From feeec3433377d46f71771c3930e5e00bf9834feb Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 27 May 2013 19:14:02 -0700 Subject: Use ALfilterState for the source direct and send filters --- OpenAL32/Include/alFilter.h | 2 ++ OpenAL32/Include/alSource.h | 6 ++---- OpenAL32/alFilter.c | 11 +++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/Include/alFilter.h b/OpenAL32/Include/alFilter.h index f70b839e..9273f15c 100644 --- a/OpenAL32/Include/alFilter.h +++ b/OpenAL32/Include/alFilter.h @@ -47,6 +47,8 @@ ALfloat lpCoeffCalc(ALfloat g, ALfloat cw); typedef enum ALfilterType { + ALfilterType_LowPass, + ALfilterType_HighShelf, ALfilterType_LowShelf, ALfilterType_Peaking, diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index bd1b2931..8766c85e 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -61,8 +61,7 @@ typedef struct DirectParams { * target (eg. FrontLeft). Not used with HRTF. */ ALfloat Gains[MaxChannels][MaxChannels]; - /* A low-pass filter, using 2 chained one-pole filters. */ - FILTER Filter[MaxChannels]; + ALfilterState Filter[MaxChannels]; } DirectParams; typedef struct SendParams { @@ -72,8 +71,7 @@ typedef struct SendParams { * output buffer. */ ALfloat Gain; - /* A low-pass filter, using 2 chained one-pole filters. */ - FILTER Filter[MaxChannels]; + ALfilterState Filter[MaxChannels]; } SendParams; diff --git a/OpenAL32/alFilter.c b/OpenAL32/alFilter.c index 5bef87fd..550c99f5 100644 --- a/OpenAL32/alFilter.c +++ b/OpenAL32/alFilter.c @@ -343,6 +343,17 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g /* Calculate filter coefficients depending on filter type */ switch(type) { + case ALfilterType_LowPass: + alpha = sinf(w0) / 2.0f * sqrtf((gain + 1.0f/gain) * + (1.0f/0.75f - 1.0f) + 2.0f); + filter->b[0] = (1.0f - cosf(w0)) * 0.5f; + filter->b[1] = 1.0f - cosf(w0); + filter->b[2] = (1.0f - cosf(w0)) * 0.5f; + filter->a[0] = 1.0f + alpha; + filter->a[1] = -2.0f*cosf(w0); + filter->a[2] = 1.0f - alpha; + break; + case ALfilterType_HighShelf: alpha = sinf(w0) / 2.0f * sqrtf((gain + 1.0f/gain) * (1.0f/0.75f - 1.0f) + 2.0f); -- cgit v1.2.3