|
| | SmoothedValue (const SmoothedValue &)=delete |
| | Prevents accidental copying of stateful DSP objects.
|
| |
| SmoothedValue & | operator= (const SmoothedValue &)=delete |
| |
| | SmoothedValue () noexcept |
| |
| void | prepare (double sampleRate, double rampTimeMs=20.0) noexcept |
| | Precalculates internal coefficients based on sample rate and timing.
|
| |
| void | setSmoothingType (SmoothingType type) noexcept |
| | Sets the smoothing algorithm.
|
| |
| SmoothingType | getSmoothingType () const noexcept |
| | Returns the current smoothing algorithm.
|
| |
| void | setTargetValue (T newTarget) noexcept |
| | Updates the target value. Safe to call continuously (e.g., from host automation).
|
| |
| T | getNextValue () noexcept |
| | Calculates and returns the next smoothed value.
|
| |
| void | processBlock (std::span< T > buffer) noexcept |
| | Computes a block of smoothed values into an output buffer.
|
| |
| T | getCurrentValue () const noexcept |
| | Returns the current internal value without advancing the state.
|
| |
| T | getTargetValue () const noexcept |
| | Returns the set target value.
|
| |
| bool | isSmoothing () const noexcept |
| | Evaluates if the smoother is actively transitioning.
|
| |
| void | skip () noexcept |
| | Forces the current value to instantly match the target, bypassing time.
|
| |
| void | reset (T value=T(0)) noexcept |
| | Hard-resets both current and target states to a specific value.
|
| |
| void | setRampTime (double sampleRate, double rampTimeMs) noexcept |
| | Updates sample rate and/or ramp time, recalculating internal steps.
|
| |
template<FloatType T>
class dspark::SmoothedValue< T >
Zero-allocation parameter smoother for real-time audio.
Provides click-free parameter transitions using various curves, processed per-sample or per-block in the audio thread. A default-constructed smoother is functional at 44.1 kHz with a 20 ms ramp; prepare() adapts it to the real rate.
Timing semantics of rampTimeMs per curve:
- Exponential: one-pole time constant (63% arrival). The value snaps exactly onto the target once within a relative epsilon, about 16 time constants after a unit step, and isSmoothing() then reports false.
- Linear: constant velocity sized to traverse a UNIT step in rampTimeMs; smaller steps arrive proportionally sooner, exactly on target.
- Chase: adaptive (not clocked): gentle right after a target change, accelerating as it settles.
The recursion state is double regardless of T (the framework rule for recursive state): in float the one-pole stalls hundreds of epsilons short of the target when the per-sample increment rounds to zero, which would leave isSmoothing() true forever (and callers that gate work on it, like Gain's bulk path or CrossoverFilter's coefficient updates, stuck on their slow path).
- Note
- Thread Safety: This class is not inherently thread-safe to avoid atomic memory barriers in the DSP hot-path. Parameter updates via
setTargetValue() should occur synchronously within the audio thread (e.g., processing an event queue at the start of a block).
- Template Parameters
-
| T | Value type (float or double, constrained by FloatType). |
Definition at line 60 of file SmoothedValue.h.