Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::signal::VcaCompressorT< SampleType > Class Template Reference

True-RMS, log-domain, single-time-constant feedforward compressor. More...

#include <vca_compressor.hpp>

Public Member Functions

void prepare (double sample_rate)
 Sizes the lookahead ring for the worst case in the declared range.
void reset ()
 Zeroes the detector and the delay line. Never allocates.
void set_threshold_db (double db)
void set_ratio (double r)
 Positive compression ratio, used when negative-ratio mode is off.
void set_negative_ratio_mode (bool enabled)
 "Infinity+": lets the static curve run with a NEGATIVE ratio, so output keeps falling as input rises past the knee.
void set_neg_ratio_amount (double r)
 The ratio used when negative-ratio mode is on.
void set_knee_db (double db)
 0 = hard knee; > 0 = OverEasy-style soft knee, total width in dB (±width/2 around threshold).
void set_time_ms (double ms)
 THE time control — one knob for both directions.
void set_attack_release_ratio_k (double k)
 The fixed attack/release lock.
void set_makeup_db (double db)
void set_lookahead_ms (double ms)
 Clamped to the ceiling prepare() sized for, so this can never need an allocation.
void set_mix (double mix01)
 Dry/wet.
void set_ceiling_db (double db)
int latency_samples () const noexcept
 The module's entire latency contribution: the lookahead delay, exactly.
double static_curve_db (double input_db) const
 The static characteristic's output level for an input level, in dB — the gain computer alone, memoryless, with no detector in front of it.
double gain_computer_db (double input_db) const
 Gain reduction in dB (SIGNED, ≤ 0 — see the file doc block) the static curve commands at input_db, after the −ceiling_db floor.
double gain_computer_unclamped_db (double input_db) const
 The same value UNCLAMPED, so a test can show where the floor engages and where it does not.
double active_ratio () const noexcept
 The ratio currently in force: the negative amount in "infinity+" mode, the positive ratio otherwise.
double gain_reduction_db () const noexcept
 Metering taps, as of the last processed sample.
GainReduction gain_reduction () const noexcept
double level_db () const noexcept
double mean_square () const noexcept
double current_gain_linear () const noexcept
double attack_coef () const noexcept
 The detector's two one-pole coefficients, in the a of y += a·(x − y) convention of units::ms_to_onepole_coef.
double release_coef () const noexcept
SampleType process (SampleType input)
void process_block (SampleType *io, int n)

Static Public Attributes

static constexpr double kFloorLinear = 1e-12
 Mean-square floor, guarding log10(0) and the denormal range on the detector's recursive state.
static constexpr double kRatioKDefault = 4.0
 The attack/release LOCK: release τ = k · attack τ.
static constexpr double kRatioKMin = 2.0
static constexpr double kRatioKMax = 8.0
static constexpr double kThresholdDbMin = -60.0
static constexpr double kThresholdDbMax = 0.0
static constexpr double kRatioMin = 1.0
static constexpr double kRatioMax = 20.0
static constexpr double kNegRatioMin = -20.0
static constexpr double kNegRatioMax = -1.0
static constexpr double kKneeDbMin = 0.0
static constexpr double kKneeDbMax = 24.0
static constexpr double kTimeMsMin = 1.0
static constexpr double kTimeMsMax = 500.0
static constexpr double kMakeupDbMax = 24.0
static constexpr double kLookaheadMsMax = 10.0
static constexpr double kCeilingDbDefault = 96.0
 Depth beyond which further gain reduction is not applied, as a POSITIVE magnitude; the clamp is −ceiling_db.
static constexpr double kCeilingDbMin = 60.0
static constexpr double kCeilingDbMax = 144.0

Detailed Description

template<typename SampleType = float>
class pulp::signal::VcaCompressorT< SampleType >

True-RMS, log-domain, single-time-constant feedforward compressor.

Member Function Documentation

◆ active_ratio()

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::active_ratio ( ) const
inlinenoexcept

