aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-03-07 22:12:33 -0800
committerChris Robinson <[email protected]>2010-03-07 22:12:33 -0800
commit1f10195c47f9747dcd262879c84e614ae3d33cab (patch)
tree994bc40bb7d499d36b475ed680cc4891bde37188 /Alc
parentdc40702b53dbc1599fd7bea7c83104fddd336f10 (diff)
Use powf when available
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALu.c92
-rw-r--r--Alc/alcReverb.c12
2 files changed, 51 insertions, 53 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 884c4a8a..1981333c 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -644,9 +644,9 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource)
case AL_EXPONENT_DISTANCE:
if(Distance > 0.0f && MinDist > 0.0f)
{
- flAttenuation = (ALfloat)pow(Distance/MinDist, -Rolloff);
+ flAttenuation = aluPow(Distance/MinDist, -Rolloff);
for(i = 0;i < NumSends;i++)
- RoomAttenuation[i] = (ALfloat)pow(Distance/MinDist, -RoomRolloff[i]);
+ RoomAttenuation[i] = aluPow(Distance/MinDist, -RoomRolloff[i]);
}
break;
@@ -672,7 +672,7 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource)
absorb = (ALSource->AirAbsorptionFactor*AIRABSORBGAINDBHF) *
effectiveDist;
// Convert dB to linear gain before applying
- absorb = pow(10.0, absorb/20.0);
+ absorb = aluPow(10.0f, absorb/20.0f);
DryGainHF *= absorb;
}
@@ -722,62 +722,60 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource)
{
ALeffectslot *Slot = ALSource->Send[i].Slot;
- if(Slot && Slot->effect.type != AL_EFFECT_NULL)
+ if(!Slot || Slot->effect.type == AL_EFFECT_NULL)
{
- if(Slot->AuxSendAuto)
- {
- if(ALSource->WetGainAuto)
- WetGain[i] *= ConeVolume;
- if(ALSource->WetGainHFAuto)
- WetGainHF[i] *= ConeHF;
+ ALSource->Params.WetGains[i] = 0.0f;
+ WetGainHF[i] = 1.0f;
+ continue;
+ }
- // Clamp to Min/Max Gain
- WetGain[i] = __min(WetGain[i],MaxVolume);
- WetGain[i] = __max(WetGain[i],MinVolume);
+ if(Slot->AuxSendAuto)
+ {
+ if(ALSource->WetGainAuto)
+ WetGain[i] *= ConeVolume;
+ if(ALSource->WetGainHFAuto)
+ WetGainHF[i] *= ConeHF;
- if(Slot->effect.type == AL_EFFECT_REVERB ||
- Slot->effect.type == AL_EFFECT_EAXREVERB)
- {
- /* Apply a decay-time transformation to the wet path,
- * based on the attenuation of the dry path.
- *
- * Using the approximate (effective) source to listener
- * distance, the initial decay of the reverb effect is
- * calculated and applied to the wet path.
- */
- WetGain[i] *= pow(10.0, effectiveDist /
+ // Clamp to Min/Max Gain
+ WetGain[i] = __min(WetGain[i],MaxVolume);
+ WetGain[i] = __max(WetGain[i],MinVolume);
+
+ if(Slot->effect.type == AL_EFFECT_REVERB ||
+ Slot->effect.type == AL_EFFECT_EAXREVERB)
+ {
+ /* Apply a decay-time transformation to the wet path, based on
+ * the attenuation of the dry path.
+ *
+ * Using the approximate (effective) source to listener
+ * distance, the initial decay of the reverb effect is
+ * calculated and applied to the wet path.
+ */
+ WetGain[i] *= aluPow(10.0f, effectiveDist /
(SPEEDOFSOUNDMETRESPERSEC *
Slot->effect.Reverb.DecayTime) *
-60.0 / 20.0);
- WetGainHF[i] *= pow(10.0,
- log10(Slot->effect.Reverb.AirAbsorptionGainHF) *
- ALSource->AirAbsorptionFactor * effectiveDist);
- }
+ WetGainHF[i] *= aluPow(10.0f,
+ log10(Slot->effect.Reverb.AirAbsorptionGainHF) *
+ ALSource->AirAbsorptionFactor * effectiveDist);
}
- else
- {
- // If the slot's auxiliary send auto is off, the data sent to
- // the effect slot is the same as the dry path, sans filter
- // effects
- WetGain[i] = DryMix;
- WetGainHF[i] = DryGainHF;
- }
-
- switch(ALSource->Send[i].WetFilter.type)
- {
- case AL_FILTER_LOWPASS:
- WetGain[i] *= ALSource->Send[i].WetFilter.Gain;
- WetGainHF[i] *= ALSource->Send[i].WetFilter.GainHF;
- break;
- }
- ALSource->Params.WetGains[i] = WetGain[i] * ListenerGain;
}
else
{
- ALSource->Params.WetGains[i] = 0.0f;
- WetGainHF[i] = 1.0f;
+ /* If the slot's auxiliary send auto is off, the data sent to the
+ * effect slot is the same as the dry path, sans filter effects */
+ WetGain[i] = DryMix;
+ WetGainHF[i] = DryGainHF;
}
+
+ switch(ALSource->Send[i].WetFilter.type)
+ {
+ case AL_FILTER_LOWPASS:
+ WetGain[i] *= ALSource->Send[i].WetFilter.Gain;
+ WetGainHF[i] *= ALSource->Send[i].WetFilter.GainHF;
+ break;
+ }
+ ALSource->Params.WetGains[i] = WetGain[i] * ListenerGain;
}
for(i = NumSends;i < MAX_SENDS;i++)
{
diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c
index 3d6e2734..318a8401 100644
--- a/Alc/alcReverb.c
+++ b/Alc/alcReverb.c
@@ -311,7 +311,7 @@ static ALboolean AllocLines(ALboolean eaxFlag, ALuint frequency, ALverbState *St
// until the decay reaches -60 dB.
static __inline ALfloat CalcDecayCoeff(ALfloat length, ALfloat decayTime)
{
- return pow(10.0f, length / decayTime * -60.0f / 20.0f);
+ return aluPow(10.0f, length / decayTime * -60.0f / 20.0f);
}
// Calculate a decay length from a coefficient and the time until the decay
@@ -488,7 +488,7 @@ static ALvoid UpdateDecorrelator(ALfloat density, ALuint frequency, ALverbState
*/
for(index = 0;index < 3;index++)
{
- length = (DECO_FRACTION * pow(DECO_MULTIPLIER, (ALfloat)index)) *
+ length = (DECO_FRACTION * aluPow(DECO_MULTIPLIER, (ALfloat)index)) *
LATE_LINE_LENGTH[0] * (1.0f + (density * LATE_LINE_MULTIPLIER));
State->DecoTap[index] = (ALuint)(length * frequency);
}
@@ -522,7 +522,7 @@ static ALvoid UpdateLateLines(ALfloat reverbGain, ALfloat lateGain, ALfloat xMix
decayTime));
// Calculate the all-pass feed-back and feed-forward coefficient.
- State->Late.ApFeedCoeff = 0.5f * pow(diffusion, 2.0f);
+ State->Late.ApFeedCoeff = 0.5f * aluPow(diffusion, 2.0f);
for(index = 0;index < 4;index++)
{
@@ -566,7 +566,7 @@ static ALvoid UpdateEchoLine(ALfloat reverbGain, ALfloat lateGain, ALfloat echoT
State->Echo.DensityGain = CalcDensityGain(State->Echo.Coeff);
// Calculate the echo all-pass feed coefficient.
- State->Echo.ApFeedCoeff = 0.5f * pow(diffusion, 2.0f);
+ State->Echo.ApFeedCoeff = 0.5f * aluPow(diffusion, 2.0f);
// Calculate the echo all-pass attenuation coefficient.
State->Echo.ApCoeff = CalcDecayCoeff(ECHO_ALLPASS_LENGTH, decayTime);
@@ -1022,8 +1022,8 @@ static ALboolean EAXVerbDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
// is calculated given the current sample rate. This ensures that the
// resulting filter response over time is consistent across all sample
// rates.
- State->Mod.Coeff = pow(MODULATION_FILTER_COEFF, MODULATION_FILTER_CONST /
- frequency);
+ State->Mod.Coeff = aluPow(MODULATION_FILTER_COEFF,
+ MODULATION_FILTER_CONST / frequency);
// The early reflection and late all-pass filter line lengths are static,
// so their offsets only need to be calculated once.