aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/bformatdec.c8
-rw-r--r--Alc/bformatdec.h4
-rw-r--r--Alc/effects/equalizer.c22
-rw-r--r--Alc/effects/reverb.c12
-rw-r--r--OpenAL32/Include/alFilter.h36
-rw-r--r--OpenAL32/alFilter.c6
6 files changed, 53 insertions, 35 deletions
diff --git a/Alc/bformatdec.c b/Alc/bformatdec.c
index 6503ac65..2c5326d4 100644
--- a/Alc/bformatdec.c
+++ b/Alc/bformatdec.c
@@ -11,9 +11,9 @@
#include "almalloc.h"
-void bandsplit_init(BandSplitter *splitter, ALfloat freq_mult)
+void bandsplit_init(BandSplitter *splitter, ALfloat f0norm)
{
- ALfloat w = freq_mult * F_TAU;
+ ALfloat w = f0norm * F_TAU;
ALfloat cw = cosf(w);
if(cw > FLT_EPSILON)
splitter->coeff = (sinf(w) - 1.0f) / cw;
@@ -75,9 +75,9 @@ void bandsplit_process(BandSplitter *splitter, ALfloat *restrict hpout, ALfloat
}
-void splitterap_init(SplitterAllpass *splitter, ALfloat freq_mult)
+void splitterap_init(SplitterAllpass *splitter, ALfloat f0norm)
{
- ALfloat w = freq_mult * F_TAU;
+ ALfloat w = f0norm * F_TAU;
ALfloat cw = cosf(w);
if(cw > FLT_EPSILON)
splitter->coeff = (sinf(w) - 1.0f) / cw;
diff --git a/Alc/bformatdec.h b/Alc/bformatdec.h
index baaecf40..b017cfd3 100644
--- a/Alc/bformatdec.h
+++ b/Alc/bformatdec.h
@@ -55,7 +55,7 @@ typedef struct BandSplitter {
ALfloat hp_z1;
} BandSplitter;
-void bandsplit_init(BandSplitter *splitter, ALfloat freq_mult);
+void bandsplit_init(BandSplitter *splitter, ALfloat f0norm);
void bandsplit_clear(BandSplitter *splitter);
void bandsplit_process(BandSplitter *splitter, ALfloat *restrict hpout, ALfloat *restrict lpout,
const ALfloat *input, ALsizei count);
@@ -68,7 +68,7 @@ typedef struct SplitterAllpass {
ALfloat z1;
} SplitterAllpass;
-void splitterap_init(SplitterAllpass *splitter, ALfloat freq_mult);
+void splitterap_init(SplitterAllpass *splitter, ALfloat f0norm);
void splitterap_clear(SplitterAllpass *splitter);
void splitterap_process(SplitterAllpass *splitter, ALfloat *restrict samples, ALsizei count);
diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c
index 7df15380..bc84f87f 100644
--- a/Alc/effects/equalizer.c
+++ b/Alc/effects/equalizer.c
@@ -125,7 +125,7 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCcontext
{
const ALCdevice *device = context->Device;
ALfloat frequency = (ALfloat)device->Frequency;
- ALfloat gain, freq_mult;
+ ALfloat gain, f0norm;
ALuint i;
STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer;
@@ -139,31 +139,31 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCcontext
* of the transition band.
*/
gain = maxf(sqrtf(props->Equalizer.LowGain), 0.0625f); /* Limit -24dB */
- freq_mult = props->Equalizer.LowCutoff/frequency;
+ f0norm = props->Equalizer.LowCutoff/frequency;
ALfilterState_setParams(&state->Chans[0].filter[0], ALfilterType_LowShelf,
- gain, freq_mult, calc_rcpQ_from_slope(gain, 0.75f)
+ gain, f0norm, calc_rcpQ_from_slope(gain, 0.75f)
);
gain = maxf(props->Equalizer.Mid1Gain, 0.0625f);
- freq_mult = props->Equalizer.Mid1Center/frequency;
+ f0norm = props->Equalizer.Mid1Center/frequency;
ALfilterState_setParams(&state->Chans[0].filter[1], ALfilterType_Peaking,
- gain, freq_mult, calc_rcpQ_from_bandwidth(
- freq_mult, props->Equalizer.Mid1Width
+ gain, f0norm, calc_rcpQ_from_bandwidth(
+ f0norm, props->Equalizer.Mid1Width
)
);
gain = maxf(props->Equalizer.Mid2Gain, 0.0625f);
- freq_mult = props->Equalizer.Mid2Center/frequency;
+ f0norm = props->Equalizer.Mid2Center/frequency;
ALfilterState_setParams(&state->Chans[0].filter[2], ALfilterType_Peaking,
- gain, freq_mult, calc_rcpQ_from_bandwidth(
- freq_mult, props->Equalizer.Mid2Width
+ gain, f0norm, calc_rcpQ_from_bandwidth(
+ f0norm, props->Equalizer.Mid2Width
)
);
gain = maxf(sqrtf(props->Equalizer.HighGain), 0.0625f);
- freq_mult = props->Equalizer.HighCutoff/frequency;
+ f0norm = props->Equalizer.HighCutoff/frequency;
ALfilterState_setParams(&state->Chans[0].filter[3], ALfilterType_HighShelf,
- gain, freq_mult, calc_rcpQ_from_slope(gain, 0.75f)
+ gain, f0norm, calc_rcpQ_from_slope(gain, 0.75f)
);
/* Copy the filter coefficients for the other input channels. */
diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c
index f6cd2b04..49362e2a 100644
--- a/Alc/effects/reverb.c
+++ b/Alc/effects/reverb.c
@@ -1281,23 +1281,23 @@ static ALvoid ALreverbState_update(ALreverbState *State, const ALCcontext *Conte
const ALCdevice *Device = Context->Device;
const ALlistener *Listener = Context->Listener;
ALuint frequency = Device->Frequency;
- ALfloat lfScale, hfScale, hfRatio;
+ ALfloat lf0norm, hf0norm, hfRatio;
ALfloat lfDecayTime, hfDecayTime;
ALfloat gain, gainlf, gainhf;
ALsizei i;
/* Calculate the master filters */
- hfScale = props->Reverb.HFReference / frequency;
+ hf0norm = props->Reverb.HFReference / frequency;
/* Restrict the filter gains from going below -60dB to keep the filter from
* killing most of the signal.
*/
gainhf = maxf(props->Reverb.GainHF, 0.001f);
ALfilterState_setParams(&State->Filter[0].Lp, ALfilterType_HighShelf,
- gainhf, hfScale, calc_rcpQ_from_slope(gainhf, 1.0f));
- lfScale = props->Reverb.LFReference / frequency;
+ gainhf, hf0norm, calc_rcpQ_from_slope(gainhf, 1.0f));
+ lf0norm = props->Reverb.LFReference / frequency;
gainlf = maxf(props->Reverb.GainLF, 0.001f);
ALfilterState_setParams(&State->Filter[0].Hp, ALfilterType_LowShelf,
- gainlf, lfScale, calc_rcpQ_from_slope(gainlf, 1.0f));
+ gainlf, lf0norm, calc_rcpQ_from_slope(gainlf, 1.0f));
for(i = 1;i < 4;i++)
{
ALfilterState_copyParams(&State->Filter[i].Lp, &State->Filter[0].Lp);
@@ -1341,7 +1341,7 @@ static ALvoid ALreverbState_update(ALreverbState *State, const ALCcontext *Conte
/* Update the late lines. */
UpdateLateLines(props->Reverb.Density, props->Reverb.Diffusion,
lfDecayTime, props->Reverb.DecayTime, hfDecayTime,
- F_TAU * lfScale, F_TAU * hfScale,
+ F_TAU * lf0norm, F_TAU * hf0norm,
props->Reverb.EchoTime, props->Reverb.EchoDepth,
frequency, State);
diff --git a/OpenAL32/Include/alFilter.h b/OpenAL32/Include/alFilter.h
index e0046d86..c1932e2e 100644
--- a/OpenAL32/Include/alFilter.h
+++ b/OpenAL32/Include/alFilter.h
@@ -48,22 +48,25 @@ typedef struct ALfilterState {
/* Currently only a C-based filter process method is implemented. */
#define ALfilterState_process ALfilterState_processC
-/* Calculates the rcpQ (i.e. 1/Q) coefficient for shelving filters, using the
+/**
+ * Calculates the rcpQ (i.e. 1/Q) coefficient for shelving filters, using the
* reference gain and shelf slope parameter.
- * 0 < gain
- * 0 < slope <= 1
+ * \param gain 0 < gain
+ * \param slope 0 < slope <= 1
*/
inline ALfloat calc_rcpQ_from_slope(ALfloat gain, ALfloat slope)
{
return sqrtf((gain + 1.0f/gain)*(1.0f/slope - 1.0f) + 2.0f);
}
-/* Calculates the rcpQ (i.e. 1/Q) coefficient for filters, using the frequency
- * multiple (i.e. ref_freq / sampling_freq) and bandwidth.
- * 0 < freq_mult < 0.5.
+/**
+ * Calculates the rcpQ (i.e. 1/Q) coefficient for filters, using the normalized
+ * reference frequency and bandwidth.
+ * \param f0norm 0 < f0norm < 0.5.
+ * \param bandwidth 0 < bandwidth
*/
-inline ALfloat calc_rcpQ_from_bandwidth(ALfloat freq_mult, ALfloat bandwidth)
+inline ALfloat calc_rcpQ_from_bandwidth(ALfloat f0norm, ALfloat bandwidth)
{
- ALfloat w0 = F_TAU * freq_mult;
+ ALfloat w0 = F_TAU * f0norm;
return 2.0f*sinhf(logf(2.0f)/2.0f*bandwidth*w0/sinf(w0));
}
@@ -75,7 +78,22 @@ inline void ALfilterState_clear(ALfilterState *filter)
filter->y[1] = 0.0f;
}
-void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat gain, ALfloat freq_mult, ALfloat rcpQ);
+/**
+ * Sets up the filter state for the specified filter type and its parameters.
+ *
+ * \param filter The filter object to prepare.
+ * \param type The type of filter for the object to apply.
+ * \param gain The gain for the reference frequency response. Only used by the
+ * Shelf and Peaking filter types.
+ * \param f0norm The normalized reference frequency (ref_freq / sample_rate).
+ * This is the center point for the Shelf, Peaking, and BandPass
+ * filter types, or the cutoff frequency for the LowPass and
+ * HighPass filter types.
+ * \param rcpQ The reciprocal of the Q coefficient for the filter's transition
+ * band. Can be generated from calc_rcpQ_from_slope or
+ * calc_rcpQ_from_bandwidth depending on the available data.
+ */
+void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat gain, ALfloat f0norm, ALfloat rcpQ);
inline void ALfilterState_copyParams(ALfilterState *restrict dst, const ALfilterState *restrict src)
{
diff --git a/OpenAL32/alFilter.c b/OpenAL32/alFilter.c
index 6e07d41b..4771414a 100644
--- a/OpenAL32/alFilter.c
+++ b/OpenAL32/alFilter.c
@@ -39,7 +39,7 @@ extern inline void ALfilterState_clear(ALfilterState *filter);
extern inline void ALfilterState_copyParams(ALfilterState *restrict dst, const ALfilterState *restrict src);
extern inline void ALfilterState_processPassthru(ALfilterState *filter, const ALfloat *restrict src, ALsizei numsamples);
extern inline ALfloat calc_rcpQ_from_slope(ALfloat gain, ALfloat slope);
-extern inline ALfloat calc_rcpQ_from_bandwidth(ALfloat freq_mult, ALfloat bandwidth);
+extern inline ALfloat calc_rcpQ_from_bandwidth(ALfloat f0norm, ALfloat bandwidth);
static void InitFilterParams(ALfilter *filter, ALenum type);
@@ -355,7 +355,7 @@ AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *va
}
-void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat gain, ALfloat freq_mult, ALfloat rcpQ)
+void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat gain, ALfloat f0norm, ALfloat rcpQ)
{
ALfloat alpha, sqrtgain_alpha_2;
ALfloat w0, sin_w0, cos_w0;
@@ -365,7 +365,7 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g
// Limit gain to -100dB
assert(gain > 0.00001f);
- w0 = F_TAU * freq_mult;
+ w0 = F_TAU * f0norm;
sin_w0 = sinf(w0);
cos_w0 = cosf(w0);
alpha = sin_w0/2.0f * rcpQ;