The ratio currently in force: the negative amount in "infinity+" mode, the positive ratio otherwise.

◆ attack_coef()

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::attack_coef ( ) const
inlinenoexcept

The detector's two one-pole coefficients, in the a of y += a·(x − y) convention of units::ms_to_onepole_coef.

Exposed because the ballistics ratio is the module's defining claim, and a test that recomputes the coefficients itself would be agreeing with its own arithmetic instead of checking the wiring.

◆ current_gain_linear()

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::current_gain_linear ( ) const
inlinenoexcept

◆ gain_computer_db()

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::gain_computer_db ( double input_db) const
inline

Gain reduction in dB (SIGNED, ≤ 0 — see the file doc block) the static curve commands at input_db, after the −ceiling_db floor.

◆ gain_computer_unclamped_db()

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::gain_computer_unclamped_db ( double input_db) const
inline

The same value UNCLAMPED, so a test can show where the floor engages and where it does not.

Not part of the audio path.

◆ gain_reduction()

template<typename SampleType = float>
GainReduction pulp::signal::VcaCompressorT< SampleType >::gain_reduction ( ) const
inlinenoexcept

◆ gain_reduction_db()

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::gain_reduction_db ( ) const
inlinenoexcept

Metering taps, as of the last processed sample.

◆ latency_samples()

template<typename SampleType = float>
int pulp::signal::VcaCompressorT< SampleType >::latency_samples ( ) const
inlinenoexcept

The module's entire latency contribution: the lookahead delay, exactly.

The detector and gain computer are zero-latency, so this is 0 at the default 0 ms lookahead (series law 5). Integer samples, no fractional interpolation, so the figure is exact rather than nominal.

◆ level_db()

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::level_db ( ) const
inlinenoexcept

◆ mean_square()

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::mean_square ( ) const
inlinenoexcept

◆ prepare()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::prepare ( double sample_rate)
inline

Sizes the lookahead ring for the worst case in the declared range.

May allocate; it is the only call that does, which is what makes set_lookahead_ms() audio-thread safe.

◆ process()

template<typename SampleType = float>
SampleType pulp::signal::VcaCompressorT< SampleType >::process ( SampleType input)
inline

◆ process_block()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::process_block ( SampleType * io,
int n )
inline

◆ release_coef()

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::release_coef ( ) const
inlinenoexcept

◆ reset()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::reset ( )
inline

Zeroes the detector and the delay line. Never allocates.

◆ set_attack_release_ratio_k()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::set_attack_release_ratio_k ( double k)
inline

The fixed attack/release lock.

Advanced: exposed so the house calibration table can tune the asymmetry, not as a performance control.

◆ set_ceiling_db()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::set_ceiling_db ( double db)
inline

◆ set_knee_db()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::set_knee_db ( double db)
inline

0 = hard knee; > 0 = OverEasy-style soft knee, total width in dB (±width/2 around threshold).

◆ set_lookahead_ms()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::set_lookahead_ms ( double ms)
inline

Clamped to the ceiling prepare() sized for, so this can never need an allocation.

◆ set_makeup_db()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::set_makeup_db ( double db)
inline

◆ set_mix()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::set_mix ( double mix01)
inline

Dry/wet.

1 = fully compressed (series compression); below 1 blends the EQUALLY DELAYED dry signal, so the mix cannot comb-filter.

◆ set_neg_ratio_amount()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::set_neg_ratio_amount ( double r)
inline

The ratio used when negative-ratio mode is on.

Kept separate from set_ratio() so flipping the mode does not destroy the positive setting the user was on, and so neither setter needs a sign-dependent clamp.

◆ set_negative_ratio_mode()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::set_negative_ratio_mode ( bool enabled)
inline

"Infinity+": lets the static curve run with a NEGATIVE ratio, so output keeps falling as input rises past the knee.

