summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--OpenAL32/Include/alFilter.h6
-rw-r--r--OpenAL32/alFilter.c50
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));