From e4186f49039a17916dedaa536143761d0a6caa87 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 21 May 2013 07:10:24 -0700 Subject: Use a properly-defined history for the FILTER struct --- Alc/ALu.c | 14 +++++++++----- Alc/alcEcho.c | 3 +-- Alc/alcModulator.c | 7 +++---- Alc/alcReverb.c | 5 ++--- Alc/mixer.c | 12 ++++++------ 5 files changed, 21 insertions(+), 20 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index 1288f7b2..6b6917bf 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -254,6 +254,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) ALboolean DirectChannels; ALfloat hwidth = 0.0f; ALfloat Pitch; + ALfloat coeff; ALfloat cw; ALint i, c; @@ -459,11 +460,14 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) /* We use two chained one-pole filters, so we need to take the * square root of the squared gain, which is the same as the base * gain. */ - ALSource->Params.Direct.iirFilter.coeff = lpCoeffCalc(DryGainHF, cw); + coeff = lpCoeffCalc(DryGainHF, cw); + for(c = 0;c < num_channels;c++) + ALSource->Params.Direct.Filter[c].coeff = lpCoeffCalc(DryGainHF, cw); for(i = 0;i < NumSends;i++) { - ALfloat a = lpCoeffCalc(WetGainHF[i], cw); - ALSource->Params.Send[i].iirFilter.coeff = a; + coeff = lpCoeffCalc(WetGainHF[i], cw); + for(c = 0;c < num_channels;c++) + ALSource->Params.Send[i].Filter[c].coeff = coeff; } } @@ -903,11 +907,11 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) /* Update filter coefficients. */ cw = cosf(F_PI*2.0f * LOWPASSFREQREF / Frequency); - ALSource->Params.Direct.iirFilter.coeff = lpCoeffCalc(DryGainHF, cw); + ALSource->Params.Direct.Filter[0].coeff = lpCoeffCalc(DryGainHF, cw); for(i = 0;i < NumSends;i++) { ALfloat a = lpCoeffCalc(WetGainHF[i], cw); - ALSource->Params.Send[i].iirFilter.coeff = a; + ALSource->Params.Send[i].Filter[0].coeff = a; } } diff --git a/Alc/alcEcho.c b/Alc/alcEcho.c index ada61c96..1aab9870 100644 --- a/Alc/alcEcho.c +++ b/Alc/alcEcho.c @@ -48,7 +48,6 @@ typedef struct ALechoState { ALfloat FeedGain; FILTER iirFilter; - ALfloat history[2]; } ALechoState; static ALvoid ALechoState_Destroy(ALechoState *state) @@ -144,7 +143,7 @@ static ALvoid ALechoState_Process(ALechoState *state, ALuint SamplesToDo, const // Apply damping and feedback gain to the second tap, and mix in the // new sample - smp = lpFilter2P(&state->iirFilter, 0, temps[i][1]+SamplesIn[i]); + smp = lpFilter2P(&state->iirFilter, temps[i][1]+SamplesIn[i]); state->SampleBuffer[offset&mask] = smp * state->FeedGain; } diff --git a/Alc/alcModulator.c b/Alc/alcModulator.c index 5d4fdab8..bb90d646 100644 --- a/Alc/alcModulator.c +++ b/Alc/alcModulator.c @@ -45,7 +45,6 @@ typedef struct ALmodulatorState { ALfloat Gain[MaxChannels]; FILTER iirFilter; - ALfloat history[1]; } ALmodulatorState; #define WAVEFORM_FRACBITS 24 @@ -68,9 +67,9 @@ static __inline ALfloat Square(ALuint index) } -static __inline ALfloat hpFilter1P(FILTER *iir, ALuint offset, ALfloat input) +static __inline ALfloat hpFilter1P(FILTER *iir, ALfloat input) { - ALfloat *history = &iir->history[offset]; + ALfloat *history = iir->history; ALfloat a = iir->coeff; ALfloat output = input; @@ -100,7 +99,7 @@ static void Process##func(ALmodulatorState *state, ALuint SamplesToDo, \ { \ ALfloat samp; \ samp = SamplesIn[base+i]; \ - samp = hpFilter1P(&state->iirFilter, 0, samp); \ + samp = hpFilter1P(&state->iirFilter, samp); \ \ index += step; \ index &= WAVEFORM_FRACMASK; \ diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c index 2bed00a5..01f4ab83 100644 --- a/Alc/alcReverb.c +++ b/Alc/alcReverb.c @@ -51,7 +51,6 @@ typedef struct ALreverbState { // Master effect low-pass filter (2 chained 1-pole filters). FILTER LpFilter; - ALfloat LpHistory[2]; struct { // Modulator delay line. @@ -483,7 +482,7 @@ static __inline ALvoid VerbPass(ALreverbState *State, ALfloat in, ALfloat *RESTR ALfloat feed, late[4], taps[4]; // Low-pass filter the incoming sample. - in = lpFilter2P(&State->LpFilter, 0, in); + in = lpFilter2P(&State->LpFilter, in); // Feed the initial delay line. DelayLineIn(&State->Delay, State->Offset, in); @@ -522,7 +521,7 @@ static __inline ALvoid EAXVerbPass(ALreverbState *State, ALfloat in, ALfloat *RE ALfloat feed, taps[4]; // Low-pass filter the incoming sample. - in = lpFilter2P(&State->LpFilter, 0, in); + in = lpFilter2P(&State->LpFilter, in); // Perform any modulation on the input. in = EAXModulation(State, in); diff --git a/Alc/mixer.c b/Alc/mixer.c index f75a7803..84f48094 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -84,13 +84,13 @@ static void SilenceData(ALfloat *dst, ALuint samples) } -static void Filter2P(FILTER *filter, ALuint chan, ALfloat *RESTRICT dst, - const ALfloat *RESTRICT src, ALuint numsamples) +static void Filter2P(FILTER *filter, ALfloat *RESTRICT dst, const ALfloat *RESTRICT src, + ALuint numsamples) { ALuint i; for(i = 0;i < numsamples;i++) - dst[i] = lpFilter2P(filter, chan, src[i]); - dst[i] = lpFilter2PC(filter, chan, src[i]); + dst[i] = lpFilter2P(filter, src[i]); + dst[i] = lpFilter2PC(filter, src[i]); } @@ -328,7 +328,7 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo) { DirectParams *directparms = &Source->Params.Direct; - Filter2P(&directparms->iirFilter, chan, SrcData, ResampledData, + Filter2P(&directparms->Filter[chan], SrcData, ResampledData, DstBufferSize); Source->Params.DryMix(directparms, SrcData, chan, OutPos, SamplesToDo, DstBufferSize); @@ -340,7 +340,7 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo) if(!sendparms->Slot) continue; - Filter2P(&sendparms->iirFilter, chan, SrcData, ResampledData, + Filter2P(&sendparms->Filter[chan], SrcData, ResampledData, DstBufferSize); Source->Params.WetMix(sendparms, SrcData, OutPos, SamplesToDo, DstBufferSize); -- cgit v1.2.3