16#ifndef SBL_DSP_MATH_FAST_MATH_HPP_
17#define SBL_DSP_MATH_FAST_MATH_HPP_
48 return x * (1.0f - x2 * (1.0f / 6.0f - x2 * (1.0f / 120.0f)));
75 constexpr float PI4 = PI2 * PI2;
79 float num = 945.0f - 105.0f * PI2 * f2 + PI4 * f4;
80 float den = 945.0f - 420.0f * PI2 * f2 + 15.0f * PI4 * f4;
112 int i =
static_cast<int>(x);
113 float f = x -
static_cast<float>(i);
120 constexpr float C1 = 0.6931472f;
121 constexpr float C2 = 0.2402265f;
122 constexpr float C3 = 0.0558011f;
123 constexpr float C4 = 0.00898f;
124 float p = 1.0f + f * (C1 + f * (C2 + f * (C3 + f * C4)));
129 std::memcpy(&bits, &p,
sizeof(bits));
131 std::memcpy(&p, &bits,
sizeof(p));
157 return x * (27.0f + x2) / (27.0f + 9.0f * x2);
169 const float denom = 1.0f + x * (1.0f + x * (0.5f + x * (1.0f / 6.0f)));
170 return 1.0f - 1.0f / denom;
The numbers every layer reaches for.
Math for the audio stack.
constexpr int32_t FLOAT_MANTISSA_BITS
float fast_sinf(float x)
Fast sine approximation for x in [0, pi/2].
float fast_exp2f(float x)
Fast 2^x approximation for exponential modulation.
constexpr float EXP2_MAX_ARG
float fast_tan_pif(float f)
Fast tan(pi f) for normalized frequency f in [0, 0.497].
constexpr float one_minus_exp_neg(float x)
1 - e^(-x) by inverse Taylor, with no expf
constexpr float FAST_TAN_PIF_MAX_F
constexpr float TANH_SATURATE_X
float fast_tanhf(float x)
Fast tanh approximation using a [3,2] Pade approximant.