Struct thl::dsp::dynamics::GainComputer#

struct GainComputer#

The static curve of a dynamics processor: the gain in dB for a level in dB.

With d the distance past the threshold in the mode’s direction (above it for the downward compression and upward expansion, below it otherwise) and the slope s = 1 - 1 / ratio for compression, ratio - 1 for expansion, the gain is s·d for d >= knee / 2, s·(d + knee / 2)² / (2·knee) inside the knee and 0 below it (the quadratic soft knee of Giannoulis, Massberg and Reiss, “Digital Dynamic Range Compressor Design”, JAES 2012), continuous with its slope at both knee edges. The gain is negative for the downward modes and positive for the upward ones, and its size is capped at the range.

A ratio of infinity compresses to the threshold (limiting); ratios below 1 count as 1 (no change). Real-time safe.

Public Functions

inline float gain_db(float level_db) const#

The gain in dB at the level level_db.

Public Members

float m_threshold_db = -18.0f#
float m_ratio = 4.0f#
float m_knee_db = 6.0f#
float m_range_db = 60.0f#

the largest gain change, in either direction

DynamicsMode m_mode = DynamicsMode::DownwardCompression#