diff options
author | Chris Robinson <[email protected]> | 2011-09-22 01:00:44 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-09-22 01:00:44 -0700 |
commit | a4b1239f45daa29bb423077da60804d7bf9287eb (patch) | |
tree | 0a9f7025fe1d298f5de58fde0836af9541c3ed01 /Alc | |
parent | 43350f9066f0c28ac8ff6269783db222508dec45 (diff) |
Use cosf and sinf when available
Also clear away a few more MSVC precision warnings
Diffstat (limited to 'Alc')
-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 |
5 files changed, 24 insertions, 24 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); } } } |