summaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2007-12-17 22:42:38 -0800
committerChris Robinson <[email protected]>2007-12-17 22:42:38 -0800
commit168d8e3beee5f809f79f6d0067cd51e25ba65295 (patch)
tree6015887ebc558845f681206dc26d59931f19acf6 /OpenAL32
parent654788f2cf0bc9bf4fe5ee7a1ef61fd3e7b2b650 (diff)
Add AL_FILTER_LOWPASS support
Direct filters only, since auxiliary sends and slots aren't available yet
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alFilter.h7
-rw-r--r--OpenAL32/alExtension.c4
-rw-r--r--OpenAL32/alFilter.c65
3 files changed, 76 insertions, 0 deletions
diff --git a/OpenAL32/Include/alFilter.h b/OpenAL32/Include/alFilter.h
index b1a61d59..038304e8 100644
--- a/OpenAL32/Include/alFilter.h
+++ b/OpenAL32/Include/alFilter.h
@@ -14,11 +14,18 @@ extern "C" {
#define AL_FILTER_HIGHPASS 0x0002
#define AL_FILTER_BANDPASS 0x0003
+#define AL_LOWPASS_GAIN 0x0001
+#define AL_LOWPASS_GAINHF 0x0002
+
+
typedef struct ALfilter_struct
{
// Filter type (AL_FILTER_NULL, ...)
ALenum type;
+ ALfloat Gain;
+ ALfloat GainHF;
+
// Index to itself
ALuint filter;
diff --git a/OpenAL32/alExtension.c b/OpenAL32/alExtension.c
index e38dcb7b..54371ff4 100644
--- a/OpenAL32/alExtension.c
+++ b/OpenAL32/alExtension.c
@@ -255,6 +255,10 @@ static ALenums enumeration[]={
{ (ALchar *)"AL_FILTER_HIGHPASS", AL_FILTER_HIGHPASS },
{ (ALchar *)"AL_FILTER_BANDPASS", AL_FILTER_BANDPASS },
+ // Filter params
+ { (ALchar *)"AL_LOWPASS_GAIN", AL_LOWPASS_GAIN },
+ { (ALchar *)"AL_LOWPASS_GAINHF", AL_LOWPASS_GAINHF },
+
// Effect types
{ (ALchar *)"AL_EFFECT_TYPE", AL_EFFECT_TYPE },
{ (ALchar *)"AL_EFFECT_NULL", AL_EFFECT_NULL },
diff --git a/OpenAL32/alFilter.c b/OpenAL32/alFilter.c
index 0167462f..719ccc0a 100644
--- a/OpenAL32/alFilter.c
+++ b/OpenAL32/alFilter.c
@@ -160,8 +160,18 @@ AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue)
if (alIsFilter(filter))
{
+ ALfilter *ALFilter = (ALfilter*)ALTHUNK_LOOKUPENTRY(filter);
+
switch(param)
{
+ case AL_FILTER_TYPE:
+ if(iValue == AL_FILTER_NULL ||
+ iValue == AL_FILTER_LOWPASS)
+ InitFilterParams(ALFilter, iValue);
+ else
+ alSetError(AL_INVALID_VALUE);
+ break;
+
default:
alSetError(AL_INVALID_ENUM);
break;
@@ -186,6 +196,10 @@ AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, ALint *piValue
{
switch(param)
{
+ case AL_FILTER_TYPE:
+ alFilteri(filter, param, piValues[0]);
+ break;
+
default:
alSetError(AL_INVALID_ENUM);
break;
@@ -208,8 +222,30 @@ AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue
if (alIsFilter(filter))
{
+ ALfilter *ALFilter = (ALfilter*)ALTHUNK_LOOKUPENTRY(filter);
+
switch(param)
{
+ case AL_LOWPASS_GAIN:
+ if(ALFilter->type == AL_FILTER_LOWPASS)
+ {
+ if(flValue >= 0.0f && flValue <= 1.0f)
+ ALFilter->Gain = flValue;
+ }
+ else
+ alSetError(AL_INVALID_ENUM);
+ break;
+
+ case AL_LOWPASS_GAINHF:
+ if(ALFilter->type == AL_FILTER_LOWPASS)
+ {
+ if(flValue >= 0.0f && flValue <= 1.0f)
+ ALFilter->GainHF = flValue;
+ }
+ else
+ alSetError(AL_INVALID_ENUM);
+ break;
+
default:
alSetError(AL_INVALID_ENUM);
break;
@@ -234,6 +270,11 @@ AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, ALfloat *pflVa
{
switch(param)
{
+ case AL_LOWPASS_GAIN:
+ case AL_LOWPASS_GAINHF:
+ alFilterf(filter, param, pflValues[0]);
+ break;
+
default:
alSetError(AL_INVALID_ENUM);
break;
@@ -304,8 +345,24 @@ AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pfl
if (alIsFilter(filter))
{
+ ALfilter *ALFilter = (ALfilter*)ALTHUNK_LOOKUPENTRY(filter);
+
switch(param)
{
+ case AL_LOWPASS_GAIN:
+ if(ALFilter->type == AL_FILTER_LOWPASS)
+ *pflValue = ALFilter->Gain;
+ else
+ alSetError(AL_INVALID_ENUM);
+ break;
+
+ case AL_LOWPASS_GAINHF:
+ if(ALFilter->type == AL_FILTER_LOWPASS)
+ *pflValue = ALFilter->GainHF;
+ else
+ alSetError(AL_INVALID_ENUM);
+ break;
+
default:
alSetError(AL_INVALID_ENUM);
break;
@@ -330,6 +387,11 @@ AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pf
{
switch(param)
{
+ case AL_LOWPASS_GAIN:
+ case AL_LOWPASS_GAINHF:
+ alGetFilterf(filter, param, pflValues);
+ break;
+
default:
alSetError(AL_INVALID_ENUM);
break;
@@ -365,4 +427,7 @@ ALvoid ReleaseALFilters(ALvoid)
static void InitFilterParams(ALfilter *filter, ALenum type)
{
filter->type = type;
+
+ filter->Gain = 1.0;
+ filter->GainHF = 1.0;
}