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

Log-domain feedforward compressor with a soft-knee gain computer. More...

#include <feedforward_compressor.hpp>

Public Types

using Detector = CompressorDetector

Public Member Functions

void prepare (double sample_rate, double max_lookahead_ms=10.0)
 Sizes the lookahead ring buffer for the worst case.
void reset ()
 Zeroes detector state and the lookahead buffer. Never allocates.
void set_threshold_db (double db)
void set_ratio (double r)
void set_knee_width_db (double w)
void set_attack_ms (double ms)
void set_release_ms (double ms)
void set_detector (Detector d)
Detector detector () const
void set_rms_window_ms (double ms)
void set_lookahead_ms (double ms)
 Lookahead in ms, clamped to the ceiling prepare() sized for — so this can never need an allocation.
void set_program_dependent_release (bool on)
void set_makeup_gain_db (double db)
void set_auto_makeup (bool on)
void set_stereo_link (double amount)
 0 = fully independent per-channel detectors, 1 = one shared detector fed by the louder channel.
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 for an input level in dB — the gain computer alone, with no smoothing.
double gain_computer_db (double input_db) const
 Gain reduction in dB (≤ 0) the static curve applies at input_db.
double effective_makeup_db () const
 Makeup gain currently in force, in dB — the auto value when auto-makeup is on, the manual value otherwise.
double gain_reduction_db (int channel=0) const
 Smoothed gain reduction in dB (≥ 0, a magnitude) as of the last processed sample.
GainReduction gain_reduction (int channel=0) const noexcept
 Canonical non-negative gain-reduction magnitude for shared meters.
SampleType process (SampleType input)
 One mono sample.
void process_stereo (SampleType &left, SampleType &right)
 One stereo pair, in place.
void process_block (SampleType *io, int n)
void process_block_stereo (SampleType *left, SampleType *right, int n)

Static Public Attributes

static constexpr double kLevelEpsilon = dynamics::kLevelEpsilon
 Level-conversion floor, guarding log10(0).
static constexpr double kSlowReleaseRatio = 4.0
 Slow/fast release ratio for program-dependent release.
static constexpr double kSustainTauMs = 200.0
 Smoothing constant of the "has compression been sustained" detector.
static constexpr double kSustainThresholdDb = 3.0
 How much gain reduction counts as sustained.
static constexpr double kThresholdDbMin = -60.0
static constexpr double kThresholdDbMax = 0.0
static constexpr double kRatioMin = 1.0
static constexpr double kRatioMax = 100.0
static constexpr double kKneeDbMin = 0.0
static constexpr double kKneeDbMax = 24.0
static constexpr double kAttackMsMin = 0.05
static constexpr double kAttackMsMax = 200.0
static constexpr double kReleaseMsMin = 5.0
static constexpr double kReleaseMsMax = 4000.0
static constexpr double kRmsWindowMsMin = 1.0
static constexpr double kRmsWindowMsMax = 50.0
static constexpr double kMakeupDbMax = 24.0
static constexpr double kMaxLookaheadMsCeiling = 50.0
 Ceiling on prepare()'s max_lookahead_ms argument.

Detailed Description

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

Log-domain feedforward compressor with a soft-knee gain computer.

Member Typedef Documentation

◆ Detector

template<typename SampleType = float>
using pulp::signal::FeedforwardCompressorT< SampleType >::Detector = CompressorDetector

Member Function Documentation

◆ detector()

template<typename SampleType = float>
Detector pulp::signal::FeedforwardCompressorT< SampleType >::detector ( ) const
inline

◆ effective_makeup_db()

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::effective_makeup_db ( ) const
inline

Makeup gain currently in force, in dB — the auto value when auto-makeup is on, the manual value otherwise.

◆ gain_computer_db()

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

Gain reduction in dB (≤ 0) the static curve applies at input_db.

◆ gain_reduction()

template<typename SampleType = float>
GainReduction pulp::signal::FeedforwardCompressorT< SampleType >::gain_reduction ( int channel = 0) const
inlinenoexcept

Canonical non-negative gain-reduction magnitude for shared meters.

◆ gain_reduction_db()

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::gain_reduction_db ( int channel = 0) const
inline

Smoothed gain reduction in dB (≥ 0, a magnitude) as of the last processed sample.

Exposed for metering and for tests that measure the detector rather than inferring it from the audio.

◆ latency_samples()

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

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

The gain computer and detector are zero-latency IIR stages, so this is 0 at the default 0 ms lookahead (series law 5).

◆ prepare()

