Use logarithmic adjustment for the gain in the autowah effect

This commit is contained in:
Chris Robinson
2014-05-17 03:08:04 -07:00
parent 1efddac3db
commit 70f1e54068
+7 -7
View File
@@ -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;