|
Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
|
Domain-neutral math: constants, clamp, interpolation. More...
Domain-neutral math: constants, clamp, interpolation.
Functions | |
| template<typename T > | |
| constexpr T | clamp (T x, T lo, T hi) |
| x held to [lo, hi]; a NaN goes to lo. | |
| template<typename T > | |
| constexpr T | clamp01 (T x) |
| x held to [0, 1]; a NaN goes to 0. | |
| bool | is_finite (float x) |
| std::isfinite, read from the exponent's bits. | |
| float | finite_or (float x, float fallback) |
x, or fallback when x is an infinity or a NaN. | |
| constexpr float | crossfade (float a, float b, float t) |
| Linear crossfade between two values. | |
| constexpr float | smooth_step (float t) |
| Hermite smooth step (3rd-order S-curve) | |
| constexpr int32_t | crossfade_i16 (int16_t a, int16_t b, uint16_t t) |
| Integer crossfade for 16-bit values. | |
| uint32_t | magnitude_bits (float x) |
| x's bits with the sign cleared. | |
Variables | |
| constexpr float | PI = 3.14159265358979323846f |
| constexpr float | TWO_PI = 2.0f * PI |
| constexpr float | HALF_PI = 0.5f * PI |
| constexpr float | MS_PER_SECOND = 1000.0f |
| constexpr float | SECONDS_PER_MS = 0.001f |
| constexpr float | SECONDS_PER_MINUTE = 60.0f |
| constexpr uint16_t | U16_MAX = 65535 |
| The full scale of a 16-bit unsigned blend factor. | |
| constexpr uint32_t | FLOAT_EXPONENT_BITS = 0x7F800000u |
| A single's exponent field: all ones in infinities and NaNs. | |
|
inlineconstexpr |
x held to [lo, hi]; a NaN goes to lo.
| x | Value to clamp |
| lo | Low bound |
| hi | High bound, at or above lo |
Definition at line 24 of file clamp.hpp.
Referenced by clamp01(), sbl::dsp::math::crossfade_gains_equal_power(), sbl::dsp::Svf::damping_for(), sbl::dsp::PhaseWalk::frame(), sbl::dsp::Svf::integrator_gain_for(), sbl::dsp::pm_frequency(), sbl::dsp::pm_taming(), sbl::dsp::BlepOsc< Kernel >::process(), sbl::dsp::PhasePulse< Kernel >::set_anchor(), sbl::dsp::PhaseSaw< Kernel >::set_anchor(), sbl::dsp::BlepOsc< Kernel >::set_frequency(), sbl::dsp::BlepOsc< Kernel >::set_pulse_width(), sbl::dsp::Svf::set_response_index(), sbl::dsp::BlepOsc< Kernel >::set_saw_knee(), sbl::dsp::BlepOsc< Kernel >::set_triangle_peak(), sbl::dsp::PhasePulse< Kernel >::set_width(), and sbl::dsp::PhaseSaw< Kernel >::set_width().
|
inlineconstexpr |
x held to [0, 1]; a NaN goes to 0.
| x | Value to clamp |
Definition at line 35 of file clamp.hpp.
References clamp().
Referenced by sbl::dsp::Vco::knee_for(), sbl::control::ParamEcho< Target >::poll(), sbl::dsp::Vca::process(), sbl::dsp::DryWet::process(), and sbl::dsp::Vco::pulse_amount().
|
inline |
std::isfinite, read from the exponent's bits.
| x | Any float |
Definition at line 27 of file finite.hpp.
References FLOAT_EXPONENT_BITS, and magnitude_bits().
Referenced by finite_or(), sbl::dsp::PhaseWalk::frame(), and sbl::dsp::PmInput::process().
|
inline |
x, or fallback when x is an infinity or a NaN.
| x | Any float |
| fallback | Value returned for a non-finite x |
Definition at line 36 of file finite.hpp.
References is_finite().
Referenced by sbl::dsp::Vco::knee_for(), sbl::dsp::pm_depth(), sbl::dsp::Vca::process(), sbl::dsp::BlepOsc< Kernel >::process(), sbl::dsp::PmPulse::process(), sbl::dsp::Vco::pulse_amount(), sbl::dsp::PhasePulse< Kernel >::set_anchor(), sbl::dsp::PhaseSaw< Kernel >::set_anchor(), sbl::dsp::BlepOsc< Kernel >::set_blend(), sbl::dsp::BlepOsc< Kernel >::set_frequency(), sbl::dsp::BlepOsc< Kernel >::set_pulse_width(), sbl::dsp::BlepOsc< Kernel >::set_saw_knee(), sbl::dsp::BlepOsc< Kernel >::set_triangle_peak(), sbl::dsp::PmPulse::set_tune(), sbl::dsp::Vco::set_tune(), sbl::dsp::PhasePulse< Kernel >::set_width(), and sbl::dsp::PhaseSaw< Kernel >::set_width().
|
inlineconstexpr |
Linear crossfade between two values.
| a | Value at t=0 |
| b | Value at t=1 |
| t | Blend factor in [0, 1] (not clamped) |
Definition at line 28 of file interpolate.hpp.
|
inlineconstexpr |
Hermite smooth step (3rd-order S-curve)
Maps [0, 1] to [0, 1] with zero derivative at the endpoints.
| t | Input in [0, 1] (not clamped) |
Definition at line 38 of file interpolate.hpp.
|
inlineconstexpr |
Integer crossfade for 16-bit values.
| a | Value at t=0 |
| b | Value at t=1 |
| t | Blend factor [0, 65535] (0 = all a, 65535 = all b) |
Definition at line 48 of file interpolate.hpp.
References U16_MAX.
|
inline |
x's bits with the sign cleared.
For finite a and b, magnitude_bits(a) < magnitude_bits(b) exactly when |a| < |b|; a non-finite value reads above every finite one, and both zeros read 0.
| x | Any float, NaN and infinities included |
Definition at line 29 of file magnitude.hpp.
Referenced by sbl::dsp::SoftLimiter::acts_on(), and is_finite().
|
inlineconstexpr |
pi
Definition at line 17 of file constants.hpp.
Referenced by sbl::dsp::math::crossfade_gains_equal_power(), and sbl::dsp::math::fast_tan_pif().
|
inlineconstexpr |
2 pi
Definition at line 18 of file constants.hpp.
Referenced by sbl::dsp::OnePole::coefficient_for().
|
inlineconstexpr |
pi / 2
Definition at line 19 of file constants.hpp.
|
inlineconstexpr |
Milliseconds in a second
Definition at line 21 of file constants.hpp.
|
inlineconstexpr |
Seconds in a millisecond
Definition at line 22 of file constants.hpp.
|
inlineconstexpr |
Seconds in a minute
Definition at line 23 of file constants.hpp.
|
inlineconstexpr |
The full scale of a 16-bit unsigned blend factor.
Definition at line 26 of file constants.hpp.
Referenced by crossfade_i16().
|
inlineconstexpr |
A single's exponent field: all ones in infinities and NaNs.
Definition at line 19 of file finite.hpp.
Referenced by is_finite().