template<typename SampleType = float>
void pulp::signal::FeedforwardCompressorT< SampleType >::prepare ( double sample_rate,
double max_lookahead_ms = 10.0 )
inline

Sizes the lookahead ring buffer for the worst case.

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

◆ process()

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

One mono sample.

◆ process_block()

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

◆ process_block_stereo()

template<typename SampleType = float>
void pulp::signal::FeedforwardCompressorT< SampleType >::process_block_stereo ( SampleType * left,
SampleType * right,
int n )
inline

◆ process_stereo()

template<typename SampleType = float>
void pulp::signal::FeedforwardCompressorT< SampleType >::process_stereo ( SampleType & left,
SampleType & right )
inline

One stereo pair, in place.

Reads both channels before writing either, which the link path requires.

◆ reset()

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

Zeroes detector state and the lookahead buffer. Never allocates.

◆ set_attack_ms()

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

◆ set_auto_makeup()

template<typename SampleType = float>
void pulp::signal::FeedforwardCompressorT< SampleType >::set_auto_makeup ( bool on)
inline

◆ set_detector()

template<typename SampleType = float>
void pulp::signal::FeedforwardCompressorT< SampleType >::set_detector ( Detector d)
inline

◆ set_knee_width_db()

template<typename SampleType = float>
void pulp::signal::FeedforwardCompressorT< SampleType >::set_knee_width_db ( double w)
inline

◆ set_lookahead_ms()

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

Lookahead in ms, clamped to the ceiling prepare() sized for — so this can never need an allocation.

◆ set_makeup_gain_db()

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

◆ set_program_dependent_release()

template<typename SampleType = float>
void pulp::signal::FeedforwardCompressorT< SampleType >::set_program_dependent_release ( bool on)
inline

◆ set_ratio()

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

◆ set_release_ms()

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

◆ set_rms_window_ms()

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

◆ set_stereo_link()

template<typename SampleType = float>
void pulp::signal::FeedforwardCompressorT< SampleType >::set_stereo_link ( double amount)
inline

0 = fully independent per-channel detectors, 1 = one shared detector fed by the louder channel.

◆ set_threshold_db()

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

◆ static_curve_db()

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

The static characteristic's output for an input level in dB — the gain computer alone, with no smoothing.

Exposed so a caller (or a test) can plot the curve without running audio through it.

Member Data Documentation

◆ kAttackMsMax

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::kAttackMsMax = 200.0
staticconstexpr

◆ kAttackMsMin

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::kAttackMsMin = 0.05
staticconstexpr

◆ kKneeDbMax

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

◆ kKneeDbMin

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

◆ kLevelEpsilon

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::kLevelEpsilon = dynamics::kLevelEpsilon
staticconstexpr

Level-conversion floor, guarding log10(0).

Declared in dynamics_core.hpp alongside the conversions that consume it, and re-exported here so the call sites and the catalog keep reading one name.

◆ kMakeupDbMax

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

◆ kMaxLookaheadMsCeiling

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::kMaxLookaheadMsCeiling = 50.0
staticconstexpr

Ceiling on prepare()'s max_lookahead_ms argument.

[design parameter] default 10 ms, range 0 .. 50 ms.

◆ kRatioMax

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::kRatioMax = 100.0
staticconstexpr

◆ kRatioMin

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

◆ kReleaseMsMax

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::kReleaseMsMax = 4000.0
staticconstexpr

◆ kReleaseMsMin

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::kReleaseMsMin = 5.0
staticconstexpr

◆ kRmsWindowMsMax

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::kRmsWindowMsMax = 50.0
staticconstexpr

◆ kRmsWindowMsMin

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::kRmsWindowMsMin = 1.0
staticconstexpr

◆ kSlowReleaseRatio

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::kSlowReleaseRatio = 4.0
staticconstexpr

Slow/fast release ratio for program-dependent release.

Honest gap: no citable literature specifies this for a general algorithm — every hardware unit's constants are proprietary. Original engineering, tuned for a musically smooth transition. [design parameter] default 4.0, range 2 .. 8.

◆ kSustainTauMs

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::kSustainTauMs = 200.0
staticconstexpr

Smoothing constant of the "has compression been sustained" detector.

[design parameter] default 200 ms, range 50 .. 1000 ms.

◆ kSustainThresholdDb

template<typename SampleType = float>
double pulp::signal::FeedforwardCompressorT< SampleType >::kSustainThresholdDb = 3.0
staticconstexpr

How much gain reduction counts as sustained.

[design parameter] default 3 dB, range 1 .. 12 dB.

◆ kThresholdDbMax

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

◆ kThresholdDbMin

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

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