Honest gap: no citable primary literature parameterises this. It is an original creative mode — the same continuous gain computer, evaluated at R < 0 and floored by ceiling_db — not a modelled circuit.

◆ set_ratio()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::set_ratio ( double r)
inline

Positive compression ratio, used when negative-ratio mode is off.

◆ set_threshold_db()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::set_threshold_db ( double db)
inline

◆ set_time_ms()

template<typename SampleType = float>
void pulp::signal::VcaCompressorT< SampleType >::set_time_ms ( double ms)
inline

THE time control — one knob for both directions.

Sets the release time constant directly; attack is time_ms / k.

◆ static_curve_db()

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::static_curve_db ( double input_db) const
inline

The static characteristic's output level for an input level, in dB — the gain computer alone, memoryless, with no detector in front of it.

Exposed so a caller or a test can evaluate the curve directly. The negative-ratio mode passes a NEGATIVE ratio straight through: the shared equation is continuous across the sign, so "infinity+" needs no branch of its own — only the −ceiling_db floor that gain_computer_db() applies below.

Member Data Documentation

◆ kCeilingDbDefault

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kCeilingDbDefault = 96.0
staticconstexpr

Depth beyond which further gain reduction is not applied, as a POSITIVE magnitude; the clamp is −ceiling_db.

Without it the negative-ratio mode's curve is unbounded below. 96 dB is deeper than the noise floor of any programme this will meet, so the clamp is inaudible where it is not wanted and finite where it is. [design parameter] default 96 dB, range 60 .. 144 dB.

◆ kCeilingDbMax

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kCeilingDbMax = 144.0
staticconstexpr

◆ kCeilingDbMin

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kCeilingDbMin = 60.0
staticconstexpr

◆ kFloorLinear

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kFloorLinear = 1e-12
staticconstexpr

Mean-square floor, guarding log10(0) and the denormal range on the detector's recursive state.

1e-12 is −120 dB in power, far below any signal power the detector meets in practice, so it never clips a legitimate low level; the top of the range is still ~30 dB under the quietest audibly relevant level, so raising it inside the range guards harder without masking signal. [design parameter, internal — not a catalog parameter] default 1e-12, range 1e-15 .. 1e-9.

◆ kKneeDbMax

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kKneeDbMax = 24.0
staticconstexpr

◆ kKneeDbMin

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kKneeDbMin = 0.0
staticconstexpr

◆ kLookaheadMsMax

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kLookaheadMsMax = 10.0
staticconstexpr

◆ kMakeupDbMax

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kMakeupDbMax = 24.0
staticconstexpr

◆ kNegRatioMax

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kNegRatioMax = -1.0
staticconstexpr

◆ kNegRatioMin

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kNegRatioMin = -20.0
staticconstexpr

◆ kRatioKDefault

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kRatioKDefault = 4.0
staticconstexpr

The attack/release LOCK: release τ = k · attack τ.

One control sets both directions in a fixed ratio, which is the architectural claim of this lineage (see the file doc block). Honest gap: no published number exists for a reference Blackmer asymmetry ratio, so this is original engineering — an advanced constant, not a knob users are expected to reach for. [design parameter] default 4.0, range 2 .. 8.

◆ kRatioKMax

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kRatioKMax = 8.0
staticconstexpr

◆ kRatioKMin

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kRatioKMin = 2.0
staticconstexpr

◆ kRatioMax

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kRatioMax = 20.0
staticconstexpr

◆ kRatioMin

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kRatioMin = 1.0
staticconstexpr

◆ kThresholdDbMax

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kThresholdDbMax = 0.0
staticconstexpr

◆ kThresholdDbMin

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kThresholdDbMin = -60.0
staticconstexpr

◆ kTimeMsMax

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kTimeMsMax = 500.0
staticconstexpr

◆ kTimeMsMin

template<typename SampleType = float>
double pulp::signal::VcaCompressorT< SampleType >::kTimeMsMin = 1.0
staticconstexpr

The documentation for this class was generated from the following file: