diff options
author | Chris Robinson <[email protected]> | 2013-10-08 16:31:23 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2013-10-08 16:31:23 -0700 |
commit | a421e515befd1916d57e7668ee98c1a5dfe63dab (patch) | |
tree | 68d69e41030ccfec34ac89175edec66e99b7660b | |
parent | 11365b42c7fedaef61d7123c390c429260eae52f (diff) |
Use a helper macro for pi*2
-rw-r--r-- | Alc/effects/autowah.c | 2 | ||||
-rw-r--r-- | Alc/effects/chorus.c | 7 | ||||
-rw-r--r-- | Alc/effects/distortion.c | 2 | ||||
-rw-r--r-- | Alc/effects/flanger.c | 7 | ||||
-rw-r--r-- | Alc/effects/modulator.c | 5 | ||||
-rw-r--r-- | Alc/effects/reverb.c | 4 | ||||
-rw-r--r-- | Alc/hrtf.c | 2 | ||||
-rw-r--r-- | Alc/panning.c | 26 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 1 | ||||
-rw-r--r-- | OpenAL32/alFilter.c | 2 |
10 files changed, 28 insertions, 30 deletions
diff --git a/Alc/effects/autowah.c b/Alc/effects/autowah.c index 9a3f8b94..29ec02af 100644 --- a/Alc/effects/autowah.c +++ b/Alc/effects/autowah.c @@ -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 */ diff --git a/Alc/effects/chorus.c b/Alc/effects/chorus.c index 9e74f8c8..4dbfc93d 100644 --- a/Alc/effects/chorus.c +++ b/Alc/effects/chorus.c @@ -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; } diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.c index 7402f0af..e39a8197 100644 --- a/Alc/effects/distortion.c +++ b/Alc/effects/distortion.c @@ -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); diff --git a/Alc/effects/flanger.c b/Alc/effects/flanger.c index d3cdd250..78be5e42 100644 --- a/Alc/effects/flanger.c +++ b/Alc/effects/flanger.c @@ -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; } diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c index 4fdd1261..17ca7e17 100644 --- a/Alc/effects/modulator.c +++ b/Alc/effects/modulator.c @@ -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; diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c index 77bf4a16..75ec76e3 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -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); diff --git a/Alc/panning.c b/Alc/panning.c index 10615570..80041696 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -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); diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index d27301b3..55b8edd1 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -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) diff --git a/OpenAL32/alFilter.c b/OpenAL32/alFilter.c index 026a5814..899ff5f0 100644 --- a/OpenAL32/alFilter.c +++ b/OpenAL32/alFilter.c @@ -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) |