From e2850df07eac6e3c641a3c66ecdc153db12ef788 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 3 May 2011 16:18:46 -0700 Subject: Use the same filters for mono sources and multi-channel --- Alc/ALu.c | 11 +++-------- Alc/mixer.c | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 20 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index 07eb9315..b4a23f98 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -858,16 +858,11 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) /* Update filter coefficients. */ cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / Frequency); - /* Spatialized sources use four chained one-pole filters, so we need to - * take the fourth root of the squared gain, which is the same as the - * square root of the base gain. */ - ALSource->Params.iirFilter.coeff = lpCoeffCalc(aluSqrt(DryGainHF), cw); - + ALSource->Params.iirFilter.coeff = lpCoeffCalc(DryGainHF, cw); for(i = 0;i < NumSends;i++) { - /* The wet path uses two chained one-pole filters, so take the - * base gain (square root of the squared gain) */ - ALSource->Params.Send[i].iirFilter.coeff = lpCoeffCalc(WetGainHF[i], cw); + ALfloat a = lpCoeffCalc(WetGainHF[i]*WetGainHF[i], cw); + ALSource->Params.Send[i].iirFilter.coeff = a; } } diff --git a/Alc/mixer.c b/Alc/mixer.c index ea155754..350bcb68 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -104,7 +104,7 @@ void Mix_Hrtf_##T##_1_##sampler(ALsource *Source, ALCdevice *Device, \ if(LIKELY(OutPos == 0)) \ { \ value = sampler(data+pos, 1, frac); \ - value = lpFilter4P(DryFilter, 0, value); \ + value = lpFilter2PC(DryFilter, 0, value); \ \ HrtfHistory[HrtfOffset&HRTF_LENGTH_MASK] = value; \ for(c = 0;c < HRTF_LENGTH;c++) \ @@ -121,7 +121,7 @@ void Mix_Hrtf_##T##_1_##sampler(ALsource *Source, ALCdevice *Device, \ { \ /* First order interpolator */ \ value = sampler(data+pos, 1, frac); \ - value = lpFilter4P(DryFilter, 0, value); \ + value = lpFilter2P(DryFilter, 0, value); \ \ /* Direct path final mix buffer and panning */ \ HrtfHistory[HrtfOffset&HRTF_LENGTH_MASK] = value; \ @@ -144,7 +144,7 @@ void Mix_Hrtf_##T##_1_##sampler(ALsource *Source, ALCdevice *Device, \ if(LIKELY(OutPos == SamplesToDo)) \ { \ value = sampler(data+pos, 1, frac); \ - value = lpFilter4P(DryFilter, 0, value); \ + value = lpFilter2PC(DryFilter, 0, value); \ \ HrtfHistory[HrtfOffset&HRTF_LENGTH_MASK] = value; \ for(c = 0;c < HRTF_LENGTH;c++) \ @@ -183,7 +183,7 @@ void Mix_Hrtf_##T##_1_##sampler(ALsource *Source, ALCdevice *Device, \ if(LIKELY(OutPos == 0)) \ { \ value = sampler(data+pos, 1, frac); \ - value = lpFilter2PC(WetFilter, 0, value); \ + value = lpFilter1PC(WetFilter, 0, value); \ \ WetClickRemoval[0] -= value*WetSend; \ } \ @@ -191,7 +191,7 @@ void Mix_Hrtf_##T##_1_##sampler(ALsource *Source, ALCdevice *Device, \ { \ /* First order interpolator */ \ value = sampler(data+pos, 1, frac); \ - value = lpFilter2P(WetFilter, 0, value); \ + value = lpFilter1P(WetFilter, 0, value); \ \ /* Room path final mix buffer and panning */ \ WetBuffer[OutPos] += value*WetSend; \ @@ -204,7 +204,7 @@ void Mix_Hrtf_##T##_1_##sampler(ALsource *Source, ALCdevice *Device, \ if(LIKELY(OutPos == SamplesToDo)) \ { \ value = sampler(data+pos, 1, frac); \ - value = lpFilter2PC(WetFilter, 0, value); \ + value = lpFilter1PC(WetFilter, 0, value); \ \ WetPendingClicks[0] += value*WetSend; \ } \ @@ -486,7 +486,7 @@ static void Mix_##T##_1_##sampler(ALsource *Source, ALCdevice *Device, \ { \ value = sampler(data+pos, 1, frac); \ \ - value = lpFilter4PC(DryFilter, 0, value); \ + value = lpFilter2PC(DryFilter, 0, value); \ for(c = 0;c < MAXCHANNELS;c++) \ ClickRemoval[c] -= value*DrySend[c]; \ } \ @@ -496,7 +496,7 @@ static void Mix_##T##_1_##sampler(ALsource *Source, ALCdevice *Device, \ value = sampler(data+pos, 1, frac); \ \ /* Direct path final mix buffer and panning */ \ - value = lpFilter4P(DryFilter, 0, value); \ + value = lpFilter2P(DryFilter, 0, value); \ for(c = 0;c < MAXCHANNELS;c++) \ DryBuffer[OutPos][c] += value*DrySend[c]; \ \ @@ -509,7 +509,7 @@ static void Mix_##T##_1_##sampler(ALsource *Source, ALCdevice *Device, \ { \ value = sampler(data+pos, 1, frac); \ \ - value = lpFilter4PC(DryFilter, 0, value); \ + value = lpFilter2PC(DryFilter, 0, value); \ for(c = 0;c < MAXCHANNELS;c++) \ PendingClicks[c] += value*DrySend[c]; \ } \ @@ -540,7 +540,7 @@ static void Mix_##T##_1_##sampler(ALsource *Source, ALCdevice *Device, \ { \ value = sampler(data+pos, 1, frac); \ \ - value = lpFilter2PC(WetFilter, 0, value); \ + value = lpFilter1PC(WetFilter, 0, value); \ WetClickRemoval[0] -= value*WetSend; \ } \ for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ @@ -549,7 +549,7 @@ static void Mix_##T##_1_##sampler(ALsource *Source, ALCdevice *Device, \ value = sampler(data+pos, 1, frac); \ \ /* Room path final mix buffer and panning */ \ - value = lpFilter2P(WetFilter, 0, value); \ + value = lpFilter1P(WetFilter, 0, value); \ WetBuffer[OutPos] += value*WetSend; \ \ frac += increment; \ @@ -561,7 +561,7 @@ static void Mix_##T##_1_##sampler(ALsource *Source, ALCdevice *Device, \ { \ value = sampler(data+pos, 1, frac); \ \ - value = lpFilter2PC(WetFilter, 0, value); \ + value = lpFilter1PC(WetFilter, 0, value); \ WetPendingClicks[0] += value*WetSend; \ } \ } \ -- cgit v1.2.3