diff options
author | Chris Robinson <[email protected]> | 2018-03-23 14:52:59 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-03-23 14:52:59 -0700 |
commit | 6990478369e76a55aa27bebceb45db081fe8144e (patch) | |
tree | 0283f2b57eaea6d96b68dd0faad781c21c061145 /Alc/filters | |
parent | e37634e908c7563e6281997d50800a2f9633d8d2 (diff) |
Rename ALfilterState/Type to BiquadState/Type
Diffstat (limited to 'Alc/filters')
-rw-r--r-- | Alc/filters/defs.h | 32 | ||||
-rw-r--r-- | Alc/filters/filter.c | 22 |
2 files changed, 27 insertions, 27 deletions
diff --git a/Alc/filters/defs.h b/Alc/filters/defs.h index f4e1e62c..c26427fb 100644 --- a/Alc/filters/defs.h +++ b/Alc/filters/defs.h @@ -14,30 +14,30 @@ * the square root of the desired linear gain (or halve the dB gain). */ -typedef enum ALfilterType { +typedef enum BiquadType { /** EFX-style low-pass filter, specifying a gain and reference frequency. */ - ALfilterType_HighShelf, + BiquadType_HighShelf, /** EFX-style high-pass filter, specifying a gain and reference frequency. */ - ALfilterType_LowShelf, + BiquadType_LowShelf, /** Peaking filter, specifying a gain and reference frequency. */ - ALfilterType_Peaking, + BiquadType_Peaking, /** Low-pass cut-off filter, specifying a cut-off frequency. */ - ALfilterType_LowPass, + BiquadType_LowPass, /** High-pass cut-off filter, specifying a cut-off frequency. */ - ALfilterType_HighPass, + BiquadType_HighPass, /** Band-pass filter, specifying a center frequency. */ - ALfilterType_BandPass, -} ALfilterType; + BiquadType_BandPass, +} BiquadType; -typedef struct ALfilterState { +typedef struct BiquadState { ALfloat x[2]; /* History of two last input samples */ ALfloat y[2]; /* History of two last output samples */ ALfloat b0, b1, b2; /* Transfer function coefficients "b" */ ALfloat a1, a2; /* Transfer function coefficients "a" (a0 is pre-applied) */ -} ALfilterState; +} BiquadState; /* Currently only a C-based filter process method is implemented. */ -#define ALfilterState_process ALfilterState_processC +#define BiquadState_process BiquadState_processC /** * Calculates the rcpQ (i.e. 1/Q) coefficient for shelving filters, using the @@ -61,7 +61,7 @@ inline ALfloat calc_rcpQ_from_bandwidth(ALfloat f0norm, ALfloat bandwidth) return 2.0f*sinhf(logf(2.0f)/2.0f*bandwidth*w0/sinf(w0)); } -inline void ALfilterState_clear(ALfilterState *filter) +inline void BiquadState_clear(BiquadState *filter) { filter->x[0] = 0.0f; filter->x[1] = 0.0f; @@ -84,9 +84,9 @@ inline void ALfilterState_clear(ALfilterState *filter) * 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); +void BiquadState_setParams(BiquadState *filter, BiquadType type, ALfloat gain, ALfloat f0norm, ALfloat rcpQ); -inline void ALfilterState_copyParams(ALfilterState *restrict dst, const ALfilterState *restrict src) +inline void BiquadState_copyParams(BiquadState *restrict dst, const BiquadState *restrict src) { dst->b0 = src->b0; dst->b1 = src->b1; @@ -95,9 +95,9 @@ inline void ALfilterState_copyParams(ALfilterState *restrict dst, const ALfilter dst->a2 = src->a2; } -void ALfilterState_processC(ALfilterState *filter, ALfloat *restrict dst, const ALfloat *restrict src, ALsizei numsamples); +void BiquadState_processC(BiquadState *filter, ALfloat *restrict dst, const ALfloat *restrict src, ALsizei numsamples); -inline void ALfilterState_processPassthru(ALfilterState *filter, const ALfloat *restrict src, ALsizei numsamples) +inline void BiquadState_processPassthru(BiquadState *filter, const ALfloat *restrict src, ALsizei numsamples) { if(numsamples >= 2) { diff --git a/Alc/filters/filter.c b/Alc/filters/filter.c index 1cf18f08..4d757be7 100644 --- a/Alc/filters/filter.c +++ b/Alc/filters/filter.c @@ -7,14 +7,14 @@ #include "alMain.h" #include "defs.h" -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 void BiquadState_clear(BiquadState *filter); +extern inline void BiquadState_copyParams(BiquadState *restrict dst, const BiquadState *restrict src); +extern inline void BiquadState_processPassthru(BiquadState *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 f0norm, ALfloat bandwidth); -void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat gain, ALfloat f0norm, ALfloat rcpQ) +void BiquadState_setParams(BiquadState *filter, BiquadType type, ALfloat gain, ALfloat f0norm, ALfloat rcpQ) { ALfloat alpha, sqrtgain_alpha_2; ALfloat w0, sin_w0, cos_w0; @@ -32,7 +32,7 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g /* Calculate filter coefficients depending on filter type */ switch(type) { - case ALfilterType_HighShelf: + case BiquadType_HighShelf: sqrtgain_alpha_2 = 2.0f * sqrtf(gain) * alpha; b[0] = gain*((gain+1.0f) + (gain-1.0f)*cos_w0 + sqrtgain_alpha_2); b[1] = -2.0f*gain*((gain-1.0f) + (gain+1.0f)*cos_w0 ); @@ -41,7 +41,7 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g a[1] = 2.0f* ((gain-1.0f) - (gain+1.0f)*cos_w0 ); a[2] = (gain+1.0f) - (gain-1.0f)*cos_w0 - sqrtgain_alpha_2; break; - case ALfilterType_LowShelf: + case BiquadType_LowShelf: sqrtgain_alpha_2 = 2.0f * sqrtf(gain) * alpha; b[0] = gain*((gain+1.0f) - (gain-1.0f)*cos_w0 + sqrtgain_alpha_2); b[1] = 2.0f*gain*((gain-1.0f) - (gain+1.0f)*cos_w0 ); @@ -50,7 +50,7 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g a[1] = -2.0f* ((gain-1.0f) + (gain+1.0f)*cos_w0 ); a[2] = (gain+1.0f) + (gain-1.0f)*cos_w0 - sqrtgain_alpha_2; break; - case ALfilterType_Peaking: + case BiquadType_Peaking: gain = sqrtf(gain); b[0] = 1.0f + alpha * gain; b[1] = -2.0f * cos_w0; @@ -60,7 +60,7 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g a[2] = 1.0f - alpha / gain; break; - case ALfilterType_LowPass: + case BiquadType_LowPass: b[0] = (1.0f - cos_w0) / 2.0f; b[1] = 1.0f - cos_w0; b[2] = (1.0f - cos_w0) / 2.0f; @@ -68,7 +68,7 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g a[1] = -2.0f * cos_w0; a[2] = 1.0f - alpha; break; - case ALfilterType_HighPass: + case BiquadType_HighPass: b[0] = (1.0f + cos_w0) / 2.0f; b[1] = -(1.0f + cos_w0); b[2] = (1.0f + cos_w0) / 2.0f; @@ -76,7 +76,7 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g a[1] = -2.0f * cos_w0; a[2] = 1.0f - alpha; break; - case ALfilterType_BandPass: + case BiquadType_BandPass: b[0] = alpha; b[1] = 0; b[2] = -alpha; @@ -94,7 +94,7 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g } -void ALfilterState_processC(ALfilterState *filter, ALfloat *restrict dst, const ALfloat *restrict src, ALsizei numsamples) +void BiquadState_processC(BiquadState *filter, ALfloat *restrict dst, const ALfloat *restrict src, ALsizei numsamples) { ALsizei i; if(LIKELY(numsamples > 1)) |