aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALu.c16
-rw-r--r--Alc/alcEcho.c2
-rw-r--r--Alc/alcModulator.c6
-rw-r--r--Alc/alcReverb.c4
-rw-r--r--Alc/hrtf.c6
-rw-r--r--Alc/panning.c78
-rw-r--r--OpenAL32/Include/alu.h3
7 files changed, 59 insertions, 56 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index a3e121e0..364c6093 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(aluCos((ALfloat)M_PI/180.0f * angles_Rear[c]),
- aluSin((ALfloat)M_PI/180.0f * angles_Rear[c]));
+ pos = aluCart2LUTpos(aluCos(F_PI/180.0f * angles_Rear[c]),
+ aluSin(F_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.0f, (ALfloat)M_PI/180.0f * angles[c],
+ 0.0f, F_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(aluCos((ALfloat)M_PI/180.0f * angles[c]),
- aluSin((ALfloat)M_PI/180.0f * angles[c]));
+ pos = aluCart2LUTpos(aluCos(F_PI/180.0f * angles[c]),
+ aluSin(F_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 = aluCos((ALfloat)M_PI*2.0f * LOWPASSFREQCUTOFF / Frequency);
+ cw = aluCos(F_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
@@ -573,7 +573,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
}
//3. Apply directional soundcones
- Angle = aluAcos(aluDotproduct(Direction,SourceToListener)) * (180.0/M_PI);
+ Angle = aluAcos(aluDotproduct(Direction,SourceToListener)) * (180.0f/F_PI);
if(Angle >= InnerAngle && Angle <= OuterAngle)
{
ALfloat scale = (Angle-InnerAngle) / (OuterAngle-InnerAngle);
@@ -790,7 +790,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
ALSource->Params.Send[i].WetGain = WetGain[i];
/* Update filter coefficients. */
- cw = aluCos((ALfloat)M_PI*2.0f * LOWPASSFREQCUTOFF / Frequency);
+ cw = aluCos(F_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 8caeb7ca..c77e185e 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 = aluCos((ALfloat)M_PI*2.0f * LOWPASSFREQCUTOFF / frequency);
+ cw = aluCos(F_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 e6f94737..4c1bd2f7 100644
--- a/Alc/alcModulator.c
+++ b/Alc/alcModulator.c
@@ -54,7 +54,7 @@ typedef struct ALmodulatorState {
static __inline ALfloat Sin(ALuint index)
{
- return aluSin(index * ((ALfloat)M_PI*2.0f / (1<<WAVEFORM_FRACBITS)));
+ return aluSin(index * (F_PI*2.0f / (1<<WAVEFORM_FRACBITS)));
}
static __inline ALfloat Saw(ALuint index)
@@ -151,8 +151,8 @@ static ALvoid ModulatorUpdate(ALeffectState *effect, ALCcontext *Context, const
if(!state->step)
state->step = 1;
- cw = aluCos((ALfloat)M_PI*2.0f * Slot->effect.Modulator.HighPassCutoff /
- Device->Frequency);
+ cw = aluCos(F_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 0555db64..49bb26ce 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 - aluCos((ALfloat)M_PI*2.0f * State->Mod.Index / State->Mod.Range);
+ sinus = 1.0f - aluCos(F_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 aluCos((ALfloat)M_PI*2.0f * hfRef / frequency);
+ return aluCos(F_PI*2.0f * hfRef / frequency);
}
// Calculate an attenuation to be applied to the input of any echo models to
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index 5da5bed3..cad6f9f1 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -71,7 +71,7 @@ static ALuint NumLoadedHrtfs = 0;
// interpolation factor between 0.0 and 1.0.
static void CalcEvIndices(ALfloat ev, ALuint *evidx, ALfloat *evmu)
{
- ev = (M_PI/2.0f + ev) * (ELEV_COUNT-1) / M_PI;
+ ev = (F_PI_2 + ev) * (ELEV_COUNT-1) / F_PI;
evidx[0] = (ALuint)ev;
evidx[1] = minu(evidx[0] + 1, ELEV_COUNT-1);
*evmu = ev - evidx[0];
@@ -82,7 +82,7 @@ static void CalcEvIndices(ALfloat ev, ALuint *evidx, ALfloat *evmu)
// interpolation factor between 0.0 and 1.0.
static void CalcAzIndices(ALuint evidx, ALfloat az, ALuint *azidx, ALfloat *azmu)
{
- az = (M_PI*2.0f + az) * azCount[evidx] / (M_PI*2.0f);
+ 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);
@@ -111,7 +111,7 @@ ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3],
if(newdir[0]-olddir[0] || newdir[1]-olddir[1] || newdir[2]-olddir[2])
angleChange = aluAcos(olddir[0]*newdir[0] +
olddir[1]*newdir[1] +
- olddir[2]*newdir[2]) / M_PI;
+ olddir[2]*newdir[2]) / F_PI;
}
diff --git a/Alc/panning.c b/Alc/panning.c
index 6d340e1e..b125fed8 100644
--- a/Alc/panning.c
+++ b/Alc/panning.c
@@ -102,7 +102,7 @@ static void SetSpeakerArrangement(const char *name, ALfloat SpeakerAngle[MAXCHAN
{
long angle = strtol(sep, NULL, 10);
if(angle >= -180 && angle <= 180)
- SpeakerAngle[i] = angle * M_PI/180.0f;
+ SpeakerAngle[i] = angle * F_PI/180.0f;
else
ERR("Invalid angle for speaker \"%s\": %ld\n", confkey, angle);
break;
@@ -144,10 +144,10 @@ static ALfloat aluLUTpos2Angle(ALint pos)
if(pos < QUADRANT_NUM)
return aluAtan((ALfloat)pos / (ALfloat)(QUADRANT_NUM - pos));
if(pos < 2 * QUADRANT_NUM)
- return (ALfloat)M_PI_2 + aluAtan((ALfloat)(pos - QUADRANT_NUM) / (ALfloat)(2 * QUADRANT_NUM - pos));
+ return F_PI_2 + aluAtan((ALfloat)(pos - QUADRANT_NUM) / (ALfloat)(2 * QUADRANT_NUM - pos));
if(pos < 3 * QUADRANT_NUM)
- return aluAtan((ALfloat)(pos - 2 * QUADRANT_NUM) / (ALfloat)(3 * QUADRANT_NUM - pos)) - (ALfloat)M_PI;
- return aluAtan((ALfloat)(pos - 3 * QUADRANT_NUM) / (ALfloat)(4 * QUADRANT_NUM - pos)) - (ALfloat)M_PI_2;
+ return aluAtan((ALfloat)(pos - 2 * QUADRANT_NUM) / (ALfloat)(3 * QUADRANT_NUM - pos)) - F_PI;
+ return aluAtan((ALfloat)(pos - 3 * QUADRANT_NUM) / (ALfloat)(4 * QUADRANT_NUM - pos)) - F_PI_2;
}
ALint aluCart2LUTpos(ALfloat re, ALfloat im)
@@ -178,15 +178,15 @@ ALvoid aluInitPanning(ALCdevice *Device)
case DevFmtMono:
Device->NumChan = 1;
Speaker2Chan[0] = FRONT_CENTER;
- SpeakerAngle[0] = (ALfloat)M_PI/180.0f * 0.0f;
+ SpeakerAngle[0] = F_PI/180.0f * 0.0f;
break;
case DevFmtStereo:
Device->NumChan = 2;
Speaker2Chan[0] = FRONT_LEFT;
Speaker2Chan[1] = FRONT_RIGHT;
- SpeakerAngle[0] = (ALfloat)M_PI/180.0f * -90.0f;
- SpeakerAngle[1] = (ALfloat)M_PI/180.0f * 90.0f;
+ SpeakerAngle[0] = F_PI/180.0f * -90.0f;
+ SpeakerAngle[1] = F_PI/180.0f * 90.0f;
SetSpeakerArrangement("layout_STEREO", SpeakerAngle, Speaker2Chan, Device->NumChan);
break;
@@ -196,10 +196,10 @@ ALvoid aluInitPanning(ALCdevice *Device)
Speaker2Chan[1] = FRONT_LEFT;
Speaker2Chan[2] = FRONT_RIGHT;
Speaker2Chan[3] = BACK_RIGHT;
- SpeakerAngle[0] = (ALfloat)M_PI/180.0f * -135.0f;
- SpeakerAngle[1] = (ALfloat)M_PI/180.0f * -45.0f;
- SpeakerAngle[2] = (ALfloat)M_PI/180.0f * 45.0f;
- SpeakerAngle[3] = (ALfloat)M_PI/180.0f * 135.0f;
+ SpeakerAngle[0] = F_PI/180.0f * -135.0f;
+ SpeakerAngle[1] = F_PI/180.0f * -45.0f;
+ SpeakerAngle[2] = F_PI/180.0f * 45.0f;
+ SpeakerAngle[3] = F_PI/180.0f * 135.0f;
SetSpeakerArrangement("layout_QUAD", SpeakerAngle, Speaker2Chan, Device->NumChan);
break;
@@ -210,11 +210,11 @@ ALvoid aluInitPanning(ALCdevice *Device)
Speaker2Chan[2] = FRONT_CENTER;
Speaker2Chan[3] = FRONT_RIGHT;
Speaker2Chan[4] = BACK_RIGHT;
- SpeakerAngle[0] = (ALfloat)M_PI/180.0f * -110.0f;
- SpeakerAngle[1] = (ALfloat)M_PI/180.0f * -30.0f;
- SpeakerAngle[2] = (ALfloat)M_PI/180.0f * 0.0f;
- SpeakerAngle[3] = (ALfloat)M_PI/180.0f * 30.0f;
- SpeakerAngle[4] = (ALfloat)M_PI/180.0f * 110.0f;
+ SpeakerAngle[0] = F_PI/180.0f * -110.0f;
+ SpeakerAngle[1] = F_PI/180.0f * -30.0f;
+ SpeakerAngle[2] = F_PI/180.0f * 0.0f;
+ SpeakerAngle[3] = F_PI/180.0f * 30.0f;
+ SpeakerAngle[4] = F_PI/180.0f * 110.0f;
SetSpeakerArrangement("layout_51CHN", SpeakerAngle, Speaker2Chan, Device->NumChan);
break;
@@ -225,11 +225,11 @@ ALvoid aluInitPanning(ALCdevice *Device)
Speaker2Chan[2] = FRONT_CENTER;
Speaker2Chan[3] = FRONT_RIGHT;
Speaker2Chan[4] = SIDE_RIGHT;
- SpeakerAngle[0] = (ALfloat)M_PI/180.0f * -90.0f;
- SpeakerAngle[1] = (ALfloat)M_PI/180.0f * -30.0f;
- SpeakerAngle[2] = (ALfloat)M_PI/180.0f * 0.0f;
- SpeakerAngle[3] = (ALfloat)M_PI/180.0f * 30.0f;
- SpeakerAngle[4] = (ALfloat)M_PI/180.0f * 90.0f;
+ SpeakerAngle[0] = F_PI/180.0f * -90.0f;
+ SpeakerAngle[1] = F_PI/180.0f * -30.0f;
+ SpeakerAngle[2] = F_PI/180.0f * 0.0f;
+ SpeakerAngle[3] = F_PI/180.0f * 30.0f;
+ SpeakerAngle[4] = F_PI/180.0f * 90.0f;
SetSpeakerArrangement("layout_51SIDECHN", SpeakerAngle, Speaker2Chan, Device->NumChan);
break;
@@ -241,12 +241,12 @@ ALvoid aluInitPanning(ALCdevice *Device)
Speaker2Chan[3] = FRONT_RIGHT;
Speaker2Chan[4] = SIDE_RIGHT;
Speaker2Chan[5] = BACK_CENTER;
- SpeakerAngle[0] = (ALfloat)M_PI/180.0f * -90.0f;
- SpeakerAngle[1] = (ALfloat)M_PI/180.0f * -30.0f;
- SpeakerAngle[2] = (ALfloat)M_PI/180.0f * 0.0f;
- SpeakerAngle[3] = (ALfloat)M_PI/180.0f * 30.0f;
- SpeakerAngle[4] = (ALfloat)M_PI/180.0f * 90.0f;
- SpeakerAngle[5] = (ALfloat)M_PI/180.0f * 180.0f;
+ SpeakerAngle[0] = F_PI/180.0f * -90.0f;
+ SpeakerAngle[1] = F_PI/180.0f * -30.0f;
+ SpeakerAngle[2] = F_PI/180.0f * 0.0f;
+ SpeakerAngle[3] = F_PI/180.0f * 30.0f;
+ SpeakerAngle[4] = F_PI/180.0f * 90.0f;
+ SpeakerAngle[5] = F_PI/180.0f * 180.0f;
SetSpeakerArrangement("layout_61CHN", SpeakerAngle, Speaker2Chan, Device->NumChan);
break;
@@ -259,13 +259,13 @@ ALvoid aluInitPanning(ALCdevice *Device)
Speaker2Chan[4] = FRONT_RIGHT;
Speaker2Chan[5] = SIDE_RIGHT;
Speaker2Chan[6] = BACK_RIGHT;
- SpeakerAngle[0] = (ALfloat)M_PI/180.0f * -150.0f;
- SpeakerAngle[1] = (ALfloat)M_PI/180.0f * -90.0f;
- SpeakerAngle[2] = (ALfloat)M_PI/180.0f * -30.0f;
- SpeakerAngle[3] = (ALfloat)M_PI/180.0f * 0.0f;
- SpeakerAngle[4] = (ALfloat)M_PI/180.0f * 30.0f;
- SpeakerAngle[5] = (ALfloat)M_PI/180.0f * 90.0f;
- SpeakerAngle[6] = (ALfloat)M_PI/180.0f * 150.0f;
+ SpeakerAngle[0] = F_PI/180.0f * -150.0f;
+ SpeakerAngle[1] = F_PI/180.0f * -90.0f;
+ SpeakerAngle[2] = F_PI/180.0f * -30.0f;
+ SpeakerAngle[3] = F_PI/180.0f * 0.0f;
+ SpeakerAngle[4] = F_PI/180.0f * 30.0f;
+ SpeakerAngle[5] = F_PI/180.0f * 90.0f;
+ SpeakerAngle[6] = F_PI/180.0f * 150.0f;
SetSpeakerArrangement("layout_71CHN", SpeakerAngle, Speaker2Chan, Device->NumChan);
break;
}
@@ -293,8 +293,8 @@ ALvoid aluInitPanning(ALCdevice *Device)
if(Theta >= SpeakerAngle[s] && Theta < SpeakerAngle[s+1])
{
/* source between speaker s and speaker s+1 */
- Alpha = (ALfloat)M_PI_2 * (Theta-SpeakerAngle[s]) /
- (SpeakerAngle[s+1]-SpeakerAngle[s]);
+ Alpha = F_PI_2 * (Theta-SpeakerAngle[s]) /
+ (SpeakerAngle[s+1]-SpeakerAngle[s]);
PanningLUT[Speaker2Chan[s]] = aluCos(Alpha);
PanningLUT[Speaker2Chan[s+1]] = aluSin(Alpha);
break;
@@ -304,9 +304,9 @@ ALvoid aluInitPanning(ALCdevice *Device)
{
/* source between last and first speaker */
if(Theta < SpeakerAngle[0])
- Theta += (ALfloat)M_PI*2.0f;
- Alpha = (ALfloat)M_PI_2 * (Theta-SpeakerAngle[s]) /
- ((ALfloat)M_PI*2.0f + SpeakerAngle[0]-SpeakerAngle[s]);
+ Theta += F_PI*2.0f;
+ Alpha = F_PI_2 * (Theta-SpeakerAngle[s]) /
+ (F_PI*2.0f + SpeakerAngle[0]-SpeakerAngle[s]);
PanningLUT[Speaker2Chan[s]] = aluCos(Alpha);
PanningLUT[Speaker2Chan[0]] = aluSin(Alpha);
}
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 5a222b47..2c20837b 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -19,6 +19,9 @@
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#endif
+#define F_PI ((float)M_PI)
+#define F_PI_2 ((float)M_PI_2)
+
#ifdef HAVE_POWF
#define aluPow(x,y) (powf((x),(y)))
#else