diff options
-rw-r--r-- | Alc/ALu.c | 11 | ||||
-rw-r--r-- | Alc/mixer.c | 24 | ||||
-rw-r--r-- | OpenAL32/Include/alFilter.h | 8 |
3 files changed, 19 insertions, 24 deletions
@@ -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; \ } \ } \ diff --git a/OpenAL32/Include/alFilter.h b/OpenAL32/Include/alFilter.h index ef852d13..7eabe5cb 100644 --- a/OpenAL32/Include/alFilter.h +++ b/OpenAL32/Include/alFilter.h @@ -16,7 +16,7 @@ typedef struct { ALfloat history[1]; #endif } FILTER; - +/* static __inline ALfloat lpFilter4P(FILTER *iir, ALuint offset, ALfloat input) { ALfloat *history = &iir->history[offset]; @@ -34,7 +34,7 @@ static __inline ALfloat lpFilter4P(FILTER *iir, ALuint offset, ALfloat input) return output; } - +*/ static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input) { ALfloat *history = &iir->history[offset]; @@ -60,7 +60,7 @@ static __inline ALfloat lpFilter1P(FILTER *iir, ALuint offset, ALfloat input) return output; } - +/* static __inline ALfloat lpFilter4PC(const FILTER *iir, ALuint offset, ALfloat input) { const ALfloat *history = &iir->history[offset]; @@ -74,7 +74,7 @@ static __inline ALfloat lpFilter4PC(const FILTER *iir, ALuint offset, ALfloat in return output; } - +*/ static __inline ALfloat lpFilter2PC(const FILTER *iir, ALuint offset, ALfloat input) { const ALfloat *history = &iir->history[offset]; |