Vital
Loading...
Searching...
No Matches
futils.h File Reference

Contains faster but less accurate versions of utility math functions, such as exponential, logarithm, and trigonometric approximations. More...

#include "common.h"
#include "poly_utils.h"
#include <cmath>

Go to the source code of this file.

Namespaces

namespace  vital
 Contains classes and functions used within the Vital synthesizer framework.
 
namespace  vital::futils
 Provides fast approximation functions for exponentials, logarithms, trigonometric operations, and saturation curves.
 

Functions

force_inline poly_float vital::futils::exp2 (poly_float exponent)
 Approximates 2^exponent for poly_float values using a polynomial approximation.
 
force_inline poly_float vital::futils::log2 (poly_float value)
 Approximates log2(value) for poly_float values using a polynomial approximation.
 
force_inline poly_float vital::futils::cheapExp2 (poly_float exponent)
 A cheaper but less accurate version of exp2 approximation.
 
force_inline poly_float vital::futils::cheapLog2 (poly_float value)
 A cheaper but less accurate version of log2 approximation.
 
force_inline mono_float vital::futils::exp2 (mono_float value)
 
force_inline mono_float vital::futils::log2 (mono_float value)
 
force_inline mono_float vital::futils::exp (mono_float exponent)
 
force_inline mono_float vital::futils::log (mono_float value)
 
force_inline mono_float vital::futils::exp_half (mono_float exponent)
 
force_inline mono_float vital::futils::pow (mono_float base, mono_float exponent)
 
template<mono_float(*)(mono_float) func>
force_inline poly_float vital::futils::map (poly_float value)
 Applies a scalar function to each element of a poly_float.
 
force_inline poly_float vital::futils::exp (poly_float exponent)
 
force_inline poly_float vital::futils::log (poly_float value)
 
force_inline poly_float vital::futils::exp_half (poly_float exponent)
 
force_inline poly_float vital::futils::pow (poly_float base, poly_float exponent)
 
force_inline poly_float vital::futils::cheapPow (poly_float base, poly_float exponent)
 
force_inline poly_float vital::futils::midiOffsetToRatio (poly_float note_offset)
 Converts a MIDI note offset to a frequency ratio.
 
force_inline poly_float vital::futils::midiNoteToFrequency (poly_float note)
 Converts a MIDI note number to frequency (in Hz).
 
force_inline mono_float vital::futils::magnitudeToDb (mono_float magnitude)
 Converts a magnitude (linear) to decibels (dB).
 
force_inline poly_float vital::futils::magnitudeToDb (poly_float magnitude)
 
force_inline mono_float vital::futils::dbToMagnitude (mono_float decibels)
 Converts decibels (dB) to magnitude (linear).
 
force_inline poly_float vital::futils::dbToMagnitude (poly_float decibels)
 
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.
 
force_inline mono_float vital::futils::quickTanh (mono_float value)
 A quick approximation of the tanh function.
 
force_inline poly_float vital::futils::quickTanh (poly_float value)
 
force_inline poly_float vital::futils::quickTanhDerivative (poly_float value)
 Derivative of the quick tanh approximation.
 
force_inline mono_float vital::futils::quickTanhDerivative (mono_float value)
 
force_inline mono_float vital::futils::reciprocalSat (mono_float value)
 Saturation approximation using 1/x function.
 
force_inline mono_float vital::futils::algebraicSat (mono_float value)
 Algebraic saturation approximation.
 
force_inline poly_float vital::futils::algebraicSat (poly_float value)
 
force_inline poly_float vital::futils::quadraticInvSat (poly_float value)
 Quadratic inverse saturation approximation.
 
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 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::tanh (poly_float value)
 Approximates tanh function using a complex polynomial.
 
force_inline mono_float vital::futils::tanh (mono_float value)
 
force_inline poly_float vital::futils::hardTanh (poly_float value)
 Another saturation function using half-range tanh.
 
force_inline poly_float vital::futils::tanhDerivativeFast (poly_float value)
 A fast approximation for the derivative of tanh.
 
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::sin (mono_float phase)
 
force_inline poly_float vital::futils::sin (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::quickSin1 (mono_float phase)
 
force_inline poly_float vital::futils::quickSin1 (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::equalPowerFade (poly_float t)
 Produces an equal-power crossfade (sin-based) between 0.0 and 1.0.
 
force_inline poly_float vital::futils::panAmplitude (poly_float pan)
 
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::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)
 

Detailed Description

Contains faster but less accurate versions of utility math functions, such as exponential, logarithm, and trigonometric approximations.

The functions in this file are optimized approximations for math operations used frequently in audio DSP. While they may not be as precise as their standard library counterparts (e.g. std::exp, std::log), they offer improved performance in certain scenarios where exact accuracy is not critical.