Vital
|
Provides fast approximation functions for exponentials, logarithms, trigonometric operations, and saturation curves. More...
Provides fast approximation functions for exponentials, logarithms, trigonometric operations, and saturation curves.
The approximations in futils are designed to be efficient and are often "good enough" for audio DSP tasks where slight deviations from exact mathematical results are acceptable.
force_inline mono_float vital::futils::algebraicSat | ( | mono_float | value | ) |
force_inline poly_float vital::futils::algebraicSat | ( | poly_float | value | ) |
force_inline mono_float vital::futils::algebraicSatDerivative | ( | mono_float | value | ) |
Derivative of algebraic saturation approximation.
force_inline poly_float vital::futils::algebraicSatDerivative | ( | poly_float | value | ) |
force_inline poly_float vital::futils::bumpSat | ( | poly_float | value | ) |
Bump saturation approximations.
force_inline poly_float vital::futils::bumpSat2 | ( | poly_float | value | ) |
force_inline poly_float vital::futils::cheapExp2 | ( | poly_float | exponent | ) |
A cheaper but less accurate version of exp2 approximation.
exponent | The exponent to raise 2 to. |
force_inline poly_float vital::futils::cheapLog2 | ( | poly_float | value | ) |
A cheaper but less accurate version of log2 approximation.
value | The input value for log base 2. |
force_inline poly_float vital::futils::cheapPow | ( | poly_float | base, |
poly_float | exponent ) |
force_inline mono_float vital::futils::dbToMagnitude | ( | mono_float | decibels | ) |
Converts decibels (dB) to magnitude (linear).
decibels | Value in decibels. |
force_inline poly_float vital::futils::dbToMagnitude | ( | poly_float | decibels | ) |
force_inline poly_float vital::futils::equalPowerFade | ( | poly_float | t | ) |
Produces an equal-power crossfade (sin-based) between 0.0 and 1.0.
force_inline poly_float vital::futils::equalPowerFadeInverse | ( | poly_float | t | ) |
The inverse equal-power fade from t to t+1.0.
force_inline mono_float vital::futils::exp | ( | mono_float | exponent | ) |
force_inline poly_float vital::futils::exp | ( | poly_float | exponent | ) |
force_inline mono_float vital::futils::exp2 | ( | mono_float | value | ) |
force_inline poly_float vital::futils::exp2 | ( | poly_float | exponent | ) |
Approximates 2^exponent for poly_float values using a polynomial approximation.
This is a more accurate approximation but still faster than a standard library exp2 function.
exponent | The exponent to raise 2 to. |
force_inline mono_float vital::futils::exp_half | ( | mono_float | exponent | ) |
force_inline poly_float vital::futils::exp_half | ( | poly_float | exponent | ) |
force_inline poly_float vital::futils::hardTanh | ( | poly_float | value | ) |
Another saturation function using half-range tanh.
force_inline mono_float vital::futils::log | ( | mono_float | value | ) |
force_inline poly_float vital::futils::log | ( | poly_float | value | ) |
force_inline mono_float vital::futils::log2 | ( | mono_float | value | ) |
force_inline poly_float vital::futils::log2 | ( | poly_float | value | ) |
Approximates log2(value) for poly_float values using a polynomial approximation.
value | The input value to take the log base 2 of. |
force_inline mono_float vital::futils::magnitudeToDb | ( | mono_float | magnitude | ) |
Converts a magnitude (linear) to decibels (dB).
magnitude | Linear magnitude value. |
force_inline poly_float vital::futils::magnitudeToDb | ( | poly_float | magnitude | ) |
force_inline poly_float vital::futils::map | ( | poly_float | value | ) |
Applies a scalar function to each element of a poly_float.
func | A function pointer taking a mono_float and returning mono_float. |
value | The input poly_float. |
force_inline poly_float vital::futils::midiNoteToFrequency | ( | poly_float | note | ) |
Converts a MIDI note number to frequency (in Hz).
note | The MIDI note number (as poly_float). |
force_inline poly_float vital::futils::midiOffsetToRatio | ( | poly_float | note_offset | ) |
Converts a MIDI note offset to a frequency ratio.
note_offset | The note offset in semitones. |
force_inline poly_float vital::futils::mulAdd | ( | poly_float | a, |
poly_float | b, | ||
poly_float | c ) |
A fused multiply-add function: result = a * b + c.
a,b,c | poly_float inputs for the operation. |
force_inline poly_float vital::futils::panAmplitude | ( | poly_float | pan | ) |
force_inline mono_float vital::futils::pow | ( | mono_float | base, |
mono_float | exponent ) |
force_inline poly_float vital::futils::pow | ( | poly_float | base, |
poly_float | exponent ) |
force_inline mono_float vital::futils::powerScale | ( | mono_float | value, |
mono_float | power ) |
A power-scaling function to map a linear range to a curved response.
force_inline poly_float vital::futils::powerScale | ( | poly_float | value, |
poly_float | power ) |
force_inline poly_float vital::futils::quadraticInvSat | ( | poly_float | value | ) |
Quadratic inverse saturation approximation.
force_inline mono_float vital::futils::quickSin | ( | mono_float | phase | ) |
Quick approximations of sine functions assuming limited phase input ranges.
force_inline poly_float vital::futils::quickSin | ( | poly_float | phase | ) |
force_inline mono_float vital::futils::quickSin1 | ( | mono_float | phase | ) |
force_inline poly_float vital::futils::quickSin1 | ( | poly_float | phase | ) |
force_inline mono_float vital::futils::quickTanh | ( | mono_float | value | ) |
A quick approximation of the tanh function.
value | The input value. |
force_inline poly_float vital::futils::quickTanh | ( | poly_float | value | ) |
force_inline mono_float vital::futils::quickTanhDerivative | ( | mono_float | value | ) |
force_inline poly_float vital::futils::quickTanhDerivative | ( | poly_float | value | ) |
Derivative of the quick tanh approximation.
value | The input value. |
force_inline mono_float vital::futils::reciprocalSat | ( | mono_float | value | ) |
force_inline mono_float vital::futils::sin | ( | mono_float | phase | ) |
force_inline poly_float vital::futils::sin | ( | poly_float | phase | ) |
force_inline mono_float vital::futils::sin1 | ( | mono_float | phase | ) |
force_inline poly_float vital::futils::sin1 | ( | poly_float | phase | ) |
force_inline poly_float vital::futils::sinInterpolate | ( | poly_float | from, |
poly_float | to, | ||
poly_float | t ) |
force_inline mono_float vital::futils::tanh | ( | mono_float | value | ) |
force_inline poly_float vital::futils::tanh | ( | poly_float | value | ) |
Approximates tanh function using a complex polynomial.
force_inline poly_float vital::futils::tanhDerivativeFast | ( | poly_float | value | ) |
A fast approximation for the derivative of tanh.