From 70f1e54068f2ccfce30f9e5db8ea61b01283f59b Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 17 May 2014 03:08:04 -0700 Subject: Use logarithmic adjustment for the gain in the autowah effect --- Alc/effects/autowah.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Alc/effects/autowah.c b/Alc/effects/autowah.c index 9857c722..c8317c8b 100644 --- a/Alc/effects/autowah.c +++ b/Alc/effects/autowah.c @@ -71,8 +71,8 @@ static ALvoid ALautowahState_update(ALautowahState *state, ALCdevice *device, co attackTime = slot->EffectProps.Autowah.AttackTime * state->Frequency; releaseTime = slot->EffectProps.Autowah.ReleaseTime * state->Frequency; - state->AttackRate = 1.0f / attackTime; - state->ReleaseRate = 1.0f / releaseTime; + state->AttackRate = powf(1.0f/GAIN_SILENCE_THRESHOLD, 1.0f/attackTime); + state->ReleaseRate = powf(GAIN_SILENCE_THRESHOLD/1.0f, 1.0f/releaseTime); state->PeakGain = slot->EffectProps.Autowah.PeakGain; state->Resonance = slot->EffectProps.Autowah.Resonance; @@ -102,9 +102,9 @@ static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo, * incoming signal, and attack or release to reach it. */ amplitude = fabsf(smp); if(amplitude > gain) - gain = minf(gain+state->AttackRate, amplitude); + gain = minf(gain*state->AttackRate, amplitude); else if(amplitude < gain) - gain = maxf(gain-state->ReleaseRate, amplitude); + gain = maxf(gain*state->ReleaseRate, amplitude); gain = maxf(gain, GAIN_SILENCE_THRESHOLD); /* FIXME: What range does the filter cover? */ @@ -168,9 +168,9 @@ static ALeffectState *ALautowahStateFactory_create(ALautowahStateFactory *UNUSED if(!state) return NULL; SET_VTABLE2(ALautowahState, ALeffectState, state); - state->AttackRate = 0.0f; - state->ReleaseRate = 0.0f; - state->Resonance = 0.0f; + state->AttackRate = 1.0f; + state->ReleaseRate = 1.0f; + state->Resonance = 2.0f; state->PeakGain = 1.0f; state->GainCtrl = 1.0f; -- cgit v1.2.3