From cf56b0733b86019631c4b877ece6bcceb3b2b50a Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 24 Sep 2011 12:17:39 -0700 Subject: Look for and use atan2f, log10f, and floorf --- Alc/ALu.c | 2 +- Alc/alcReverb.c | 2 +- Alc/hrtf.c | 6 +++--- CMakeLists.txt | 19 +++++++++++-------- OpenAL32/Include/alu.h | 18 ++++++++++++++++++ config.h.in | 9 +++++++++ 6 files changed, 43 insertions(+), 13 deletions(-) diff --git a/Alc/ALu.c b/Alc/ALu.c index 0697e943..c02b0fdc 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -717,7 +717,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) // the listener. This prevents +0 and -0 Z from producing // inconsistent panning. ev = aluAsin(Position[1]); - az = atan2(Position[0], -Position[2]*ZScale); + az = aluAtan2(Position[0], -Position[2]*ZScale); } // Check to see if the HRIR is already moving. diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c index 80439669..92a82a51 100644 --- a/Alc/alcReverb.c +++ b/Alc/alcReverb.c @@ -757,7 +757,7 @@ static __inline ALfloat CalcDecayCoeff(ALfloat length, ALfloat decayTime) // reaches -60 dB. static __inline ALfloat CalcDecayLength(ALfloat coeff, ALfloat decayTime) { - return log10(coeff) * decayTime / -3.0f/*log10(0.001)*/; + return aluLog10(coeff) * decayTime / aluLog10(0.001)/*-60 dB*/; } // Calculate the high frequency parameter for the I3DL2 coefficient diff --git a/Alc/hrtf.c b/Alc/hrtf.c index 9decb545..d8d65097 100644 --- a/Alc/hrtf.c +++ b/Alc/hrtf.c @@ -85,7 +85,7 @@ static void CalcAzIndices(ALuint evidx, ALfloat az, ALuint *azidx, ALfloat *azmu az = (F_PI*2.0f + az) * azCount[evidx] / (F_PI*2.0f); azidx[0] = (ALuint)az % azCount[evidx]; azidx[1] = (azidx[0] + 1) % azCount[evidx]; - *azmu = az - floor(az); + *azmu = az - aluFloor(az); } // Calculates the normalized HRTF transition factor (delta) from the changes @@ -99,7 +99,7 @@ ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3], // Calculate the normalized dB gain change. newGain = maxf(newGain, 0.0001f); oldGain = maxf(oldGain, 0.0001f); - gainChange = aluFabs(log10(newGain / oldGain) / log10(0.0001f)); + gainChange = aluFabs(aluLog10(newGain / oldGain) / aluLog10(0.0001f)); // Calculate the normalized listener to source angle change when there is // enough gain to notice it. @@ -231,7 +231,7 @@ ALuint GetMovingHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat a ridx[3] = evOffset[evidx[1]] + ((azCount[evidx[1]]-azidx[1]) % azCount[evidx[1]]); // Calculate the stepping parameters. - delta = maxf(floor(delta*(Hrtf->sampleRate*0.015f) + 0.5f), 1.0f); + delta = maxf(aluFloor(delta*(Hrtf->sampleRate*0.015f) + 0.5f), 1.0f); step = 1.0f / delta; // Calculate the normalized and attenuated target HRIR coefficients using diff --git a/CMakeLists.txt b/CMakeLists.txt index 89762164..4f4902bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,14 +231,17 @@ IF(HAVE_LIBM) ENDIF() -CHECK_SYMBOL_EXISTS(powf math.h HAVE_POWF) -CHECK_SYMBOL_EXISTS(sqrtf math.h HAVE_SQRTF) -CHECK_SYMBOL_EXISTS(cosf math.h HAVE_COSF) -CHECK_SYMBOL_EXISTS(sinf math.h HAVE_SINF) -CHECK_SYMBOL_EXISTS(acosf math.h HAVE_ACOSF) -CHECK_SYMBOL_EXISTS(asinf math.h HAVE_ASINF) -CHECK_SYMBOL_EXISTS(atanf math.h HAVE_ATANF) -CHECK_SYMBOL_EXISTS(fabsf math.h HAVE_FABSF) +CHECK_SYMBOL_EXISTS(powf math.h HAVE_POWF) +CHECK_SYMBOL_EXISTS(sqrtf math.h HAVE_SQRTF) +CHECK_SYMBOL_EXISTS(cosf math.h HAVE_COSF) +CHECK_SYMBOL_EXISTS(sinf math.h HAVE_SINF) +CHECK_SYMBOL_EXISTS(acosf math.h HAVE_ACOSF) +CHECK_SYMBOL_EXISTS(asinf math.h HAVE_ASINF) +CHECK_SYMBOL_EXISTS(atanf math.h HAVE_ATANF) +CHECK_SYMBOL_EXISTS(atan2f math.h HAVE_ATAN2F) +CHECK_SYMBOL_EXISTS(fabsf math.h HAVE_FABSF) +CHECK_SYMBOL_EXISTS(log10f math.h HAVE_LOG10F) +CHECK_SYMBOL_EXISTS(floorf math.h HAVE_FLOORF) IF(HAVE_FENV_H) CHECK_SYMBOL_EXISTS(fesetround fenv.h HAVE_FESETROUND) diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index b6924908..e8ac64fd 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -64,12 +64,30 @@ #define aluAtan(x) ((ALfloat)atan((double)(x))) #endif +#ifdef HAVE_ATAN2F +#define aluAtan2(x,y) (atan2f((x),(y))) +#else +#define aluAtan2(x,y) ((ALfloat)atan2((double)(x),(double)(y))) +#endif + #ifdef HAVE_FABSF #define aluFabs(x) (fabsf((x))) #else #define aluFabs(x) ((ALfloat)fabs((double)(x))) #endif +#ifdef HAVE_LOG10F +#define aluLog10(x) (log10f((x))) +#else +#define aluLog10(x) ((ALfloat)log10((double)(x))) +#endif + +#ifdef HAVE_FLOORF +#define aluFloor(x) (floorf((x))) +#else +#define aluFloor(x) ((ALfloat)floor((double)(x))) +#endif + #define QUADRANT_NUM 128 #define LUT_NUM (4 * QUADRANT_NUM) diff --git a/config.h.in b/config.h.in index 645e4208..3cafe8d2 100644 --- a/config.h.in +++ b/config.h.in @@ -68,9 +68,18 @@ /* Define if we have the atanf function */ #cmakedefine HAVE_ATANF +/* Define if we have the atan2f function */ +#cmakedefine HAVE_ATAN2F + /* Define if we have the fabsf function */ #cmakedefine HAVE_FABSF +/* Define if we have the log10f function */ +#cmakedefine HAVE_LOG10F + +/* Define if we have the floorf function */ +#cmakedefine HAVE_FLOORF + /* Define if we have the strtof function */ #cmakedefine HAVE_STRTOF -- cgit v1.2.3