Look for and use atan2f, log10f, and floorf

This commit is contained in:
Chris Robinson
2011-09-24 12:17:39 -07:00
parent 2b0a63003f
commit cf56b0733b
6 changed files with 43 additions and 13 deletions
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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
+3 -3
View File
@@ -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
+11 -8
View File
@@ -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)
+18
View File
@@ -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)
+9
View File
@@ -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