aboutsummaryrefslogtreecommitdiffstats
path: root/alc/effects
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-01-27 02:59:07 -0800
committerChris Robinson <[email protected]>2022-01-27 02:59:07 -0800
commitf8ac1ffe805b13c8b1cd2bc4d4a8362cbe1c2cbe (patch)
treea8a24a3e85f7a8f00cf3947da37e97ab0f42d3f6 /alc/effects
parent1bbea9cd3060ef65a2623f156b4f12ebf62c52fe (diff)
Get rid of MathDefs
Diffstat (limited to 'alc/effects')
-rw-r--r--alc/effects/autowah.cpp4
-rw-r--r--alc/effects/chorus.cpp4
-rw-r--r--alc/effects/distortion.cpp4
-rw-r--r--alc/effects/fshifter.cpp6
-rw-r--r--alc/effects/modulator.cpp4
-rw-r--r--alc/effects/pshifter.cpp10
-rw-r--r--alc/effects/reverb.cpp14
-rw-r--r--alc/effects/vmorpher.cpp6
8 files changed, 24 insertions, 28 deletions
diff --git a/alc/effects/autowah.cpp b/alc/effects/autowah.cpp
index f496eb51..46cc8fb0 100644
--- a/alc/effects/autowah.cpp
+++ b/alc/effects/autowah.cpp
@@ -28,6 +28,7 @@
#include "alc/effects/base.h"
#include "almalloc.h"
+#include "alnumbers.h"
#include "alnumeric.h"
#include "alspan.h"
#include "core/ambidefs.h"
@@ -38,7 +39,6 @@
#include "core/effectslot.h"
#include "core/mixer.h"
#include "intrusive_ptr.h"
-#include "math_defs.h"
namespace {
@@ -159,7 +159,7 @@ void AutowahState::process(const size_t samplesToDo,
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) * al::MathDefs<float>::Tau();
+ w0 = minf((bandwidth*env_delay + freq_min), 0.46f) * (al::numbers::pi_v<float>*2.0f);
mEnv[i].cos_w0 = std::cos(w0);
mEnv[i].alpha = std::sin(w0)/(2.0f * QFactor);
}
diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp
index 7d32f8ff..99a2a68a 100644
--- a/alc/effects/chorus.cpp
+++ b/alc/effects/chorus.cpp
@@ -28,6 +28,7 @@
#include "alc/effects/base.h"
#include "almalloc.h"
+#include "alnumbers.h"
#include "alnumeric.h"
#include "alspan.h"
#include "core/bufferline.h"
@@ -39,7 +40,6 @@
#include "core/mixer/defs.h"
#include "core/resampler_limits.h"
#include "intrusive_ptr.h"
-#include "math_defs.h"
#include "opthelpers.h"
#include "vector.h"
@@ -150,7 +150,7 @@ void ChorusState::update(const ContextBase *Context, const EffectSlot *Slot,
mLfoScale = 4.0f / static_cast<float>(mLfoRange);
break;
case ChorusWaveform::Sinusoid:
- mLfoScale = al::MathDefs<float>::Tau() / static_cast<float>(mLfoRange);
+ mLfoScale = al::numbers::pi_v<float>*2.0f / static_cast<float>(mLfoRange);
break;
}
diff --git a/alc/effects/distortion.cpp b/alc/effects/distortion.cpp
index c9366791..74cffd4a 100644
--- a/alc/effects/distortion.cpp
+++ b/alc/effects/distortion.cpp
@@ -27,6 +27,7 @@
#include "alc/effects/base.h"
#include "almalloc.h"
+#include "alnumbers.h"
#include "alnumeric.h"
#include "alspan.h"
#include "core/bufferline.h"
@@ -38,7 +39,6 @@
#include "core/mixer.h"
#include "core/mixer/defs.h"
#include "intrusive_ptr.h"
-#include "math_defs.h"
namespace {
@@ -77,7 +77,7 @@ void DistortionState::update(const ContextBase *context, const EffectSlot *slot,
const DeviceBase *device{context->mDevice};
/* Store waveshaper edge settings. */
- const float edge{minf(std::sin(al::MathDefs<float>::Pi()*0.5f * props->Distortion.Edge),
+ const float edge{minf(std::sin(al::numbers::pi_v<float>*0.5f * props->Distortion.Edge),
0.99f)};
mEdgeCoeff = 2.0f * edge / (1.0f-edge);
diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp
index b143db0c..def745c4 100644
--- a/alc/effects/fshifter.cpp
+++ b/alc/effects/fshifter.cpp
@@ -30,6 +30,7 @@
#include "alc/effects/base.h"
#include "alcomplex.h"
#include "almalloc.h"
+#include "alnumbers.h"
#include "alnumeric.h"
#include "alspan.h"
#include "core/bufferline.h"
@@ -40,7 +41,6 @@
#include "core/mixer.h"
#include "core/mixer/defs.h"
#include "intrusive_ptr.h"
-#include "math_defs.h"
namespace {
@@ -61,7 +61,7 @@ std::array<double,HIL_SIZE> InitHannWindow()
/* Create lookup table of the Hann window for the desired size, i.e. HIL_SIZE */
for(size_t i{0};i < HIL_SIZE>>1;i++)
{
- constexpr double scale{al::MathDefs<double>::Pi() / double{HIL_SIZE}};
+ constexpr double scale{al::numbers::pi / double{HIL_SIZE}};
const double val{std::sin(static_cast<double>(i+1) * scale)};
ret[i] = ret[HIL_SIZE-1-i] = val * val;
}
@@ -217,7 +217,7 @@ void FshifterState::process(const size_t samplesToDo, const al::span<const Float
uint phase_idx{mPhase[c]};
for(size_t k{0};k < samplesToDo;++k)
{
- const double phase{phase_idx * ((1.0/MixerFracOne) * al::MathDefs<double>::Tau())};
+ const double phase{phase_idx * (al::numbers::pi*2.0 / MixerFracOne)};
BufferOut[k] = static_cast<float>(mOutdata[k].real()*std::cos(phase) +
mOutdata[k].imag()*std::sin(phase)*mSign[c]);
diff --git a/alc/effects/modulator.cpp b/alc/effects/modulator.cpp
index 4a086b11..84561f5c 100644
--- a/alc/effects/modulator.cpp
+++ b/alc/effects/modulator.cpp
@@ -27,6 +27,7 @@
#include "alc/effects/base.h"
#include "almalloc.h"
+#include "alnumbers.h"
#include "alnumeric.h"
#include "alspan.h"
#include "core/ambidefs.h"
@@ -38,7 +39,6 @@
#include "core/filters/biquad.h"
#include "core/mixer.h"
#include "intrusive_ptr.h"
-#include "math_defs.h"
namespace {
@@ -53,7 +53,7 @@ using uint = unsigned int;
inline float Sin(uint index)
{
- constexpr float scale{al::MathDefs<float>::Tau() / WAVEFORM_FRACONE};
+ constexpr float scale{al::numbers::pi_v<float>*2.0f / WAVEFORM_FRACONE};
return std::sin(static_cast<float>(index) * scale);
}
diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp
index dae0a267..aa20c660 100644
--- a/alc/effects/pshifter.cpp
+++ b/alc/effects/pshifter.cpp
@@ -30,6 +30,7 @@
#include "alc/effects/base.h"
#include "alcomplex.h"
#include "almalloc.h"
+#include "alnumbers.h"
#include "alnumeric.h"
#include "alspan.h"
#include "core/bufferline.h"
@@ -39,7 +40,6 @@
#include "core/mixer.h"
#include "core/mixer/defs.h"
#include "intrusive_ptr.h"
-#include "math_defs.h"
struct ContextBase;
@@ -63,7 +63,7 @@ std::array<double,STFT_SIZE> InitHannWindow()
/* Create lookup table of the Hann window for the desired size, i.e. STFT_SIZE */
for(size_t i{0};i < STFT_SIZE>>1;i++)
{
- constexpr double scale{al::MathDefs<double>::Pi() / double{STFT_SIZE}};
+ constexpr double scale{al::numbers::pi / double{STFT_SIZE}};
const double val{std::sin(static_cast<double>(i+1) * scale)};
ret[i] = ret[STFT_SIZE-1-i] = val * val;
}
@@ -155,7 +155,7 @@ void PshifterState::process(const size_t samplesToDo, const al::span<const Float
/* Cycle offset per update expected of each frequency bin (bin 0 is none,
* bin 1 is x1, bin 2 is x2, etc).
*/
- constexpr double expected_cycles{al::MathDefs<double>::Tau() / OVERSAMP};
+ constexpr double expected_cycles{al::numbers::pi*2.0 / OVERSAMP};
for(size_t base{0u};base < samplesToDo;)
{
@@ -198,8 +198,8 @@ void PshifterState::process(const size_t samplesToDo, const al::span<const Float
double tmp{(phase - mLastPhase[k]) - static_cast<double>(k)*expected_cycles};
/* Map delta phase into +/- Pi interval */
- int qpd{double2int(tmp / al::MathDefs<double>::Pi())};
- tmp -= al::MathDefs<double>::Pi() * (qpd + (qpd%2));
+ int qpd{double2int(tmp / al::numbers::pi)};
+ tmp -= al::numbers::pi * (qpd + (qpd%2));
/* Get deviation from bin frequency from the +/- Pi interval */
tmp /= expected_cycles;
diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp
index 379cc1fb..0b5e4edb 100644
--- a/alc/effects/reverb.cpp
+++ b/alc/effects/reverb.cpp
@@ -44,7 +44,6 @@
#include "core/mixer.h"
#include "core/mixer/defs.h"
#include "intrusive_ptr.h"
-#include "math_defs.h"
#include "opthelpers.h"
#include "vecmat.h"
#include "vector.h"
@@ -113,7 +112,7 @@ alignas(16) constexpr float EarlyA2B[NUM_LINES][NUM_LINES]{
};
/* Converts A-Format to B-Format for late reverb. */
-constexpr float Sqrt1_2{7.07106781e-01f/*1.0f/std::sqrt(2.0f)*/};
+constexpr auto Sqrt1_2 = static_cast<float>(1.0/al::numbers::sqrt2);
alignas(16) constexpr float LateA2B[NUM_LINES][NUM_LINES]{
{ 0.5f, 0.5f, 0.5f, 0.5f },
{ Sqrt1_2, -Sqrt1_2, 0.0f, 0.0f },
@@ -795,10 +794,8 @@ void T60Filter::calcCoeffs(const float length, const float lfDecayTime,
void EarlyReflections::updateLines(const float density_mult, const float diffusion,
const float decayTime, const float frequency)
{
- constexpr float sqrt1_2{0.70710678118654752440f/*1.0f/std::sqrt(2.0f)*/};
-
/* Calculate the all-pass feed-back/forward coefficient. */
- VecAp.Coeff = diffusion*diffusion * sqrt1_2;
+ VecAp.Coeff = diffusion*diffusion * Sqrt1_2;
for(size_t i{0u};i < NUM_LINES;i++)
{
@@ -888,8 +885,7 @@ void LateReverb::updateLines(const float density_mult, const float diffusion,
DensityGain[1] = CalcDensityGain(CalcDecayCoeff(length, decayTimeWeighted));
/* Calculate the all-pass feed-back/forward coefficient. */
- constexpr float sqrt1_2{0.70710678118654752440f/*1.0f/std::sqrt(2.0f)*/};
- VecAp.Coeff = diffusion*diffusion * sqrt1_2;
+ VecAp.Coeff = diffusion*diffusion * Sqrt1_2;
for(size_t i{0u};i < NUM_LINES;i++)
{
@@ -1431,7 +1427,7 @@ void ReverbState::earlyFaded(const size_t offset, const size_t todo, const float
void Modulation::calcDelays(size_t todo)
{
- constexpr float inv_scale{MOD_FRACONE / al::MathDefs<float>::Tau()};
+ constexpr float inv_scale{MOD_FRACONE / al::numbers::pi_v<float> / 2.0f};
uint idx{Index};
const uint step{Step};
const float depth{Depth[0]};
@@ -1446,7 +1442,7 @@ void Modulation::calcDelays(size_t todo)
void Modulation::calcFadedDelays(size_t todo, float fadeCount, float fadeStep)
{
- constexpr float inv_scale{MOD_FRACONE / al::MathDefs<float>::Tau()};
+ constexpr float inv_scale{MOD_FRACONE / al::numbers::pi_v<float> / 2.0f};
uint idx{Index};
const uint step{Step};
const float depth{Depth[0]};
diff --git a/alc/effects/vmorpher.cpp b/alc/effects/vmorpher.cpp
index e3eed179..48cbb15e 100644
--- a/alc/effects/vmorpher.cpp
+++ b/alc/effects/vmorpher.cpp
@@ -40,6 +40,7 @@
#include "alc/effects/base.h"
#include "almalloc.h"
+#include "alnumbers.h"
#include "alnumeric.h"
#include "alspan.h"
#include "core/ambidefs.h"
@@ -50,7 +51,6 @@
#include "core/effectslot.h"
#include "core/mixer.h"
#include "intrusive_ptr.h"
-#include "math_defs.h"
namespace {
@@ -71,7 +71,7 @@ using uint = unsigned int;
inline float Sin(uint index)
{
- constexpr float scale{al::MathDefs<float>::Tau() / WAVEFORM_FRACONE};
+ constexpr float scale{al::numbers::pi_v<float>*2.0f / WAVEFORM_FRACONE};
return std::sin(static_cast<float>(index) * scale)*0.5f + 0.5f;
}
@@ -103,7 +103,7 @@ struct FormantFilter
FormantFilter() = default;
FormantFilter(float f0norm, float gain)
- : mCoeff{std::tan(al::MathDefs<float>::Pi() * f0norm)}, mGain{gain}
+ : mCoeff{std::tan(al::numbers::pi_v<float> * f0norm)}, mGain{gain}
{ }
inline void process(const float *samplesIn, float *samplesOut, const size_t numInput)