Use a helper macro for pi*2
This commit is contained in:
parent
11365b42c7
commit
a421e515be
@ -111,7 +111,7 @@ static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo,
|
||||
if((state->lfo++) % 30 == 0)
|
||||
{
|
||||
/* Using custom low-pass filter coefficients, to handle the resonance and peak-gain properties. */
|
||||
frequency = (1.0f + cosf(state->lfo * (1.0f / lerp(1.0f, 4.0f, state->AttackTime * state->ReleaseTime)) * 2.0f * F_PI / state->Frequency)) / OCTAVE;
|
||||
frequency = (1.0f + cosf(state->lfo * (1.0f / lerp(1.0f, 4.0f, state->AttackTime * state->ReleaseTime)) * F_2PI / state->Frequency)) / OCTAVE;
|
||||
frequency = expf((frequency - 1.0f) * 6.0f);
|
||||
|
||||
/* computing cutoff frequency and peak gain */
|
||||
|
@ -122,7 +122,7 @@ static ALvoid ALchorusState_update(ALchorusState *state, ALCdevice *Device, cons
|
||||
if(rate == 0.0f)
|
||||
state->lfo_coeff = 0.0f;
|
||||
else
|
||||
state->lfo_coeff = F_PI*2.0f / (frequency / rate);
|
||||
state->lfo_coeff = F_2PI / (frequency / rate);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -152,12 +152,11 @@ static inline void Sinusoid(ALint *delay_left, ALint *delay_right, ALint offset,
|
||||
{
|
||||
ALfloat lfo_value;
|
||||
|
||||
lfo_value = 1.0f + sinf(fmodf(state->lfo_coeff*offset, 2.0f*F_PI));
|
||||
lfo_value = 1.0f + sinf(fmodf(state->lfo_coeff*offset, F_2PI));
|
||||
lfo_value *= state->depth * state->delay;
|
||||
*delay_left = fastf2i(lfo_value) + state->delay;
|
||||
|
||||
lfo_value = 1.0f + sinf(fmodf(state->lfo_coeff*(offset+state->lfo_disp),
|
||||
2.0f*F_PI));
|
||||
lfo_value = 1.0f + sinf(fmodf(state->lfo_coeff*(offset+state->lfo_disp), F_2PI));
|
||||
lfo_value *= state->depth * state->delay;
|
||||
*delay_right = fastf2i(lfo_value) + state->delay;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, ALCdevice *Devi
|
||||
state->attenuation = Slot->EffectProps.Distortion.Gain;
|
||||
|
||||
/* Store waveshaper edge settings */
|
||||
edge = sinf(Slot->EffectProps.Distortion.Edge * (F_PI/2.0f));
|
||||
edge = sinf(Slot->EffectProps.Distortion.Edge * (F_PI_2));
|
||||
edge = minf(edge, 0.99f);
|
||||
state->edge_coeff = 2.0f * edge / (1.0f-edge);
|
||||
|
||||
|
@ -122,7 +122,7 @@ static ALvoid ALflangerState_update(ALflangerState *state, ALCdevice *Device, co
|
||||
if(rate == 0.0f)
|
||||
state->lfo_coeff = 0.0f;
|
||||
else
|
||||
state->lfo_coeff = F_PI * 2.0f / (frequency / rate);
|
||||
state->lfo_coeff = F_2PI / (frequency / rate);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -152,12 +152,11 @@ static inline void Sinusoid(ALint *delay_left, ALint *delay_right, ALint offset,
|
||||
{
|
||||
ALfloat lfo_value;
|
||||
|
||||
lfo_value = 1.0f + sinf(fmodf(state->lfo_coeff * offset, 2.0f*F_PI));
|
||||
lfo_value = 1.0f + sinf(fmodf(state->lfo_coeff * offset, F_2PI));
|
||||
lfo_value *= state->depth * state->delay;
|
||||
*delay_left = fastf2i(lfo_value) + state->delay;
|
||||
|
||||
lfo_value = 1.0f + sinf(fmodf(state->lfo_coeff * (offset+state->lfo_disp),
|
||||
2.0f*F_PI));
|
||||
lfo_value = 1.0f + sinf(fmodf(state->lfo_coeff * (offset+state->lfo_disp), F_2PI));
|
||||
lfo_value *= state->depth * state->delay;
|
||||
*delay_right = fastf2i(lfo_value) + state->delay;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ typedef struct ALmodulatorState {
|
||||
|
||||
static inline ALfloat Sin(ALuint index)
|
||||
{
|
||||
return sinf(index * (F_PI*2.0f / WAVEFORM_FRACONE) - F_PI)*0.5f + 0.5f;
|
||||
return sinf(index*(F_2PI/WAVEFORM_FRACONE) - F_PI)*0.5f + 0.5f;
|
||||
}
|
||||
|
||||
static inline ALfloat Saw(ALuint index)
|
||||
@ -139,8 +139,7 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, ALCdevice *Device
|
||||
if(state->step == 0) state->step = 1;
|
||||
|
||||
/* Custom filter coeffs, which match the old version instead of a low-shelf. */
|
||||
cw = cosf(F_PI*2.0f * Slot->EffectProps.Modulator.HighPassCutoff /
|
||||
Device->Frequency);
|
||||
cw = cosf(F_2PI * Slot->EffectProps.Modulator.HighPassCutoff / Device->Frequency);
|
||||
a = (2.0f-cw) - sqrtf(powf(2.0f-cw, 2.0f) - 1.0f);
|
||||
|
||||
state->Filter.b[0] = a;
|
||||
|
@ -266,7 +266,7 @@ static inline ALfloat EAXModulation(ALreverbState *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 - cosf(F_PI*2.0f * State->Mod.Index / State->Mod.Range);
|
||||
sinus = 1.0f - cosf(F_2PI * 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
|
||||
@ -1137,7 +1137,7 @@ static ALvoid ALreverbState_update(ALreverbState *State, ALCdevice *Device, cons
|
||||
Slot->EffectProps.Reverb.AirAbsorptionGainHF,
|
||||
Slot->EffectProps.Reverb.DecayTime);
|
||||
|
||||
cw = cosf(F_PI*2.0f * hfscale);
|
||||
cw = cosf(F_2PI * hfscale);
|
||||
// Update the late lines.
|
||||
UpdateLateLines(Slot->EffectProps.Reverb.Gain, Slot->EffectProps.Reverb.LateReverbGain,
|
||||
x, Slot->EffectProps.Reverb.Density, Slot->EffectProps.Reverb.DecayTime,
|
||||
|
@ -92,7 +92,7 @@ static void CalcEvIndices(const struct Hrtf *Hrtf, ALfloat ev, ALuint *evidx, AL
|
||||
*/
|
||||
static void CalcAzIndices(const struct Hrtf *Hrtf, ALuint evidx, ALfloat az, ALuint *azidx, ALfloat *azmu)
|
||||
{
|
||||
az = (F_PI*2.0f + az) * Hrtf->azCount[evidx] / (F_PI*2.0f);
|
||||
az = (F_2PI + az) * Hrtf->azCount[evidx] / (F_2PI);
|
||||
azidx[0] = fastf2u(az) % Hrtf->azCount[evidx];
|
||||
azidx[1] = (azidx[0] + 1) % Hrtf->azCount[evidx];
|
||||
*azmu = az - floorf(az);
|
||||
|
@ -186,9 +186,9 @@ void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth, A
|
||||
}
|
||||
/* Sound is between last and first speakers */
|
||||
if(angle < SpeakerAngle[0])
|
||||
angle += F_PI*2.0f;
|
||||
a = (angle-SpeakerAngle[i]) /
|
||||
(F_PI*2.0f + SpeakerAngle[0]-SpeakerAngle[i]);
|
||||
angle += F_2PI;
|
||||
a = (angle-SpeakerAngle[i]) /
|
||||
(F_2PI + SpeakerAngle[0]-SpeakerAngle[i]);
|
||||
gains[Speaker2Chan[i]] = sqrtf(1.0f-a) * ingain;
|
||||
gains[Speaker2Chan[0]] = sqrtf( a) * ingain;
|
||||
return;
|
||||
@ -213,7 +213,7 @@ void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth, A
|
||||
}
|
||||
for(i = 0;done < device->NumChan;i++)
|
||||
{
|
||||
SpeakerAngle[done] = device->SpeakerAngle[i]-angle + F_PI*2.0f;
|
||||
SpeakerAngle[done] = device->SpeakerAngle[i]-angle + F_2PI;
|
||||
Speaker2Chan[done] = device->Speaker2Chan[i];
|
||||
done++;
|
||||
}
|
||||
@ -236,7 +236,7 @@ void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth, A
|
||||
}
|
||||
for(i = device->NumChan-1;done < device->NumChan;i--)
|
||||
{
|
||||
SpeakerAngle[done] = device->SpeakerAngle[i]-angle - F_PI*2.0f;
|
||||
SpeakerAngle[done] = device->SpeakerAngle[i]-angle - F_2PI;
|
||||
Speaker2Chan[done] = device->Speaker2Chan[i];
|
||||
done--;
|
||||
}
|
||||
@ -266,14 +266,14 @@ void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth, A
|
||||
}
|
||||
if(SpeakerAngle[i] > rangle)
|
||||
{
|
||||
a = (F_PI*2.0f + rangle-SpeakerAngle[last]) /
|
||||
(F_PI*2.0f + SpeakerAngle[i]-SpeakerAngle[last]);
|
||||
a = (F_2PI + rangle-SpeakerAngle[last]) /
|
||||
(F_2PI + SpeakerAngle[i]-SpeakerAngle[last]);
|
||||
tmpgains[chan] = lerp(tmpgains[chan], 1.0f, a);
|
||||
}
|
||||
else if(SpeakerAngle[last] < rangle)
|
||||
{
|
||||
a = (rangle-SpeakerAngle[last]) /
|
||||
(F_PI*2.0f + SpeakerAngle[i]-SpeakerAngle[last]);
|
||||
a = (rangle-SpeakerAngle[last]) /
|
||||
(F_2PI + SpeakerAngle[i]-SpeakerAngle[last]);
|
||||
tmpgains[chan] = lerp(tmpgains[chan], 1.0f, a);
|
||||
}
|
||||
} while(0);
|
||||
@ -318,14 +318,14 @@ void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth, A
|
||||
}
|
||||
if(SpeakerAngle[i] < langle)
|
||||
{
|
||||
a = (langle-SpeakerAngle[i]) /
|
||||
(F_PI*2.0f + SpeakerAngle[0]-SpeakerAngle[i]);
|
||||
a = (langle-SpeakerAngle[i]) /
|
||||
(F_2PI + SpeakerAngle[0]-SpeakerAngle[i]);
|
||||
tmpgains[chan] = lerp(tmpgains[chan], 1.0f, 1.0f-a);
|
||||
}
|
||||
else if(SpeakerAngle[0] > langle)
|
||||
{
|
||||
a = (F_PI*2.0f + langle-SpeakerAngle[i]) /
|
||||
(F_PI*2.0f + SpeakerAngle[0]-SpeakerAngle[i]);
|
||||
a = (F_2PI + langle-SpeakerAngle[i]) /
|
||||
(F_2PI + SpeakerAngle[0]-SpeakerAngle[i]);
|
||||
tmpgains[chan] = lerp(tmpgains[chan], 1.0f, 1.0f-a);
|
||||
}
|
||||
} while(0);
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#define F_PI (3.14159265358979323846f)
|
||||
#define F_PI_2 (1.57079632679489661923f)
|
||||
#define F_2PI (6.28318530717958647692f)
|
||||
|
||||
#ifndef FLT_EPSILON
|
||||
#define FLT_EPSILON (1.19209290e-07f)
|
||||
|
@ -339,7 +339,7 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g
|
||||
// Limit gain to -100dB
|
||||
gain = maxf(gain, 0.00001f);
|
||||
|
||||
w0 = 2.0f*F_PI * freq_scale;
|
||||
w0 = F_2PI * freq_scale;
|
||||
|
||||
/* Calculate filter coefficients depending on filter type */
|
||||
switch(type)
|
||||
|
Loading…
x
Reference in New Issue
Block a user