Class thl::dsp::dynamics::GainSmoother#
-
class GainSmoother#
The ballistics of a dynamics processor: smooths its gain in dB.
Smoothing the computed gain, not the level (the “smooth decoupled” detector of Giannoulis, Massberg and Reiss 2012), gives the attack and release their own times whatever the threshold and ratio. The gain moves with the attack time while its target lies farther from 0 dB than it (more gain change: in compression, out of an upward mode), with the release time otherwise; both are one-pole time constants (the step reaches 1 - 1/e, 63 %, after one).
Hold: a release waits this long after the gain last moved away from 0 dB or held at its target (a sustained compression holds from its end).
Auto release: a second, slow stage (10× the attack, 10× the release) follows the same target, and the gain is whichever stage lies farther from 0 dB. A short peak hardly moves the slow stage and releases at the release time; a long compression builds it up and releases slowly, which pumps less.
Threads: set_times() computes coefficients (std::exp); all is real-time safe.
Public Functions
-
inline void prepare(double sample_rate)#
-
inline void set_times(float attack_ms, float release_ms, float hold_ms = 0.0f, bool auto_release = false)#
Attack, release and hold in ms; at 0 the gain jumps (attack, release) or does not wait.
-
inline void reset(float gain_db = 0.0f)#
Jumps to
gain_db, both stages, the hold over.
-
inline float process(float target_db)#
One sample towards
target_db; the smoothed gain in dB.
-
inline float gain_db() const#
The gain in dB as last returned (without auto release: the fast stage).
Public Static Attributes
-
static constexpr float k_auto_release_factor = 10.0f#