diff options
-rw-r--r-- | Alc/ALu.c | 14 | ||||
-rw-r--r-- | Alc/alcEcho.c | 2 | ||||
-rw-r--r-- | Alc/alcModulator.c | 16 | ||||
-rw-r--r-- | Alc/alcReverb.c | 8 | ||||
-rw-r--r-- | Alc/panning.c | 8 | ||||
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 12 | ||||
-rw-r--r-- | config.h.in | 6 |
8 files changed, 45 insertions, 25 deletions
@@ -211,8 +211,8 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) DryGain *= aluSqrt(2.0f/4.0f); for(c = 0;c < 2;c++) { - pos = aluCart2LUTpos(cos(angles_Rear[c] * (M_PI/180.0)), - sin(angles_Rear[c] * (M_PI/180.0))); + pos = aluCart2LUTpos(aluCos((ALfloat)M_PI/180.0f * angles_Rear[c]), + aluSin((ALfloat)M_PI/180.0f * angles_Rear[c])); SpeakerGain = Device->PanningLUT[pos]; for(i = 0;i < (ALint)Device->NumChan;i++) @@ -284,7 +284,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) /* Get the static HRIR coefficients and delays for this * channel. */ GetLerpedHrtfCoeffs(ALContext->Device->Hrtf, - 0.0, angles[c] * (M_PI/180.0), + 0.0f, (ALfloat)M_PI/180.0f * angles[c], DryGain*ListenerGain, ALSource->Params.HrtfCoeffs[c], ALSource->Params.HrtfDelay[c]); @@ -301,8 +301,8 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) SrcMatrix[c][LFE] += DryGain * ListenerGain; continue; } - pos = aluCart2LUTpos(cos(angles[c] * (M_PI/180.0)), - sin(angles[c] * (M_PI/180.0))); + pos = aluCart2LUTpos(aluCos((ALfloat)M_PI/180.0f * angles[c]), + aluSin((ALfloat)M_PI/180.0f * angles[c])); SpeakerGain = Device->PanningLUT[pos]; for(i = 0;i < (ALint)Device->NumChan;i++) @@ -321,7 +321,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) /* Update filter coefficients. Calculations based on the I3DL2 * spec. */ - cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / Frequency); + cw = aluCos((ALfloat)M_PI*2.0f * LOWPASSFREQCUTOFF / Frequency); /* We use two chained one-pole filters, so we need to take the * square root of the squared gain, which is the same as the base @@ -790,7 +790,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) ALSource->Params.Send[i].WetGain = WetGain[i]; /* Update filter coefficients. */ - cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / Frequency); + cw = aluCos((ALfloat)M_PI*2.0f * LOWPASSFREQCUTOFF / Frequency); ALSource->Params.iirFilter.coeff = lpCoeffCalc(DryGainHF, cw); for(i = 0;i < NumSends;i++) diff --git a/Alc/alcEcho.c b/Alc/alcEcho.c index 76249d87..8caeb7ca 100644 --- a/Alc/alcEcho.c +++ b/Alc/alcEcho.c @@ -111,7 +111,7 @@ static ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, const ALeff state->FeedGain = Slot->effect.Echo.Feedback; - cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / frequency); + cw = aluCos((ALfloat)M_PI*2.0f * LOWPASSFREQCUTOFF / frequency); g = 1.0f - Slot->effect.Echo.Damping; state->iirFilter.coeff = lpCoeffCalc(g, cw); diff --git a/Alc/alcModulator.c b/Alc/alcModulator.c index 1a2ffd64..e6f94737 100644 --- a/Alc/alcModulator.c +++ b/Alc/alcModulator.c @@ -52,19 +52,19 @@ typedef struct ALmodulatorState { #define WAVEFORM_FRACBITS 16 #define WAVEFORM_FRACMASK ((1<<WAVEFORM_FRACBITS)-1) -static __inline ALdouble Sin(ALuint index) +static __inline ALfloat Sin(ALuint index) { - return sin(index * (M_PI*2.0 / (1<<WAVEFORM_FRACBITS))); + return aluSin(index * ((ALfloat)M_PI*2.0f / (1<<WAVEFORM_FRACBITS))); } -static __inline ALdouble Saw(ALuint index) +static __inline ALfloat Saw(ALuint index) { - return index*(2.0/(1<<WAVEFORM_FRACBITS)) - 1.0; + return index*(2.0f/(1<<WAVEFORM_FRACBITS)) - 1.0f; } -static __inline ALdouble Square(ALuint index) +static __inline ALfloat Square(ALuint index) { - return (index&(1<<(WAVEFORM_FRACBITS-1))) ? -1.0 : 1.0; + return (index&(1<<(WAVEFORM_FRACBITS-1))) ? -1.0f : 1.0f; } @@ -151,8 +151,8 @@ static ALvoid ModulatorUpdate(ALeffectState *effect, ALCcontext *Context, const if(!state->step) state->step = 1; - cw = cos(2.0*M_PI * Slot->effect.Modulator.HighPassCutoff / - Device->Frequency); + cw = aluCos((ALfloat)M_PI*2.0f * Slot->effect.Modulator.HighPassCutoff / + Device->Frequency); a = (2.0f-cw) - aluSqrt(aluPow(2.0f-cw, 2.0f) - 1.0f); state->iirFilter.coeff = a; diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c index 425b7052..0555db64 100644 --- a/Alc/alcReverb.c +++ b/Alc/alcReverb.c @@ -237,7 +237,7 @@ static __inline ALfloat EAXModulation(ALverbState *State, ALfloat in) // Calculate the sinus rythm (dependent on modulation time and the // sampling rate). The center of the sinus is moved to reduce the delay // of the effect when the time or depth are low. - sinus = 1.0f - cos(2.0f * M_PI * State->Mod.Index / State->Mod.Range); + sinus = 1.0f - aluCos((ALfloat)M_PI*2.0f * State->Mod.Index / State->Mod.Range); // The depth determines the range over which to read the input samples // from, so it must be filtered to reduce the distortion caused by even @@ -764,7 +764,7 @@ static __inline ALfloat CalcDecayLength(ALfloat coeff, ALfloat decayTime) // calculation. static __inline ALfloat CalcI3DL2HFreq(ALfloat hfRef, ALuint frequency) { - return cos(2.0f * M_PI * hfRef / frequency); + return aluCos((ALfloat)M_PI*2.0f * hfRef / frequency); } // Calculate an attenuation to be applied to the input of any echo models to @@ -797,9 +797,9 @@ static __inline ALvoid CalcMatrixCoeffs(ALfloat diffusion, ALfloat *x, ALfloat * t = diffusion * atan(n); // Calculate the first mixing matrix coefficient. - *x = cos(t); + *x = aluCos(t); // Calculate the second mixing matrix coefficient. - *y = sin(t) / n; + *y = aluSin(t) / n; } // Calculate the limited HF ratio for use with the late reverb low-pass diff --git a/Alc/panning.c b/Alc/panning.c index 983d3ef6..f600284d 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -295,8 +295,8 @@ ALvoid aluInitPanning(ALCdevice *Device) /* source between speaker s and speaker s+1 */ Alpha = M_PI_2 * (Theta-SpeakerAngle[s]) / (SpeakerAngle[s+1]-SpeakerAngle[s]); - PanningLUT[Speaker2Chan[s]] = cos(Alpha); - PanningLUT[Speaker2Chan[s+1]] = sin(Alpha); + PanningLUT[Speaker2Chan[s]] = aluCos(Alpha); + PanningLUT[Speaker2Chan[s+1]] = aluSin(Alpha); break; } } @@ -307,8 +307,8 @@ ALvoid aluInitPanning(ALCdevice *Device) Theta += 2.0f * M_PI; Alpha = M_PI_2 * (Theta-SpeakerAngle[s]) / (2.0f * M_PI + SpeakerAngle[0]-SpeakerAngle[s]); - PanningLUT[Speaker2Chan[s]] = cos(Alpha); - PanningLUT[Speaker2Chan[0]] = sin(Alpha); + PanningLUT[Speaker2Chan[s]] = aluCos(Alpha); + PanningLUT[Speaker2Chan[0]] = aluSin(Alpha); } } } diff --git a/CMakeLists.txt b/CMakeLists.txt index 5552152c..21e9189d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,13 +225,15 @@ CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H) CHECK_LIBRARY_EXISTS(m powf "" HAVE_POWF) CHECK_LIBRARY_EXISTS(m sqrtf "" HAVE_SQRTF) +CHECK_LIBRARY_EXISTS(m cosf "" HAVE_COSF) +CHECK_LIBRARY_EXISTS(m sinf "" HAVE_SINF) CHECK_LIBRARY_EXISTS(m acosf "" HAVE_ACOSF) CHECK_LIBRARY_EXISTS(m atanf "" HAVE_ATANF) CHECK_LIBRARY_EXISTS(m fabsf "" HAVE_FABSF) IF(HAVE_FENV_H) CHECK_LIBRARY_EXISTS(m fesetround "" HAVE_FESETROUND) ENDIF() -IF(HAVE_SQRTF OR HAVE_ACOSF OR HAVE_ATANF OR HAVE_FABSF OR HAVE_FESETROUND) +IF(HAVE_SQRTF OR HAVE_COSF OR HAVE_SINF OR HAVE_ACOSF OR HAVE_ATANF OR HAVE_FABSF OR HAVE_FESETROUND) SET(EXTRA_LIBS m ${EXTRA_LIBS}) ENDIF() CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF) diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 216c2e14..5a222b47 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -31,6 +31,18 @@ #define aluSqrt(x) ((ALfloat)sqrt((double)(x))) #endif +#ifdef HAVE_COSF +#define aluCos(x) (cosf((x))) +#else +#define aluCos(x) ((ALfloat)cos((double)(x))) +#endif + +#ifdef HAVE_SINF +#define aluSin(x) (sinf((x))) +#else +#define aluSin(x) ((ALfloat)sin((double)(x))) +#endif + #ifdef HAVE_ACOSF #define aluAcos(x) (acosf((x))) #else diff --git a/config.h.in b/config.h.in index f680295d..b6c945a5 100644 --- a/config.h.in +++ b/config.h.in @@ -53,6 +53,12 @@ /* Define if we have the sqrtf function */ #cmakedefine HAVE_SQRTF +/* Define if we have the cosf function */ +#cmakedefine HAVE_COSF + +/* Define if we have the sinf function */ +#cmakedefine HAVE_SINF + /* Define if we have the acosf function */ #cmakedefine HAVE_ACOSF |