23#ifndef SBL_DSP_MATH_FAST_MATH_HPP_
24#define SBL_DSP_MATH_FAST_MATH_HPP_
43 return x * (1.0f - x2 * (1.0f / 6.0f - x2 * (1.0f / 120.0f)));
72 constexpr float pi =
PI;
73 constexpr float pi2 = pi * pi;
74 constexpr float pi4 = pi2 * pi2;
77 float num = 945.0f - 105.0f * pi2 * f2 + pi4 * f4;
78 float den = 945.0f - 420.0f * pi2 * f2 + 15.0f * pi4 * f4;
79 return pi * f * num / den;
101 if (x < -16.0f)
return 0.0f;
102 if (x > 16.0f) x = 16.0f;
106 int i =
static_cast<int>(x);
107 float f = x -
static_cast<float>(i);
108 if (f < 0.0f) { f += 1.0f; --i; }
112 constexpr float C1 = 0.6931472f;
113 constexpr float C2 = 0.2402265f;
114 constexpr float C3 = 0.0558011f;
115 constexpr float C4 = 0.00898f;
116 float p = 1.0f + f * (C1 + f * (C2 + f * (C3 + f * C4)));
119 union {
float fv; int32_t iv; } v;
142 if (x < -3.0f)
return -1.0f;
143 if (x > 3.0f)
return 1.0f;
144 if (x != x)
return 0.0f;
147 return x * (27.0f + x2) / (27.0f + 9.0f * x2);
152inline float su_to_hz(
float su,
float min_hz,
float octaves) {
159 const float denom = 1.0f + x * (1.0f + x * (0.5f + x * (1.0f / 6.0f)));
160 return 1.0f - 1.0f / denom;
The numbers every layer reaches for.
Cross-cutting math used at every audio layer.
float fast_exp2f(float x)
float fast_tan_pif(float f)
constexpr float one_minus_exp_neg(float x)
float su_to_hz(float su, float min_hz, float octaves)
float fast_tanhf(float x)