diff options
author | Chris Robinson <[email protected]> | 2015-11-01 04:43:55 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2015-11-01 05:41:06 -0800 |
commit | c57f57192067e2d68cfe4ab0fc9479d2453bfbda (patch) | |
tree | fb9dabd6296c87ff72f4271774ae9951898d9227 /Alc/effects/equalizer.c | |
parent | f094d94608e00b1b08bd8c607d16651072323bb5 (diff) |
Pass in the Q parameter for setting the filter parameters
Also better handle the peaking filter gain.
Diffstat (limited to 'Alc/effects/equalizer.c')
-rw-r--r-- | Alc/effects/equalizer.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c index 6a5ed549..244667ab 100644 --- a/Alc/effects/equalizer.c +++ b/Alc/effects/equalizer.c @@ -93,29 +93,37 @@ static ALboolean ALequalizerState_deviceUpdate(ALequalizerState *UNUSED(state), static ALvoid ALequalizerState_update(ALequalizerState *state, ALCdevice *device, const ALeffectslot *slot) { ALfloat frequency = (ALfloat)device->Frequency; + ALfloat gain, freq_mult; ComputeAmbientGains(device, slot->Gain, state->Gain); - /* Calculate coefficients for the each type of filter */ + /* Calculate coefficients for the each type of filter. Note that the shelf + * filters' gain is for the reference frequency, which is the centerpoint + * of the transition band. + */ + gain = sqrtf(slot->EffectProps.Equalizer.LowGain); + freq_mult = slot->EffectProps.Equalizer.LowCutoff/frequency; ALfilterState_setParams(&state->filter[0], ALfilterType_LowShelf, - sqrtf(slot->EffectProps.Equalizer.LowGain), - slot->EffectProps.Equalizer.LowCutoff/frequency, - 0.0f); + gain, freq_mult, calc_rcpQ_from_slope(gain, 0.75f) + ); + gain = slot->EffectProps.Equalizer.Mid1Gain; + freq_mult = slot->EffectProps.Equalizer.Mid1Center/frequency; ALfilterState_setParams(&state->filter[1], ALfilterType_Peaking, - sqrtf(slot->EffectProps.Equalizer.Mid1Gain), - slot->EffectProps.Equalizer.Mid1Center/frequency, - slot->EffectProps.Equalizer.Mid1Width); + gain, freq_mult, calc_rcpQ_from_bandwidth(freq_mult, slot->EffectProps.Equalizer.Mid1Width) + ); + gain = slot->EffectProps.Equalizer.Mid2Gain; + freq_mult = slot->EffectProps.Equalizer.Mid2Center/frequency; ALfilterState_setParams(&state->filter[2], ALfilterType_Peaking, - sqrtf(slot->EffectProps.Equalizer.Mid2Gain), - slot->EffectProps.Equalizer.Mid2Center/frequency, - slot->EffectProps.Equalizer.Mid2Width); + gain, freq_mult, calc_rcpQ_from_bandwidth(freq_mult, slot->EffectProps.Equalizer.Mid2Width) + ); + gain = sqrtf(slot->EffectProps.Equalizer.HighGain); + freq_mult = slot->EffectProps.Equalizer.HighCutoff/frequency; ALfilterState_setParams(&state->filter[3], ALfilterType_HighShelf, - sqrtf(slot->EffectProps.Equalizer.HighGain), - slot->EffectProps.Equalizer.HighCutoff/frequency, - 0.0f); + gain, freq_mult, calc_rcpQ_from_slope(gain, 0.75f) + ); } static ALvoid ALequalizerState_process(ALequalizerState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) |