aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2015-11-01 04:43:55 -0800
committerChris Robinson <[email protected]>2015-11-01 05:41:06 -0800
commitc57f57192067e2d68cfe4ab0fc9479d2453bfbda (patch)
treefb9dabd6296c87ff72f4271774ae9951898d9227 /Alc/effects
parentf094d94608e00b1b08bd8c607d16651072323bb5 (diff)
Pass in the Q parameter for setting the filter parameters
Also better handle the peaking filter gain.
Diffstat (limited to 'Alc/effects')
-rw-r--r--Alc/effects/distortion.c6
-rw-r--r--Alc/effects/echo.c10
-rw-r--r--Alc/effects/equalizer.c34
-rw-r--r--Alc/effects/reverb.c7
4 files changed, 36 insertions, 21 deletions
diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.c
index 22e05c70..221cec39 100644
--- a/Alc/effects/distortion.c
+++ b/Alc/effects/distortion.c
@@ -72,14 +72,16 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, ALCdevice *Devi
/* Bandwidth value is constant in octaves */
bandwidth = (cutoff / 2.0f) / (cutoff * 0.67f);
ALfilterState_setParams(&state->lowpass, ALfilterType_LowPass, 1.0f,
- cutoff / (frequency*4.0f), bandwidth);
+ cutoff / (frequency*4.0f), calc_rcpQ_from_bandwidth(cutoff / (frequency*4.0f), bandwidth)
+ );
/* Bandpass filter */
cutoff = Slot->EffectProps.Distortion.EQCenter;
/* Convert bandwidth in Hz to octaves */
bandwidth = Slot->EffectProps.Distortion.EQBandwidth / (cutoff * 0.67f);
ALfilterState_setParams(&state->bandpass, ALfilterType_BandPass, 1.0f,
- cutoff / (frequency*4.0f), bandwidth);
+ cutoff / (frequency*4.0f), calc_rcpQ_from_bandwidth(cutoff / (frequency*4.0f), bandwidth)
+ );
ComputeAmbientGains(Device, Slot->Gain, state->Gain);
}
diff --git a/Alc/effects/echo.c b/Alc/effects/echo.c
index b852a096..f5a53c36 100644
--- a/Alc/effects/echo.c
+++ b/Alc/effects/echo.c
@@ -85,8 +85,7 @@ static ALvoid ALechoState_update(ALechoState *state, ALCdevice *Device, const AL
{
ALfloat pandir[3] = { 0.0f, 0.0f, 0.0f };
ALuint frequency = Device->Frequency;
- ALfloat gain = Slot->Gain;
- ALfloat lrpan;
+ ALfloat gain, lrpan;
state->Tap[0].delay = fastf2u(Slot->EffectProps.Echo.Delay * frequency) + 1;
state->Tap[1].delay = fastf2u(Slot->EffectProps.Echo.LRDelay * frequency);
@@ -96,9 +95,12 @@ static ALvoid ALechoState_update(ALechoState *state, ALCdevice *Device, const AL
state->FeedGain = Slot->EffectProps.Echo.Feedback;
+ gain = minf(1.0f - Slot->EffectProps.Echo.Damping, 0.01f);
ALfilterState_setParams(&state->Filter, ALfilterType_HighShelf,
- 1.0f - Slot->EffectProps.Echo.Damping,
- LOWPASSFREQREF/frequency, 0.0f);
+ gain, LOWPASSFREQREF/frequency,
+ calc_rcpQ_from_slope(gain, 0.75f));
+
+ gain = Slot->Gain;
/* First tap panning */
pandir[0] = -lrpan;
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)
diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c
index 6c3f2691..71e12b33 100644
--- a/Alc/effects/reverb.c
+++ b/Alc/effects/reverb.c
@@ -1112,6 +1112,7 @@ static ALvoid ALreverbState_update(ALreverbState *State, ALCdevice *Device, cons
const ALeffectProps *props = &Slot->EffectProps;
ALuint frequency = Device->Frequency;
ALfloat lfscale, hfscale, hfRatio;
+ ALfloat gainlf, gainhf;
ALfloat cw, x, y;
if(Slot->EffectType == AL_EFFECT_EAXREVERB && !EmulateEAXReverb)
@@ -1121,11 +1122,13 @@ static ALvoid ALreverbState_update(ALreverbState *State, ALCdevice *Device, cons
// Calculate the master filters
hfscale = props->Reverb.HFReference / frequency;
+ gainhf = maxf(props->Reverb.GainHF, 0.0001f);
ALfilterState_setParams(&State->LpFilter, ALfilterType_HighShelf,
- props->Reverb.GainHF, hfscale, 0.0f);
+ gainhf, hfscale, calc_rcpQ_from_slope(gainhf, 0.75f));
lfscale = props->Reverb.LFReference / frequency;
+ gainlf = maxf(props->Reverb.GainLF, 0.0001f);
ALfilterState_setParams(&State->HpFilter, ALfilterType_LowShelf,
- props->Reverb.GainLF, lfscale, 0.0f);
+ gainlf, lfscale, calc_rcpQ_from_slope(gainlf, 0.75f));
// Update the modulator line.
UpdateModulator(props->Reverb.ModulationTime, props->Reverb.ModulationDepth,