diff options
-rw-r--r-- | Alc/ALu.c | 33 | ||||
-rw-r--r-- | Alc/alcEcho.c | 9 | ||||
-rw-r--r-- | OpenAL32/Include/alFilter.h | 33 |
3 files changed, 34 insertions, 41 deletions
@@ -140,39 +140,6 @@ __inline ALuint aluChannelsFromFormat(ALenum format) } -static __inline ALfloat lpFilter4P(FILTER *iir, ALuint offset, ALfloat input) -{ - ALfloat *history = &iir->history[offset]; - ALfloat a = iir->coeff; - ALfloat output = input; - - output = output + (history[0]-output)*a; - history[0] = output; - output = output + (history[1]-output)*a; - history[1] = output; - output = output + (history[2]-output)*a; - history[2] = output; - output = output + (history[3]-output)*a; - history[3] = output; - - return output; -} - -static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input) -{ - ALfloat *history = &iir->history[offset]; - ALfloat a = iir->coeff; - ALfloat output = input; - - output = output + (history[0]-output)*a; - history[0] = output; - output = output + (history[1]-output)*a; - history[1] = output; - - return output; -} - - static __inline ALshort aluF2S(ALfloat Value) { ALint i; diff --git a/Alc/alcEcho.c b/Alc/alcEcho.c index e518fb21..feede2ba 100644 --- a/Alc/alcEcho.c +++ b/Alc/alcEcho.c @@ -144,8 +144,6 @@ ALvoid EchoUpdate(ALCcontext *Context, struct ALeffectslot *Slot, ALeffect *Effe ALvoid EchoProcess(ALechoState *state, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS]) { - ALfloat *history = state->iirFilter.history; - const ALfloat a = state->iirFilter.coeff; const ALuint delay = state->BufferLength-1; ALuint tap1off = state->Tap[0].offset; ALuint tap2off = state->Tap[1].offset; @@ -156,12 +154,7 @@ ALvoid EchoProcess(ALechoState *state, ALuint SamplesToDo, const ALfloat *Sample for(i = 0;i < SamplesToDo;i++) { // Apply damping - samp[0] = state->SampleBuffer[tap2off] + SamplesIn[i]; - - samp[0] += (history[0]-samp[0]) * a; - history[0] = samp[0]; - samp[0] += (history[1]-samp[0]) * a; - history[1] = samp[0]; + samp[0] = lpFilter2P(&state->iirFilter, 0, state->SampleBuffer[tap2off]+SamplesIn[i]); // Apply feedback gain and mix in the new sample state->SampleBuffer[fboff] = samp[0] * state->FeedGain; diff --git a/OpenAL32/Include/alFilter.h b/OpenAL32/Include/alFilter.h index 40fff4fd..c0a05d6a 100644 --- a/OpenAL32/Include/alFilter.h +++ b/OpenAL32/Include/alFilter.h @@ -13,6 +13,39 @@ typedef struct { ALfloat history[0]; } FILTER; +static __inline ALfloat lpFilter4P(FILTER *iir, ALuint offset, ALfloat input) +{ + ALfloat *history = &iir->history[offset]; + ALfloat a = iir->coeff; + ALfloat output = input; + + output = output + (history[0]-output)*a; + history[0] = output; + output = output + (history[1]-output)*a; + history[1] = output; + output = output + (history[2]-output)*a; + history[2] = output; + output = output + (history[3]-output)*a; + history[3] = output; + + return output; +} + +static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input) +{ + ALfloat *history = &iir->history[offset]; + ALfloat a = iir->coeff; + ALfloat output = input; + + output = output + (history[0]-output)*a; + history[0] = output; + output = output + (history[1]-output)*a; + history[1] = output; + + return output; +} + + #define AL_FILTER_TYPE 0x8001 #define AL_FILTER_NULL 0x0000 |