diff --git a/Quake/snd_mix.c b/Quake/snd_mix.c index 79aeea35..0af3c967 100644 --- a/Quake/snd_mix.c +++ b/Quake/snd_mix.c @@ -153,11 +153,11 @@ static void S_TransferPaintBuffer (int endtime) ============== S_MakeBlackmanWindowKernel -Based on equation 16-4 from -"The Scientist and Engineer's Guide to Digital Signal Processing" +Makes a lowpass filter kernel, from equation 16-4 in +"The Scientist and Engineer's Guide to Digital Signal Processing", -M must be even -kernel has room for M+1 floats, +M is the kernel size (doesn't count the center point), must be even +kernel has room for M+1 floats f_c is the filter cutoff frequency, as a fraction of the samplerate ============== */ @@ -196,10 +196,10 @@ static void S_MakeBlackmanWindowKernel(float *kernel, int M, float f_c) typedef struct { float *memory; // kernelsize floats float *kernel; // kernelsize floats - int kernelsize; // M+1, padded to be a multiple of 16 - int M; - int parity; // 0-3 - float f_c; + int kernelsize; // M+1, rounded up to be a multiple of 16 + int M; // M value used to make kernel, even + int parity; // 0-3 + float f_c; // cutoff frequency, [0..1], fraction of sample rate } filter_t; static void S_UpdateFilter(filter_t *filter, int M, float f_c) @@ -213,7 +213,7 @@ static void S_UpdateFilter(filter_t *filter, int M, float f_c) filter->f_c = f_c; filter->parity = 0; - // M + 1 rounded up to the next multiple of 16 + // M + 1 rounded up to the next multiple of 16 filter->kernelsize = (M + 1) + 16 - ((M + 1) % 16); filter->memory = calloc(filter->kernelsize, sizeof(float)); filter->kernel = calloc(filter->kernelsize, sizeof(float)); @@ -252,16 +252,21 @@ static void S_ApplyFilter(filter_t *filter, int *data, int stride, int count) for (i=0; i