aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/effects')
-rw-r--r--Alc/effects/echo.c16
-rw-r--r--Alc/effects/modulator.c5
-rw-r--r--Alc/effects/reverb.c24
3 files changed, 24 insertions, 21 deletions
diff --git a/Alc/effects/echo.c b/Alc/effects/echo.c
index b2b50836..a45f3398 100644
--- a/Alc/effects/echo.c
+++ b/Alc/effects/echo.c
@@ -54,7 +54,7 @@ typedef struct ALechoState {
ALfloat FeedGain;
- FILTER iirFilter;
+ ALfilterState Filter;
} ALechoState;
static ALvoid ALechoState_Destruct(ALechoState *state)
@@ -92,7 +92,7 @@ static ALboolean ALechoState_DeviceUpdate(ALechoState *state, ALCdevice *Device)
static ALvoid ALechoState_Update(ALechoState *state, ALCdevice *Device, const ALeffectslot *Slot)
{
ALuint frequency = Device->Frequency;
- ALfloat lrpan, cw, g, gain;
+ ALfloat lrpan, gain;
ALfloat dirGain;
ALuint i;
@@ -104,9 +104,9 @@ static ALvoid ALechoState_Update(ALechoState *state, ALCdevice *Device, const AL
state->FeedGain = Slot->EffectProps.Echo.Feedback;
- cw = cosf(F_PI*2.0f * LOWPASSFREQREF / frequency);
- g = 1.0f - Slot->EffectProps.Echo.Damping;
- state->iirFilter.coeff = lpCoeffCalc(g, cw);
+ ALfilterState_setParams(&state->Filter, ALfilterType_LowPass,
+ 1.0f - Slot->EffectProps.Echo.Damping,
+ (ALfloat)LOWPASSFREQREF/frequency, 0.0f);
gain = Slot->Gain;
for(i = 0;i < MaxChannels;i++)
@@ -148,7 +148,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, temps[i][1]+SamplesIn[i]);
+ smp = ALfilterState_processSingle(&state->Filter, temps[i][1]+SamplesIn[i]);
state->SampleBuffer[offset&mask] = smp * state->FeedGain;
}
@@ -199,9 +199,7 @@ ALeffectState *ALechoStateFactory_create(ALechoStateFactory *factory)
state->Tap[1].delay = 0;
state->Offset = 0;
- state->iirFilter.coeff = 0.0f;
- state->iirFilter.history[0] = 0.0f;
- state->iirFilter.history[1] = 0.0f;
+ ALfilterState_clear(&state->Filter);
return STATIC_CAST(ALeffectState, state);
}
diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c
index 0a8a4512..0bfca76c 100644
--- a/Alc/effects/modulator.c
+++ b/Alc/effects/modulator.c
@@ -37,6 +37,11 @@ typedef struct ALmodulatorStateFactory {
static ALmodulatorStateFactory ModulatorFactory;
+typedef struct {
+ ALfloat coeff;
+ ALfloat history[2];
+} FILTER;
+
typedef struct ALmodulatorState {
DERIVE_FROM_TYPE(ALeffectState);
diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c
index 7dcabe3a..5d85ee7b 100644
--- a/Alc/effects/reverb.c
+++ b/Alc/effects/reverb.c
@@ -57,8 +57,8 @@ typedef struct ALreverbState {
ALfloat *SampleBuffer;
ALuint TotalSamples;
- // Master effect low-pass filter (2 chained 1-pole filters).
- FILTER LpFilter;
+ // Master effect low-pass filter
+ ALfilterState LpFilter;
struct {
// Modulator delay line.
@@ -490,7 +490,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, in);
+ in = ALfilterState_processSingle(&State->LpFilter, in);
// Feed the initial delay line.
DelayLineIn(&State->Delay, State->Offset, in);
@@ -529,7 +529,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, in);
+ in = ALfilterState_processSingle(&State->LpFilter, in);
// Perform any modulation on the input.
in = EAXModulation(State, in);
@@ -1083,7 +1083,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection
static ALvoid ALreverbState_Update(ALreverbState *State, ALCdevice *Device, const ALeffectslot *Slot)
{
ALuint frequency = Device->Frequency;
- ALfloat cw, x, y, hfRatio;
+ ALfloat freq_scale, cw, x, y, hfRatio;
if(Slot->EffectType == AL_EFFECT_EAXREVERB && !EmulateEAXReverb)
State->IsEax = AL_TRUE;
@@ -1092,11 +1092,12 @@ static ALvoid ALreverbState_Update(ALreverbState *State, ALCdevice *Device, cons
// Calculate the master low-pass filter (from the master effect HF gain).
if(State->IsEax)
- cw = CalcI3DL2HFreq(Slot->EffectProps.Reverb.HFReference, frequency);
+ freq_scale = Slot->EffectProps.Reverb.HFReference / frequency;
else
- cw = CalcI3DL2HFreq(LOWPASSFREQREF, frequency);
- // This is done with 2 chained 1-pole filters, so no need to square g.
- State->LpFilter.coeff = lpCoeffCalc(Slot->EffectProps.Reverb.GainHF, cw);
+ freq_scale = (ALfloat)LOWPASSFREQREF / frequency;
+ ALfilterState_setParams(&State->LpFilter, ALfilterType_LowPass,
+ Slot->EffectProps.Reverb.GainHF,
+ freq_scale, 0.0f);
if(State->IsEax)
{
@@ -1133,6 +1134,7 @@ static ALvoid ALreverbState_Update(ALreverbState *State, ALCdevice *Device, cons
Slot->EffectProps.Reverb.AirAbsorptionGainHF,
Slot->EffectProps.Reverb.DecayTime);
+ cw = cosf(F_PI*2.0f * freq_scale);
// Update the late lines.
UpdateLateLines(Slot->EffectProps.Reverb.Gain, Slot->EffectProps.Reverb.LateReverbGain,
x, Slot->EffectProps.Reverb.Density, Slot->EffectProps.Reverb.DecayTime,
@@ -1195,9 +1197,7 @@ static ALeffectState *ALreverbStateFactory_create(ALreverbStateFactory *factory)
state->TotalSamples = 0;
state->SampleBuffer = NULL;
- state->LpFilter.coeff = 0.0f;
- state->LpFilter.history[0] = 0.0f;
- state->LpFilter.history[1] = 0.0f;
+ ALfilterState_clear(&state->LpFilter);
state->Mod.Delay.Mask = 0;
state->Mod.Delay.Line = NULL;