diff options
-rw-r--r-- | Alc/ALu.c | 11 | ||||
-rw-r--r-- | OpenAL32/Include/alFilter.h | 7 | ||||
-rw-r--r-- | OpenAL32/alExtension.c | 4 | ||||
-rw-r--r-- | OpenAL32/alFilter.c | 65 |
4 files changed, 86 insertions, 1 deletions
@@ -369,10 +369,19 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, PanningFB = 0.5f; } + //7. Apply filter gains and filters + switch(ALSource->DirectFilter.filter) + { + case AL_FILTER_LOWPASS: + DryMix *= ALSource->DirectFilter.Gain; + DryGainHF *= ALSource->DirectFilter.GainHF; + break; + } + *drygainhf = DryGainHF; *wetgainhf = WetGainHF; - //7. Convert pannings into channel volumes + //8. Convert pannings into channel volumes switch(OutputFormat) { case AL_FORMAT_MONO8: 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; } |