diff options
-rw-r--r-- | Alc/ALu.c | 92 | ||||
-rw-r--r-- | Alc/alcReverb.c | 12 | ||||
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 6 | ||||
-rw-r--r-- | config.h.in | 3 |
5 files changed, 61 insertions, 53 deletions
@@ -644,9 +644,9 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource) case AL_EXPONENT_DISTANCE: if(Distance > 0.0f && MinDist > 0.0f) { - flAttenuation = (ALfloat)pow(Distance/MinDist, -Rolloff); + flAttenuation = aluPow(Distance/MinDist, -Rolloff); for(i = 0;i < NumSends;i++) - RoomAttenuation[i] = (ALfloat)pow(Distance/MinDist, -RoomRolloff[i]); + RoomAttenuation[i] = aluPow(Distance/MinDist, -RoomRolloff[i]); } break; @@ -672,7 +672,7 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource) absorb = (ALSource->AirAbsorptionFactor*AIRABSORBGAINDBHF) * effectiveDist; // Convert dB to linear gain before applying - absorb = pow(10.0, absorb/20.0); + absorb = aluPow(10.0f, absorb/20.0f); DryGainHF *= absorb; } @@ -722,62 +722,60 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource) { ALeffectslot *Slot = ALSource->Send[i].Slot; - if(Slot && Slot->effect.type != AL_EFFECT_NULL) + if(!Slot || Slot->effect.type == AL_EFFECT_NULL) { - if(Slot->AuxSendAuto) - { - if(ALSource->WetGainAuto) - WetGain[i] *= ConeVolume; - if(ALSource->WetGainHFAuto) - WetGainHF[i] *= ConeHF; + ALSource->Params.WetGains[i] = 0.0f; + WetGainHF[i] = 1.0f; + continue; + } - // Clamp to Min/Max Gain - WetGain[i] = __min(WetGain[i],MaxVolume); - WetGain[i] = __max(WetGain[i],MinVolume); + if(Slot->AuxSendAuto) + { + if(ALSource->WetGainAuto) + WetGain[i] *= ConeVolume; + if(ALSource->WetGainHFAuto) + WetGainHF[i] *= ConeHF; - if(Slot->effect.type == AL_EFFECT_REVERB || - Slot->effect.type == AL_EFFECT_EAXREVERB) - { - /* Apply a decay-time transformation to the wet path, - * based on the attenuation of the dry path. - * - * Using the approximate (effective) source to listener - * distance, the initial decay of the reverb effect is - * calculated and applied to the wet path. - */ - WetGain[i] *= pow(10.0, effectiveDist / + // Clamp to Min/Max Gain + WetGain[i] = __min(WetGain[i],MaxVolume); + WetGain[i] = __max(WetGain[i],MinVolume); + + if(Slot->effect.type == AL_EFFECT_REVERB || + Slot->effect.type == AL_EFFECT_EAXREVERB) + { + /* Apply a decay-time transformation to the wet path, based on + * the attenuation of the dry path. + * + * Using the approximate (effective) source to listener + * distance, the initial decay of the reverb effect is + * calculated and applied to the wet path. + */ + WetGain[i] *= aluPow(10.0f, effectiveDist / (SPEEDOFSOUNDMETRESPERSEC * Slot->effect.Reverb.DecayTime) * -60.0 / 20.0); - WetGainHF[i] *= pow(10.0, - log10(Slot->effect.Reverb.AirAbsorptionGainHF) * - ALSource->AirAbsorptionFactor * effectiveDist); - } + WetGainHF[i] *= aluPow(10.0f, + log10(Slot->effect.Reverb.AirAbsorptionGainHF) * + ALSource->AirAbsorptionFactor * effectiveDist); } - else - { - // If the slot's auxiliary send auto is off, the data sent to - // the effect slot is the same as the dry path, sans filter - // effects - WetGain[i] = DryMix; - WetGainHF[i] = DryGainHF; - } - - switch(ALSource->Send[i].WetFilter.type) - { - case AL_FILTER_LOWPASS: - WetGain[i] *= ALSource->Send[i].WetFilter.Gain; - WetGainHF[i] *= ALSource->Send[i].WetFilter.GainHF; - break; - } - ALSource->Params.WetGains[i] = WetGain[i] * ListenerGain; } else { - ALSource->Params.WetGains[i] = 0.0f; - WetGainHF[i] = 1.0f; + /* If the slot's auxiliary send auto is off, the data sent to the + * effect slot is the same as the dry path, sans filter effects */ + WetGain[i] = DryMix; + WetGainHF[i] = DryGainHF; } + + switch(ALSource->Send[i].WetFilter.type) + { + case AL_FILTER_LOWPASS: + WetGain[i] *= ALSource->Send[i].WetFilter.Gain; + WetGainHF[i] *= ALSource->Send[i].WetFilter.GainHF; + break; + } + ALSource->Params.WetGains[i] = WetGain[i] * ListenerGain; } for(i = NumSends;i < MAX_SENDS;i++) { diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c index 3d6e2734..318a8401 100644 --- a/Alc/alcReverb.c +++ b/Alc/alcReverb.c @@ -311,7 +311,7 @@ static ALboolean AllocLines(ALboolean eaxFlag, ALuint frequency, ALverbState *St // until the decay reaches -60 dB. static __inline ALfloat CalcDecayCoeff(ALfloat length, ALfloat decayTime) { - return pow(10.0f, length / decayTime * -60.0f / 20.0f); + return aluPow(10.0f, length / decayTime * -60.0f / 20.0f); } // Calculate a decay length from a coefficient and the time until the decay @@ -488,7 +488,7 @@ static ALvoid UpdateDecorrelator(ALfloat density, ALuint frequency, ALverbState */ for(index = 0;index < 3;index++) { - length = (DECO_FRACTION * pow(DECO_MULTIPLIER, (ALfloat)index)) * + length = (DECO_FRACTION * aluPow(DECO_MULTIPLIER, (ALfloat)index)) * LATE_LINE_LENGTH[0] * (1.0f + (density * LATE_LINE_MULTIPLIER)); State->DecoTap[index] = (ALuint)(length * frequency); } @@ -522,7 +522,7 @@ static ALvoid UpdateLateLines(ALfloat reverbGain, ALfloat lateGain, ALfloat xMix decayTime)); // Calculate the all-pass feed-back and feed-forward coefficient. - State->Late.ApFeedCoeff = 0.5f * pow(diffusion, 2.0f); + State->Late.ApFeedCoeff = 0.5f * aluPow(diffusion, 2.0f); for(index = 0;index < 4;index++) { @@ -566,7 +566,7 @@ static ALvoid UpdateEchoLine(ALfloat reverbGain, ALfloat lateGain, ALfloat echoT State->Echo.DensityGain = CalcDensityGain(State->Echo.Coeff); // Calculate the echo all-pass feed coefficient. - State->Echo.ApFeedCoeff = 0.5f * pow(diffusion, 2.0f); + State->Echo.ApFeedCoeff = 0.5f * aluPow(diffusion, 2.0f); // Calculate the echo all-pass attenuation coefficient. State->Echo.ApCoeff = CalcDecayCoeff(ECHO_ALLPASS_LENGTH, decayTime); @@ -1022,8 +1022,8 @@ static ALboolean EAXVerbDeviceUpdate(ALeffectState *effect, ALCdevice *Device) // is calculated given the current sample rate. This ensures that the // resulting filter response over time is consistent across all sample // rates. - State->Mod.Coeff = pow(MODULATION_FILTER_COEFF, MODULATION_FILTER_CONST / - frequency); + State->Mod.Coeff = aluPow(MODULATION_FILTER_COEFF, + MODULATION_FILTER_CONST / frequency); // The early reflection and late all-pass filter line lengths are static, // so their offsets only need to be calculated once. diff --git a/CMakeLists.txt b/CMakeLists.txt index aaeaef1b..35681fd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,6 +143,7 @@ CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(pri CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H) CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H) +CHECK_LIBRARY_EXISTS(m powf "" HAVE_POWF) CHECK_LIBRARY_EXISTS(m sqrtf "" HAVE_SQRTF) CHECK_LIBRARY_EXISTS(m acosf "" HAVE_ACOSF) CHECK_LIBRARY_EXISTS(m atanf "" HAVE_ATANF) diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index eedf10d9..a4e0930c 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -15,6 +15,12 @@ #define M_PI_2 1.57079632679489661923 /* pi/2 */ #endif +#ifdef HAVE_POWF +#define aluPow(x,y) ((ALfloat)powf((float)(x),(float)(y))) +#else +#define aluPow(x,y) ((ALfloat)pow((double)(x),(double)(y))) +#endif + #ifdef HAVE_SQRTF #define aluSqrt(x) ((ALfloat)sqrtf((float)(x))) #else diff --git a/config.h.in b/config.h.in index 168b403a..1d7c8cce 100644 --- a/config.h.in +++ b/config.h.in @@ -31,6 +31,9 @@ /* Define if we have the stat function */ #cmakedefine HAVE_STAT +/* Define if we have the powf function */ +#cmakedefine HAVE_POWF + /* Define if we have the sqrtf function */ #cmakedefine HAVE_SQRTF |