diff options
author | Chris Robinson <[email protected]> | 2014-05-17 02:09:43 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-05-17 02:09:43 -0700 |
commit | 1efddac3dbdf6bb2192172c6d09be374205d1221 (patch) | |
tree | 546f9dcf3b8b329d6b3eafbfeedfb88df99e3c3d /OpenAL32 | |
parent | c5b25ba2a76e50090c82dc0e246bce422ce9e4fc (diff) |
Document the different filter types, and combine some split lines
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alFilter.h | 6 | ||||
-rw-r--r-- | OpenAL32/alFilter.c | 50 |
2 files changed, 20 insertions, 36 deletions
diff --git a/OpenAL32/Include/alFilter.h b/OpenAL32/Include/alFilter.h index 4a66ef9b..86547182 100644 --- a/OpenAL32/Include/alFilter.h +++ b/OpenAL32/Include/alFilter.h @@ -15,12 +15,18 @@ extern "C" { * http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt */ typedef enum ALfilterType { + /** EFX-style low-pass filter, specifying a gain and reference frequency. */ ALfilterType_HighShelf, + /** EFX-style high-pass filter, specifying a gain and reference frequency. */ ALfilterType_LowShelf, + /** Peaking filter, specifying a gain, reference frequency, and bandwidth. */ ALfilterType_Peaking, + /** Low-pass cut-off filter, specifying a cut-off frequency and bandwidth. */ ALfilterType_LowPass, + /** High-pass cut-off filter, specifying a cut-off frequency and bandwidth. */ ALfilterType_HighPass, + /** Band-pass filter, specifying a center frequency and bandwidth. */ ALfilterType_BandPass, } ALfilterType; diff --git a/OpenAL32/alFilter.c b/OpenAL32/alFilter.c index 70595aa0..ade41f4c 100644 --- a/OpenAL32/alFilter.c +++ b/OpenAL32/alFilter.c @@ -349,44 +349,22 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g switch(type) { case ALfilterType_HighShelf: - alpha = sinf(w0) / 2.0f * sqrtf((gain + 1.0f/gain) * - (1.0f/0.75f - 1.0f) + 2.0f); - filter->b[0] = gain * ((gain + 1.0f) + - (gain - 1.0f) * cosf(w0) + - 2.0f * sqrtf(gain) * alpha); - filter->b[1] = -2.0f * gain * ((gain - 1.0f) + - (gain + 1.0f) * cosf(w0)); - filter->b[2] = gain * ((gain + 1.0f) + - (gain - 1.0f) * cosf(w0) - - 2.0f * sqrtf(gain) * alpha); - filter->a[0] = (gain + 1.0f) - - (gain - 1.0f) * cosf(w0) + - 2.0f * sqrtf(gain) * alpha; - filter->a[1] = 2.0f * ((gain - 1.0f) - - (gain + 1.0f) * cosf(w0)); - filter->a[2] = (gain + 1.0f) - - (gain - 1.0f) * cosf(w0) - - 2.0f * sqrtf(gain) * alpha; + alpha = sinf(w0)/2.0f*sqrtf((gain + 1.0f/gain)*(1.0f/0.75f - 1.0f) + 2.0f); + filter->b[0] = gain*((gain+1.0f) + (gain-1.0f)*cosf(w0) + 2.0f*sqrtf(gain)*alpha); + filter->b[1] = -2.0f*gain*((gain-1.0f) + (gain+1.0f)*cosf(w0) ); + filter->b[2] = gain*((gain+1.0f) + (gain-1.0f)*cosf(w0) - 2.0f*sqrtf(gain)*alpha); + filter->a[0] = (gain+1.0f) - (gain-1.0f)*cosf(w0) + 2.0f*sqrtf(gain)*alpha; + filter->a[1] = 2.0f* ((gain-1.0f) - (gain+1.0f)*cosf(w0) ); + filter->a[2] = (gain+1.0f) - (gain-1.0f)*cosf(w0) - 2.0f*sqrtf(gain)*alpha; break; case ALfilterType_LowShelf: - alpha = sinf(w0) / 2.0f * sqrtf((gain + 1.0f / gain) * - (1.0f / 0.75f - 1.0f) + 2.0f); - filter->b[0] = gain * ((gain + 1.0f) - - (gain - 1.0f) * cosf(w0) + - 2.0f * sqrtf(gain) * alpha); - filter->b[1] = 2.0f * gain * ((gain - 1.0f) - - (gain + 1.0f) * cosf(w0)); - filter->b[2] = gain * ((gain + 1.0f) - - (gain - 1.0f) * cosf(w0) - - 2.0f * sqrtf(gain) * alpha); - filter->a[0] = (gain + 1.0f) + - (gain - 1.0f) * cosf(w0) + - 2.0f * sqrtf(gain) * alpha; - filter->a[1] = -2.0f * ((gain - 1.0f) + - (gain + 1.0f) * cosf(w0)); - filter->a[2] = (gain + 1.0f) + - (gain - 1.0f) * cosf(w0) - - 2.0f * sqrtf(gain) * alpha; + alpha = sinf(w0)/2.0f*sqrtf((gain + 1.0f/gain)*(1.0f/0.75f - 1.0f) + 2.0f); + filter->b[0] = gain*((gain+1.0f) - (gain-1.0f)*cosf(w0) + 2.0f*sqrtf(gain)*alpha); + filter->b[1] = 2.0f*gain*((gain-1.0f) - (gain+1.0f)*cosf(w0) ); + filter->b[2] = gain*((gain+1.0f) - (gain-1.0f)*cosf(w0) - 2.0f*sqrtf(gain)*alpha); + filter->a[0] = (gain+1.0f) + (gain-1.0f)*cosf(w0) + 2.0f*sqrtf(gain)*alpha; + filter->a[1] = -2.0f* ((gain-1.0f) + (gain+1.0f)*cosf(w0) ); + filter->a[2] = (gain+1.0f) + (gain-1.0f)*cosf(w0) - 2.0f*sqrtf(gain)*alpha; break; case ALfilterType_Peaking: alpha = sinf(w0) * sinhf(logf(2.0f) / 2.0f * bandwidth * w0 / sinf(w0)); |