diff options
-rw-r--r-- | Alc/ALu.c | 4 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 1 | ||||
-rw-r--r-- | OpenAL32/Include/alSource.h | 2 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 14 |
4 files changed, 21 insertions, 0 deletions
@@ -378,6 +378,10 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, break; } + if(ALSource->AirAbsorptionFactor > 0.0f) + DryGainHF *= pow(ALSource->AirAbsorptionFactor * AIRABSORBGAINHF, + Distance * MetersPerUnit); + *drygainhf = DryGainHF; *wetgainhf = WetGainHF; diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 8ffda560..5a221065 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -98,6 +98,7 @@ extern char szDebug[256]; //#define OUTPUT_BUFFER_SIZE (32768*SWMIXER_OUTPUT_RATE/22050) #define SPEEDOFSOUNDMETRESPERSEC (343.3f) +#define AIRABSORBGAINHF (0.994f) typedef struct { ALCboolean (*OpenPlayback)(ALCdevice*, const ALCchar*); diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index 4493c006..38b0094d 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -68,6 +68,8 @@ typedef struct ALsource_struct ALboolean DryGainHFAuto; ALfloat OuterGainHF; + ALfloat AirAbsorptionFactor; + // Index to itself ALuint source; diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 1e30b1db..65bfcb22 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -348,6 +348,13 @@ ALAPI ALvoid ALAPIENTRY alSourcef(ALuint source, ALenum eParam, ALfloat flValue) alSetError(AL_INVALID_VALUE); break; + case AL_AIR_ABSORPTION_FACTOR: + if (flValue >= 0.0f && flValue <= 10.0f) + pSource->AirAbsorptionFactor = flValue; + else + alSetError(AL_INVALID_VALUE); + break; + case AL_SEC_OFFSET: case AL_SAMPLE_OFFSET: case AL_BYTE_OFFSET: @@ -472,6 +479,7 @@ ALAPI ALvoid ALAPIENTRY alSourcefv(ALuint source, ALenum eParam, const ALfloat * case AL_SEC_OFFSET: case AL_SAMPLE_OFFSET: case AL_BYTE_OFFSET: + case AL_AIR_ABSORPTION_FACTOR: alSourcef(source, eParam, pflValues[0]); break; @@ -850,6 +858,10 @@ ALAPI ALvoid ALAPIENTRY alGetSourcef(ALuint source, ALenum eParam, ALfloat *pflV *pflValue = pSource->flRefDistance; break; + case AL_AIR_ABSORPTION_FACTOR: + *pflValue = pSource->AirAbsorptionFactor; + break; + default: alSetError(AL_INVALID_ENUM); break; @@ -958,6 +970,7 @@ ALAPI ALvoid ALAPIENTRY alGetSourcefv(ALuint source, ALenum eParam, ALfloat *pfl case AL_CONE_OUTER_ANGLE: case AL_REFERENCE_DISTANCE: case AL_CONE_OUTER_GAINHF: + case AL_AIR_ABSORPTION_FACTOR: alGetSourcef(source, eParam, pflValues); break; @@ -1879,6 +1892,7 @@ static ALvoid InitSourceParams(ALsource *pSource) pSource->flOuterGain = 0.0f; pSource->DryGainHFAuto = AL_TRUE; + pSource->AirAbsorptionFactor = 0.0f; pSource->state = AL_INITIAL; pSource->lSourceType = AL_UNDETERMINED; |