diff options
author | Chris Robinson <[email protected]> | 2019-01-06 04:16:51 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-01-06 04:16:51 -0800 |
commit | da3a916042a7ba9426af1d6f03e689dbd7760191 (patch) | |
tree | ab6cfc0d2fd26504a013989af7ecd399a4034914 /Alc/effects | |
parent | 98f3e6a16295029129193a073680a70c034703dd (diff) |
Replace macros with constexpr inline functions
Diffstat (limited to 'Alc/effects')
-rw-r--r-- | Alc/effects/autowah.cpp | 2 | ||||
-rw-r--r-- | Alc/effects/chorus.cpp | 6 | ||||
-rw-r--r-- | Alc/effects/distortion.cpp | 3 | ||||
-rw-r--r-- | Alc/effects/echo.cpp | 4 | ||||
-rw-r--r-- | Alc/effects/fshifter.cpp | 8 | ||||
-rw-r--r-- | Alc/effects/modulator.cpp | 2 | ||||
-rw-r--r-- | Alc/effects/pshifter.cpp | 8 | ||||
-rw-r--r-- | Alc/effects/reverb.cpp | 12 |
8 files changed, 23 insertions, 22 deletions
diff --git a/Alc/effects/autowah.cpp b/Alc/effects/autowah.cpp index b116cc0f..7df5d49e 100644 --- a/Alc/effects/autowah.cpp +++ b/Alc/effects/autowah.cpp @@ -150,7 +150,7 @@ void ALautowahState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Sampl env_delay = lerp(sample, env_delay, a); /* Calculate the cos and alpha components for this sample's filter. */ - w0 = minf((bandwidth*env_delay + freq_min), 0.46f) * F_TAU; + w0 = minf((bandwidth*env_delay + freq_min), 0.46f) * al::MathDefs<float>::Tau(); mEnv[i].cos_w0 = cosf(w0); mEnv[i].alpha = sinf(w0)/(2.0f * Q_FACTOR); } diff --git a/Alc/effects/chorus.cpp b/Alc/effects/chorus.cpp index 1a89a015..1132a33a 100644 --- a/Alc/effects/chorus.cpp +++ b/Alc/effects/chorus.cpp @@ -147,8 +147,8 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co /* Gains for left and right sides */ ALfloat coeffs[2][MAX_AMBI_COEFFS]; - CalcAngleCoeffs(-F_PI_2, 0.0f, 0.0f, coeffs[0]); - CalcAngleCoeffs( F_PI_2, 0.0f, 0.0f, coeffs[1]); + CalcAngleCoeffs(al::MathDefs<float>::Pi()*-0.5f, 0.0f, 0.0f, coeffs[0]); + CalcAngleCoeffs(al::MathDefs<float>::Pi()* 0.5f, 0.0f, 0.0f, coeffs[1]); mOutBuffer = target.Main->Buffer; mOutChannels = target.Main->NumChannels; @@ -178,7 +178,7 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co mLfoScale = 4.0f / mLfoRange; break; case WaveForm::Sinusoid: - mLfoScale = F_TAU / mLfoRange; + mLfoScale = al::MathDefs<float>::Tau() / mLfoRange; break; } diff --git a/Alc/effects/distortion.cpp b/Alc/effects/distortion.cpp index e54ae455..1b9c66fa 100644 --- a/Alc/effects/distortion.cpp +++ b/Alc/effects/distortion.cpp @@ -65,7 +65,8 @@ void ALdistortionState::update(const ALCcontext *context, const ALeffectslot *sl const ALCdevice *device{context->Device}; /* Store waveshaper edge settings. */ - const ALfloat edge{minf(std::sin(props->Distortion.Edge * F_PI_2), 0.99f)}; + const ALfloat edge{ + minf(std::sin(al::MathDefs<float>::Pi()*0.5f * props->Distortion.Edge), 0.99f)}; mEdgeCoeff = 2.0f * edge / (1.0f-edge); ALfloat cutoff{props->Distortion.LowpassCutoff}; diff --git a/Alc/effects/echo.cpp b/Alc/effects/echo.cpp index b774052a..697d2e88 100644 --- a/Alc/effects/echo.cpp +++ b/Alc/effects/echo.cpp @@ -116,8 +116,8 @@ void ALechoState::update(const ALCcontext *context, const ALeffectslot *slot, co ); ALfloat coeffs[2][MAX_AMBI_COEFFS]; - CalcAngleCoeffs(-F_PI_2*lrpan, 0.0f, spread, coeffs[0]); - CalcAngleCoeffs( F_PI_2*lrpan, 0.0f, spread, coeffs[1]); + CalcAngleCoeffs(al::MathDefs<float>::Pi()*-0.5f*lrpan, 0.0f, spread, coeffs[0]); + CalcAngleCoeffs(al::MathDefs<float>::Pi()* 0.5f*lrpan, 0.0f, spread, coeffs[1]); mOutBuffer = target.Main->Buffer; mOutChannels = target.Main->NumChannels; diff --git a/Alc/effects/fshifter.cpp b/Alc/effects/fshifter.cpp index 9b8499cf..c444872c 100644 --- a/Alc/effects/fshifter.cpp +++ b/Alc/effects/fshifter.cpp @@ -52,7 +52,7 @@ std::array<ALdouble,HIL_SIZE> InitHannWindow(void) /* Create lookup table of the Hann window for the desired size, i.e. HIL_SIZE */ for(ALsizei i{0};i < HIL_SIZE>>1;i++) { - ALdouble val = std::sin(M_PI * (ALdouble)i / (ALdouble)(HIL_SIZE-1)); + ALdouble val = std::sin(al::MathDefs<double>::Pi() * i / ALdouble{HIL_SIZE-1}); ret[i] = ret[HIL_SIZE-1-i] = val * val; } return ret; @@ -140,13 +140,13 @@ void ALfshifterState::update(const ALCcontext *context, const ALeffectslot *slot void ALfshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels) { - static const complex_d complex_zero{0.0, 0.0}; + static constexpr complex_d complex_zero{0.0, 0.0}; ALfloat *RESTRICT BufferOut = mBufferOut; ALsizei j, k, base; for(base = 0;base < SamplesToDo;) { - ALsizei todo = mini(HIL_SIZE-mCount, SamplesToDo-base); + const ALsizei todo{mini(HIL_SIZE-mCount, SamplesToDo-base)}; ASSUME(todo > 0); @@ -189,7 +189,7 @@ void ALfshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Samp /* Process frequency shifter using the analytic signal obtained. */ for(k = 0;k < SamplesToDo;k++) { - double phase = mPhase * ((1.0/FRACTIONONE) * 2.0*M_PI); + double phase = mPhase * ((1.0/FRACTIONONE) * al::MathDefs<double>::Tau()); BufferOut[k] = (float)(mOutdata[k].real()*std::cos(phase) + mOutdata[k].imag()*std::sin(phase)*mLdSign); diff --git a/Alc/effects/modulator.cpp b/Alc/effects/modulator.cpp index 889d6a86..3544188b 100644 --- a/Alc/effects/modulator.cpp +++ b/Alc/effects/modulator.cpp @@ -43,7 +43,7 @@ static inline ALfloat Sin(ALsizei index) { - return std::sin((ALfloat)index * (F_TAU / (ALfloat)WAVEFORM_FRACONE)); + return std::sin((ALfloat)index * (al::MathDefs<float>::Tau() / (ALfloat)WAVEFORM_FRACONE)); } static inline ALfloat Saw(ALsizei index) diff --git a/Alc/effects/pshifter.cpp b/Alc/effects/pshifter.cpp index a70fae52..8d82b07e 100644 --- a/Alc/effects/pshifter.cpp +++ b/Alc/effects/pshifter.cpp @@ -84,7 +84,7 @@ std::array<ALdouble,STFT_SIZE> InitHannWindow(void) /* Create lookup table of the Hann window for the desired size, i.e. HIL_SIZE */ for(ALsizei i{0};i < STFT_SIZE>>1;i++) { - ALdouble val = std::sin(M_PI * (ALdouble)i / (ALdouble)(STFT_SIZE-1)); + ALdouble val = std::sin(al::MathDefs<double>::Pi() * i / ALdouble{STFT_SIZE-1}); ret[i] = ret[STFT_SIZE-1-i] = val * val; } return ret; @@ -195,7 +195,7 @@ void ALpshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Samp * http://blogs.zynaptiq.com/bernsee/pitch-shifting-using-the-ft/ */ - static constexpr ALdouble expected{M_PI*2.0 / OVERSAMP}; + static constexpr ALdouble expected{al::MathDefs<double>::Tau() / OVERSAMP}; const ALdouble freq_per_bin{mFreqPerBin}; ALfloat *RESTRICT bufferOut{mBufferOut}; ALsizei count{mCount}; @@ -237,8 +237,8 @@ void ALpshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Samp double tmp{(component.Phase - mLastPhase[k]) - k*expected}; /* Map delta phase into +/- Pi interval */ - int qpd{double2int(tmp / M_PI)}; - tmp -= M_PI * (qpd + (qpd%2)); + int qpd{double2int(tmp / al::MathDefs<double>::Pi())}; + tmp -= al::MathDefs<double>::Pi() * (qpd + (qpd%2)); /* Get deviation from bin frequency from the +/- Pi interval */ tmp /= expected; diff --git a/Alc/effects/reverb.cpp b/Alc/effects/reverb.cpp index 9bc4f8f2..6f1b1bb1 100644 --- a/Alc/effects/reverb.cpp +++ b/Alc/effects/reverb.cpp @@ -738,9 +738,9 @@ alu::Matrix GetTransformFromVector(const ALfloat *vec) ALfloat mag{std::sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2])}; if(mag > 1.0f) { - norm[0] = vec[0] / mag * -SQRTF_3; - norm[1] = vec[1] / mag * SQRTF_3; - norm[2] = vec[2] / mag * SQRTF_3; + norm[0] = vec[0] / mag * -al::MathDefs<float>::Sqrt3(); + norm[1] = vec[1] / mag * al::MathDefs<float>::Sqrt3(); + norm[2] = vec[2] / mag * al::MathDefs<float>::Sqrt3(); mag = 1.0f; } else @@ -749,9 +749,9 @@ alu::Matrix GetTransformFromVector(const ALfloat *vec) * term. There's no need to renormalize the magnitude since it would * just be reapplied in the matrix. */ - norm[0] = vec[0] * -SQRTF_3; - norm[1] = vec[1] * SQRTF_3; - norm[2] = vec[2] * SQRTF_3; + norm[0] = vec[0] * -al::MathDefs<float>::Sqrt3(); + norm[1] = vec[1] * al::MathDefs<float>::Sqrt3(); + norm[2] = vec[2] * al::MathDefs<float>::Sqrt3(); } return alu::Matrix{ |