From a4b1239f45daa29bb423077da60804d7bf9287eb Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 22 Sep 2011 01:00:44 -0700 Subject: Use cosf and sinf when available Also clear away a few more MSVC precision warnings --- Alc/ALu.c | 14 +++++++------- Alc/alcEcho.c | 2 +- Alc/alcModulator.c | 16 ++++++++-------- Alc/alcReverb.c | 8 ++++---- Alc/panning.c | 8 ++++---- 5 files changed, 24 insertions(+), 24 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index 670df970..a3e121e0 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -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<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); } } } -- cgit v1.2.3