DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
dspark::Compressor< T > Class Template Reference

High-fidelity modular compressor designed for real-time applications. More...

#include <Compressor.h>

Collaboration diagram for dspark::Compressor< T >:

Classes

struct  FeedbackLaw
 Element law result: static target (dB, <= 0) and its |slope|. More...
 
struct  FeedbackSolve
 Semi-implicit solve result: stepped gain and the law's target. More...
 

Public Types

enum class  DetectorType {
  Peak , Rms , TruePeak , SplitPolarity ,
  Hilbert
}
 Level detection methodologies. More...
 
enum class  Topology { FeedForward , FeedBack }
 Signal routing topology for the detector sidechain. More...
 
enum class  Character { Clean , Opto , FET , Varimu }
 Time-constant behavior and release curve shape. More...
 
enum class  Mode { Downward , Upward }
 Processing direction. More...
 
enum class  AutoMakeupMode { Off , Static , Adaptive }
 Automatic makeup-gain behavior (applies in Downward mode). More...
 

Public Member Functions

 ~Compressor ()=default
 
void prepare (const AudioSpec &spec)
 Allocates buffers and initializes internal DSP state.
 
void prepare (double sampleRate) noexcept
 Prepares the compressor using sample rate only (backward compatibility).
 
void processBlock (AudioBufferView< T > buffer) noexcept
 Processes an audio buffer in-place using its own signal as the sidechain.
 
void processBlock (AudioBufferView< T > audio, AudioBufferView< T > sidechain) noexcept
 Processes audio with an independent external sidechain.
 
processSample (T input, int channel) noexcept
 Processes a single sample on one channel.
 
void reset () noexcept
 Resets all internal DSP history, states, and buffers to neutral.
 
void setThreshold (T dB) noexcept
 Sets the compression threshold in dB.
 
void setRatio (T ratio) noexcept
 Sets the compression ratio (1.0 = off, >20.0 = limiting).
 
void setAttack (T ms) noexcept
 Sets the attack time in milliseconds.
 
void setRelease (T ms) noexcept
 Sets the release time in milliseconds (clamped to >= 1 ms: below that the envelope stops smoothing at all and the gain path degenerates into a waveshaper).
 
void setKnee (T dB) noexcept
 Sets knee width in dB (0 = hard knee, >0 = soft knee).
 
void setMakeupGain (T dB) noexcept
 Sets manual static makeup gain in dB.
 
void setAutoMakeup (AutoMakeupMode mode) noexcept
 Selects the automatic makeup behavior (default: Off).
 
void setAutoMakeup (bool on) noexcept
 Convenience overload: true selects Adaptive, false turns auto makeup off.
 
void setMode (Mode mode) noexcept
 Sets processing mode (Downward or Upward compression).
 
void setStereoLink (T amount) noexcept
 Sets stereo linking amount (0.0 = unlinked dual mono, 1.0 = fully linked).
 
void setMix (T dryWet) noexcept
 Sets dry/wet balance for parallel (New York) compression (1.0 = fully wet).
 
void setLookahead (T ms) noexcept
 Sets lookahead time in ms (0 = off, max = 10ms).
 
void setDetector (DetectorType type) noexcept
 Changes the level detection algorithm (Peak, RMS, TruePeak, Hilbert).
 
void setHoldTime (T ms) noexcept
 Sets the gain-reduction hold time.
 
void setRange (T dB) noexcept
 Limits the maximum gain change the compressor may apply.
 
void setTopology (Topology topo) noexcept
 Changes signal routing topology (FeedForward or FeedBack).
 
void setCharacter (Character type) noexcept
 Changes ballistics and envelope behavior character.
 
void setCharacterColor (T amount) noexcept
 Sets the amount of the character's harmonic signature (0 to 1).
 
getCharacterColor () const noexcept
 Returns the character colour amount (see setCharacterColor).
 
void setSidechainHPF (bool enabled, T cutoffHz=T(80)) noexcept
 Toggles the internal sidechain high-pass filter.
 
void setRmsWindow (T ms) noexcept
 Sets the RMS analysis window size in milliseconds.
 
getGainReductionDb () const noexcept
 Returns current active gain reduction in dB (negative value).
 
DetectorType getDetector () const noexcept
 Returns the currently active detector type.
 
Topology getTopology () const noexcept
 Returns the currently active topology.
 
Character getCharacter () const noexcept
 Returns the currently active character.
 
int getLatency () const noexcept
 Returns total processing latency in samples.
 
std::vector< uint8_t > getState () const
 Serializes the parameter state (setup/UI threads; allocates).
 
bool setState (const uint8_t *data, size_t size)
 Restores parameters from a blob (tolerant; rejects foreign ids).
 

Protected Member Functions

void processBlockImpl (AudioBufferView< T > audio, AudioBufferView< T > sidechain) noexcept
 Core DSP loop executing sidechain detection, linking, ballistics, and gain application.
 
void updateTimeConstants (T fs) noexcept
 Pre-calculates recursive exponential decay coefficients.
 
applyHoldAndRange (T targetGR_Db, int ch) noexcept
 Applies the hold and range stages to the static gain target (dB).
 
detectLevel (T sample, int ch, DetectorType detType) noexcept
 Computes level detection in Decibels.
 
computeGain (T inputDb, T thresh, T ratio, T knee, Character charType, Mode modeType, T guardDb) const noexcept
 Calculates static target gain reduction based on knee and ratio.
 
computeGainUpward (T inputDb, T thresh, T ratio, T knee, T guardDb) const noexcept
 Upward compression curve calculation.
 
FeedbackLaw computeGainFeedback (T outDb, T thresh, T ratio, T knee, Character charType) const noexcept
 Feedback target for detectors with memory (explicit path).
 
FeedbackSolve solveFeedbackGain (T inDb, T k, T effB, T thresh, T ratio, T knee, Character charType) const noexcept
 Solves one feedback ballistics step against the current input.
 
applyBallisticsFeedbackImplicit (T inDb, int ch, Character charType, T thresh, T ratio, T knee) noexcept
 Feedback ballistics with the loop resolved semi-implicitly.
 
applyBallistics (T targetGrDb, int ch, bool splitAdaptive, T loopSlope=T(0)) noexcept
 Smooths the static gain target with the active character's ballistics.
 
void updateHpfCoefficients () noexcept
 Updates the normalized DC-blocker / High-pass filter coefficients.
 
applySidechainHPF (T input, int ch) noexcept
 Applies sidechain filtering for a specific channel.
 
void updateRmsWindow () noexcept
 Safely recalculates the RMS window size ensuring zero heap allocations.
 

Static Protected Member Functions

template<typename E >
static E clampEnum (E value, E last) noexcept
 Clamps an enum to its valid [first, last] range.
 
static T effectiveRatioFor (Character charType, T ratio, T excessDb) noexcept
 Level-dependent effective ratio of the character (Varimu grows).
 
static T effectiveKneeFor (Character charType, T knee) noexcept
 Physical knee floor of the character (dB).
 
static FeedbackLaw elementLaw (T eOut, T r, T w) noexcept
 Downward element law for feedback detection, per output level.
 

Protected Attributes

AudioSpec spec_ {}
 Active audio environment specification.
 
double sampleRate_ = 0
 Cached operating sample rate.
 
std::atomic< T > threshold_ { T(-20) }
 Threshold in dB.
 
std::atomic< T > ratio_ { T(4) }
 Ratio (e.g., 4 = 4:1).
 
std::atomic< T > attackMs_ { T(5) }
 Attack time in milliseconds.
 
std::atomic< T > releaseMs_ { T(100) }
 Release time in milliseconds.
 
std::atomic< T > kneeWidth_ { T(0) }
 Knee width in dB.
 
std::atomic< T > makeupGain_ { T(0) }
 Static makeup gain in dB.
 
std::atomic< T > stereoLink_ { T(1) }
 Stereo linking amount (0 to 1).
 
std::atomic< T > mix_ { T(1) }
 Wet/Dry mix (1 = full wet).
 
std::atomic< T > lookaheadMs_ { T(0) }
 Lookahead latency target in ms.
 
std::atomic< T > characterColor_ { T(0) }
 Character harmonic amount (0 to 1).
 
std::atomic< AutoMakeupModeautoMakeupMode_ { AutoMakeupMode::Off }
 Auto-makeup behavior.
 
std::atomic< DetectorTypedetectorType_ { DetectorType::Peak }
 Selected detection method.
 
std::atomic< Topologytopology_ { Topology::FeedForward }
 Selected topology.
 
std::atomic< Charactercharacter_ { Character::Clean }
 Selected ballistics.
 
std::atomic< Modemode_ { Mode::Downward }
 Selected compression mode.
 
autoMakeupCoeff_ = T(0.9995)
 Auto-makeup tracking factor.
 
autoMakeupEnv_ = T(0)
 Smoothed internal auto-makeup envelope.
 
std::atomic< bool > timeConstantsDirty_ { true }
 Coefficients need a recompute.
 
charAttCoeff_ = T(0)
 Attack coefficient of the fast envelope.
 
charRelCoeff_ = T(0)
 Release coefficient (fast stage).
 
charSlowRelCoeff_ = T(0)
 Release coefficient of the memory stage.
 
charChargeCoeff_ = T(0)
 History charge coefficient of the memory stage.
 
charFastWeight_ = T(1)
 Fast/slow blend (1 = single envelope).
 
SmoothedValue< T > thresholdSmooth_
 De-zippered threshold.
 
SmoothedValue< T > ratioSmooth_
 De-zippered ratio.
 
SmoothedValue< T > kneeSmooth_
 De-zippered knee.
 
SmoothedValue< T > makeupSmooth_
 De-zippered makeup gain (dB).
 
SmoothedValue< T > mixSmooth_
 De-zippered parallel mix.
 
SmoothedValue< T > colorSmooth_
 De-zippered character colour amount.
 
fetDcCoeff_ = T(0)
 ~10 Hz DC-tracking coefficient.
 
std::array< T, kMaxChannelsfetDcState_ {}
 Per-channel DC estimate of wet^2.
 
std::array< T, kMaxChannelsenvFastDb_ {}
 Fast gain envelope per channel (dB).
 
std::array< T, kMaxChannelsenvSlowDb_ {}
 Slow memory envelope per channel (dB).
 
std::array< T, kMaxChannelsupwardGuardDb_ {}
 Peak-held sustained level (Upward guard).
 
upwardGuardDecay_ = T(0.00125)
 Guard decay per sample (60 dB/s).
 
std::array< T, kMaxChannelsfbLastOutput_ {}
 Feedback topology history buffer.
 
std::array< T, kMaxChannelschannelLevelDb_ {}
 Raw detected level buffer.
 
std::array< RingBuffer< T >, kMaxChannelslookaheadBuffers_ {}
 Lookahead delay lines.
 
int lookaheadSamples_ = 0
 Active lookahead latency in samples.
 
std::array< Hilbert< T >, kMaxChannelshilbertDetectors_ {}
 Analytic signal generators for detection.
 
std::atomic< bool > scHpfEnabled_ { false }
 HPF toggle.
 
std::atomic< T > scHpfFreq_ { T(80) }
 HPF Cutoff frequency.
 
scHpfB1_ = T(0)
 HPF internal feedback coefficient.
 
scHpfA0_ = T(0)
 HPF normalized feedforward coefficient.
 
std::array< T, kMaxChannelsscHpfState_ {}
 HPF y[n-1] state.
 
std::array< T, kMaxChannelsscHpfPrev_ {}
 HPF x[n-1] state.
 
std::array< T, kMaxChannelssplitPosEnv_ {}
 Positive half-wave tracking.
 
std::array< T, kMaxChannelssplitNegEnv_ {}
 Negative half-wave tracking.
 
splitDetAttCoeff_ = T(0.6)
 Detector attack coefficient (sample-rate derived).
 
splitDetRelCoeff_ = T(0.99)
 Detector release coefficient (sample-rate derived).
 
rmsWindowMs_ = T(10)
 Active RMS length in ms (audio-thread copy).
 
std::atomic< T > rmsWindowMsAtomic_ { T(10) }
 Control-thread published target.
 
std::atomic< bool > rmsWindowDirty_ { false }
 Applied at the next block.
 
int rmsWindowSamples_ = 0
 Active RMS length in samples.
 
std::array< std::vector< T >, kMaxChannelsrmsBuffers_
 Pre-allocated RMS sliding windows.
 
std::array< T, kMaxChannelsrmsSums_ {}
 Running sums for RMS.
 
std::array< int, kMaxChannelsrmsIndices_ {}
 Write heads for RMS buffers.
 
std::array< int, kMaxChannelsrmsRecomputeCounters_ {}
 Re-summation counters.
 
TruePeakDetector< T, kMaxChannelstruePeak_
 
std::atomic< T > holdMs_ { T(0) }
 Gain-hold time in ms (0 = off).
 
std::atomic< T > rangeDb_ { T(100) }
 Max |gain change| in dB.
 
int holdSamples_ = 0
 
std::array< int, kMaxChannelsholdCounters_ {}
 
std::array< T, kMaxChannelsheldGrDb_ {}
 
std::atomic< T > gainReductionDb_ { T(0) }
 Publicly readable Gain Reduction meter.
 

Static Protected Attributes

static constexpr int kMaxChannels = 16
 
static constexpr T kFetColorH2 = T(0.028)
 
static constexpr int kRmsRecomputePeriod = 4096
 Re-summation interval to halt drift.
 

Detailed Description

template<FloatType T>
class dspark::Compressor< T >

High-fidelity modular compressor designed for real-time applications.

This class avoids virtual dispatch entirely by utilizing branch-predicted enum switches on pre-cached atomic states. Parameter changes are internally smoothed to prevent audio artifacts. Processing is strictly allocation-free after the initial prepare() call.

Note
The gain path runs at the host rate on purpose: worst-case gain-modulation aliasing measures <= -72 dBc (FET character at its minimum attack), inaudible on real material. Products that oversample a nonlinear section can wrap this compressor in that section like any other stage with Core/Oversampling: one resampler for the whole section instead of one per module (see docs/cookbook.md, "Oversampling a nonlinear section").
Template Parameters
TFloating-point sample type (float or double).

Definition at line 87 of file Compressor.h.

Member Enumeration Documentation

◆ AutoMakeupMode

template<FloatType T>
enum class dspark::Compressor::AutoMakeupMode
strong

Automatic makeup-gain behavior (applies in Downward mode).

Enumerator
Off 

Manual makeup only (setMakeupGain).

Static 

Textbook auto makeup: a constant offset equal to half the static gain reduction of a 0 dBFS signal, derived from the (smoothed) threshold/ratio/knee. No program dependence.

Adaptive 

Loudness matching: tracks the smoothed gain reduction (~300 ms) and compensates it in full, keeping the average output level matched to the input (quiet passages are lifted).

Definition at line 168 of file Compressor.h.

◆ Character

template<FloatType T>
enum class dspark::Compressor::Character
strong

Time-constant behavior and release curve shape.

All characters smooth the gain reduction in dB (log domain), so attack and release knobs read as the t63 time constant of the dB envelope.

Enumerator
Clean 

Smoothed branching one-pole in the log domain (modern transparent design): constant dB-per-second ballistics, knobs mean what they say.

Opto 

T4 optical cell model (LA-2A lineage), calibrated to the Teletronix spec: ~50% recovers in one release time (the spec's "0.06 s to 50%" is release = 60 ms), complete release 0.5-5 s depending on how long the compressor was engaged (the slow memory stage only charges under sustained compression), and a 10 ms attack floor (the cell's published attack time). The knee has the same 10 dB physical floor as Varimu: a photocell's resistance curve is gradual and cannot form a hard corner.

FET 

1176 lineage. Always detects in FeedBack topology with the hardware's peak rectifier (the Topology and Detector settings are ignored and lookahead is unavailable while selected). Attack clamps to the hardware range 0.02-0.8 ms and release to 50-1100 ms; release is two-stage with a program-dependent slow tail (~t63 at the knob value). The panel ratio is the observed curve, like the hardware: 4/8 compress, 12/20 limit. setCharacterColor() adds the FET's 2nd-order channel-modulation harmonics, calibrated at 1.0 to the 1176 THD spec (< 0.5% while limiting).

Varimu 

Variable-mu tube lineage (Fairchild). The effective ratio grows with level above the threshold and the knee has a 10 dB floor (a remote-cutoff tube cannot produce a hard corner). Log-domain ballistics with the user's time constants.

Definition at line 126 of file Compressor.h.

◆ DetectorType

template<FloatType T>
enum class dspark::Compressor::DetectorType
strong

Level detection methodologies.

Enumerator
Peak 

Instantaneous absolute value tracking. Fast and standard.

Rms 

Sliding-window Root-Mean-Square. Smoother, responds to average energy.

TruePeak 

4x oversampled peak detection (ITU-R BS.1770-4 compliant).

SplitPolarity 

Asymmetric positive/negative half-wave tracking (ButterComp2 style).

Hilbert 

Analytic-signal magnitude: ripple-free envelope (lowest THD on sustained material). The 191-tap FIR detects ~95 samples late, so the audio path is delayed by the same amount to stay aligned with the gain (transients are caught; the delay is reported by getLatency()). Feedback operation keeps its loop causal, so the alignment delay is disabled there; processSample() (documented as lookahead-free) does not apply it either.

Definition at line 93 of file Compressor.h.

◆ Mode

template<FloatType T>
enum class dspark::Compressor::Mode
strong

Processing direction.

Enumerator
Downward 

Standard: Reduces dynamic range by attenuating signals above the threshold.

Upward 

Upward: Reduces dynamic range by boosting signals below the threshold. The boost fades out when the SUSTAINED level (peak-held, falling 60 dB/s) drops 40 to 60 dB below the threshold, so pauses and the noise floor are not amplified; setRange() bounds the boost.

Definition at line 158 of file Compressor.h.

◆ Topology

template<FloatType T>
enum class dspark::Compressor::Topology
strong

Signal routing topology for the detector sidechain.

Enumerator
FeedForward 

Detector reads uncompressed input (modern, precise, transparent).

FeedBack 

Detector reads compressed output (vintage, self-regulating, colored). The static curve still honours the panel values: the element's law is solved so the closed loop settles exactly on the requested ratio and knee, like the hardware whose panel markings reflect measured curves. External sidechain keys are ignored here (the detector is wired to the output).

Definition at line 109 of file Compressor.h.

Constructor & Destructor Documentation

◆ ~Compressor()

template<FloatType T>
dspark::Compressor< T >::~Compressor ( )
default

Member Function Documentation

◆ applyBallistics()

template<FloatType T>
T dspark::Compressor< T >::applyBallistics ( targetGrDb,
int  ch,
bool  splitAdaptive,
loopSlope = T(0) 
)
inlineprotectednoexcept

Smooths the static gain target with the active character's ballistics.

Operates on the gain change in dB. Clean/Varimu run a smoothed branching one-pole (attack while the gain moves away from unity, release while it recovers). Opto/FET blend a fast envelope with a slow one that charges with compression history, producing the two-stage program-dependent release of the modeled hardware: brief peaks release fast because the slow stage never charged, sustained compression leaves a long tail.

Parameters
targetGrDbStatic gain change target in dB (negative = reduction).
chChannel index.
splitAdaptiveTrue when the EFFECTIVE detector is SplitPolarity (the callers derive it once per block/sample: it must follow the detector actually in use, which the FET character overrides).
loopSlopeIncremental loop gain when driven from a feedback detector with memory (explicit loop): both coefficients get a stability floor, which caps the per-sample loop advance at 0.5 and keeps the one-sample-delay iteration from ringing at extreme ratio/time combinations. 0 = no loop (default).
Returns
The smoothed gain change in dB to apply.

Definition at line 1592 of file Compressor.h.

◆ applyBallisticsFeedbackImplicit()

template<FloatType T>
T dspark::Compressor< T >::applyBallisticsFeedbackImplicit ( inDb,
int  ch,
Character  charType,
thresh,
ratio,
knee 
)
inlineprotectednoexcept

Feedback ballistics with the loop resolved semi-implicitly.

Runs the same branching envelopes as applyBallistics, but the step toward the target is solved simultaneously with the level the detector will read. Hold and range act on the OBSERVED gain after the step (see the inline note), and the memory stage tracks the real static curve.

Parameters
inDbInput level in dB (post link and sidechain filter).

Definition at line 1512 of file Compressor.h.

◆ applyHoldAndRange()

template<FloatType T>
T dspark::Compressor< T >::applyHoldAndRange ( targetGR_Db,
int  ch 
)
inlineprotectednoexcept

Applies the hold and range stages to the static gain target (dB).

Hold keeps the deepest recent gain change for holdSamples_ before the ballistics may relax; range bounds |gain change| to the configured dB.

Definition at line 1160 of file Compressor.h.

◆ applySidechainHPF()

template<FloatType T>
T dspark::Compressor< T >::applySidechainHPF ( input,
int  ch 
)
inlineprotectednoexcept

Applies sidechain filtering for a specific channel.

Parameters
inputRaw sidechain sample.
chChannel index.
Returns
High-pass filtered sample.

Definition at line 1659 of file Compressor.h.

◆ clampEnum()

template<FloatType T>
template<typename E >
static E dspark::Compressor< T >::clampEnum ( value,
last 
)
inlinestaticprotectednoexcept

Clamps an enum to its valid [first, last] range.

Wild values (a cast integer, a corrupted state blob) would otherwise fall through every switch case: updateTimeConstants() would keep its zero-initialized coefficients (instant ballistics, i.e. a waveshaper) and the getters would report an impossible value.

Definition at line 839 of file Compressor.h.

◆ computeGain()

template<FloatType T>
T dspark::Compressor< T >::computeGain ( inputDb,
thresh,
ratio,
knee,
Character  charType,
Mode  modeType,
guardDb 
) const
inlineprotectednoexcept

Calculates static target gain reduction based on knee and ratio.

Parameters
inputDbDetected level in decibels.
threshThreshold parameter in dB.
ratioRatio parameter.
kneeSoft-knee width parameter in dB.
charTypeApplies the character's knee floor and ratio law.
modeTypeUpward or Downward processing mode.
Returns
Target gain reduction in Decibels.

Definition at line 1299 of file Compressor.h.

◆ computeGainFeedback()

template<FloatType T>
FeedbackLaw dspark::Compressor< T >::computeGainFeedback ( outDb,
thresh,
ratio,
knee,
Character  charType 
) const
inlineprotectednoexcept

Feedback target for detectors with memory (explicit path).

Varimu's level-dependent ratio is a function of the INPUT level, which a feedback detector does not see; two fixed-point passes reconstruct it from the output level (the law is smooth, so this lands well within 0.1 dB of the exact curve).

Parameters
outDbDetected output level (dB).

Definition at line 1427 of file Compressor.h.

◆ computeGainUpward()

template<FloatType T>
T dspark::Compressor< T >::computeGainUpward ( inputDb,
thresh,
ratio,
knee,
guardDb 
) const
inlineprotectednoexcept

Upward compression curve calculation.

The boost fades to zero when guardDb falls 40 to 60 dB below the threshold: without that guard, pauses and the noise floor (which the detector reads at its -100 dB floor) would receive the largest boost of all. guardDb is the peak-held sustained level, NOT the instantaneous one: gating on the instantaneous level would punch boost holes at every zero crossing of the waveform.

Definition at line 1339 of file Compressor.h.

◆ detectLevel()

template<FloatType T>
T dspark::Compressor< T >::detectLevel ( sample,
int  ch,
DetectorType  detType 
)
inlineprotectednoexcept

Computes level detection in Decibels.

Parameters
sampleInput sample.
chChannel index (for state tracking).
detTypeSelected detector methodology.
Returns
Decibel representation of detected level.

Definition at line 1196 of file Compressor.h.

◆ effectiveKneeFor()

template<FloatType T>
static T dspark::Compressor< T >::effectiveKneeFor ( Character  charType,
knee 
)
inlinestaticprotectednoexcept

Physical knee floor of the character (dB).

Definition at line 1280 of file Compressor.h.

◆ effectiveRatioFor()

template<FloatType T>
static T dspark::Compressor< T >::effectiveRatioFor ( Character  charType,
ratio,
excessDb 
)
inlinestaticprotectednoexcept

Level-dependent effective ratio of the character (Varimu grows).

Parameters
excessDbInput level above the threshold in dB.

Definition at line 1270 of file Compressor.h.

◆ elementLaw()

template<FloatType T>
static FeedbackLaw dspark::Compressor< T >::elementLaw ( eOut,
r,
w 
)
inlinestaticprotectednoexcept

Downward element law for feedback detection, per output level.

The detector reads the compressed output, so a raw feed-forward law in the loop settles far off the requested curve (its observed ratio can never pass 2:1). This is the closed-form inverse instead: gel(out) = grFF(in(out)), where in(out) inverts out = in + grFF(in). The settled loop then reproduces the user's static curve exactly. Piecewise: silence, quadratic knee (cancellation-free root), and a linear region of slope (R - 1), the classic loop gain that makes a feedback compressor observe ratio R.

Parameters
eOutDetected output level relative to the threshold (dB).
rEffective ratio (>= 1).
wEffective knee width (dB, >= 0).

Definition at line 1395 of file Compressor.h.

◆ getCharacter()

template<FloatType T>
Character dspark::Compressor< T >::getCharacter ( ) const
inlinenoexcept

Returns the currently active character.

Definition at line 737 of file Compressor.h.

◆ getCharacterColor()

template<FloatType T>
T dspark::Compressor< T >::getCharacterColor ( ) const
inlinenoexcept

Returns the character colour amount (see setCharacterColor).

Definition at line 685 of file Compressor.h.

◆ getDetector()

template<FloatType T>
DetectorType dspark::Compressor< T >::getDetector ( ) const
inlinenoexcept

Returns the currently active detector type.

Definition at line 731 of file Compressor.h.

◆ getGainReductionDb()

template<FloatType T>
T dspark::Compressor< T >::getGainReductionDb ( ) const
inlinenoexcept

Returns current active gain reduction in dB (negative value).

Definition at line 728 of file Compressor.h.

◆ getLatency()

template<FloatType T>
int dspark::Compressor< T >::getLatency ( ) const
inlinenoexcept

Returns total processing latency in samples.

Lookahead plus the Hilbert detector's alignment delay when that detector is active. Feedback operation (Topology::FeedBack, or the FET character, which always detects in feedback) disables both, so latency is 0 there. The plugin layer re-reads this after parameter changes and re-notifies the host when it moves.

Definition at line 748 of file Compressor.h.

◆ getState()

template<FloatType T>
std::vector< uint8_t > dspark::Compressor< T >::getState ( ) const
inline

Serializes the parameter state (setup/UI threads; allocates).

Definition at line 767 of file Compressor.h.

◆ getTopology()

template<FloatType T>
Topology dspark::Compressor< T >::getTopology ( ) const
inlinenoexcept

Returns the currently active topology.

Definition at line 734 of file Compressor.h.

◆ prepare() [1/2]

template<FloatType T>
void dspark::Compressor< T >::prepare ( const AudioSpec spec)
inline

Allocates buffers and initializes internal DSP state.

An invalid spec (non-positive/NaN sample rate or no channels) is ignored: the previous prepared state, if any, stays intact.

Warning
Must not be called from the audio thread. Allocates memory.
Parameters
specAudio environment specification (sample rate, block size, channels).

Definition at line 190 of file Compressor.h.

◆ prepare() [2/2]

template<FloatType T>
void dspark::Compressor< T >::prepare ( double  sampleRate)
inlinenoexcept

Prepares the compressor using sample rate only (backward compatibility).

Parameters
sampleRateThe operating sample rate.

Definition at line 252 of file Compressor.h.

◆ processBlock() [1/2]

template<FloatType T>
void dspark::Compressor< T >::processBlock ( AudioBufferView< T >  audio,
AudioBufferView< T >  sidechain 
)
inlinenoexcept

Processes audio with an independent external sidechain.

The detector analyzes the sidechain buffer, but gain reduction is applied to the audio buffer.

Parameters
audioAudio buffer to be compressed (modified in-place).
sidechainKey/Sidechain signal (read-only).

Definition at line 276 of file Compressor.h.

◆ processBlock() [2/2]

template<FloatType T>
void dspark::Compressor< T >::processBlock ( AudioBufferView< T >  buffer)
inlinenoexcept

Processes an audio buffer in-place using its own signal as the sidechain.

Parameters
bufferMutable reference to the audio block.

Definition at line 262 of file Compressor.h.

◆ processBlockImpl()

template<FloatType T>
void dspark::Compressor< T >::processBlockImpl ( AudioBufferView< T >  audio,
AudioBufferView< T >  sidechain 
)
inlineprotectednoexcept

Core DSP loop executing sidechain detection, linking, ballistics, and gain application.

No-op before prepare(). A sidechain view with fewer samples than the audio view is ignored (the detector falls back to the audio itself) rather than read out of bounds.

Parameters
audioBuffer to modify.
sidechainBuffer to read for level detection.

Definition at line 855 of file Compressor.h.

◆ processSample()

template<FloatType T>
T dspark::Compressor< T >::processSample ( input,
int  channel 
)
inlinenoexcept

Processes a single sample on one channel.

Bypasses block-level features like stereo linking, parallel mix, and lookahead. Ideal for modular routing, synth voices, or per-sample environments.

Note
No DenormalGuard is installed on this per-sample hot path (installing and tearing down the FTZ/DAZ guard every sample would dominate its cost); per-sample callers are expected to guard their own processing loop with a single DenormalGuard, exactly as the block path does once per block. This matches Limiter/NoiseGate processSample().
getLatency() reports the processBlock() path (lookahead + Hilbert alignment). This per-sample path BYPASSES the lookahead delay line, so it adds no lookahead latency regardless of setLookahead().
Shared state (parameter smoothers, auto-makeup envelope) advances once per sample FRAME and is driven by channel 0. Multi-channel per-sample workflows must therefore include channel 0; other channels read the current smoothed values without advancing them.
Parameters
inputAudio sample to process. Returned unchanged (with no state touched) before prepare() or for a channel outside [0, 16).
channelIndex of the audio channel (used for state tracking).
Returns
Compressed output sample.

Definition at line 306 of file Compressor.h.

◆ reset()

template<FloatType T>
void dspark::Compressor< T >::reset ( )
inlinenoexcept

Resets all internal DSP history, states, and buffers to neutral.

Definition at line 448 of file Compressor.h.

◆ setAttack()

template<FloatType T>
void dspark::Compressor< T >::setAttack ( ms)
inlinenoexcept

Sets the attack time in milliseconds.

Reads as the t63 time constant of the OBSERVED gain-reduction envelope in dB. Character models clamp it to their hardware's physical range: Opto floors it at 10 ms (the T4 cell's published attack time), FET clamps it to 0.02-0.8 ms. In FeedBack operation the loop multiplies the raw ballistics speed by its gain; the coefficient is re-derived so the observed t63 stays on the knob (the 1176's 20-800 us figures are measured results, not raw RC values).

Definition at line 520 of file Compressor.h.

◆ setAutoMakeup() [1/2]

template<FloatType T>
void dspark::Compressor< T >::setAutoMakeup ( AutoMakeupMode  mode)
inlinenoexcept

Selects the automatic makeup behavior (default: Off).

Static is the textbook auto makeup: a constant, program-independent offset of half the static gain reduction of a full-scale signal. Adaptive is loudness matching: it tracks the smoothed gain reduction (~300 ms) and compensates it in full, so the average output level stays matched to the input and quiet passages are lifted accordingly (macro-dynamics are reduced). For a fixed offset use setMakeupGain().

Definition at line 567 of file Compressor.h.

◆ setAutoMakeup() [2/2]

template<FloatType T>
void dspark::Compressor< T >::setAutoMakeup ( bool  on)
inlinenoexcept

Convenience overload: true selects Adaptive, false turns auto makeup off.

Definition at line 574 of file Compressor.h.

◆ setCharacter()

template<FloatType T>
void dspark::Compressor< T >::setCharacter ( Character  type)
inlinenoexcept

Changes ballistics and envelope behavior character.

Definition at line 658 of file Compressor.h.

◆ setCharacterColor()

template<FloatType T>
void dspark::Compressor< T >::setCharacterColor ( amount)
inlinenoexcept

Sets the amount of the character's harmonic signature (0 to 1).

Currently shapes the FET character: 2nd-order channel modulation of the 1176's gain-reduction FET (the drain-source resistance bends with the signal across it), scaled with the active gain reduction and AC-coupled like the hardware's output stage. At 1.0 it is calibrated to the published 1176 THD spec (< 0.5% while limiting, measured at -6 dBFS program level); it only distorts while the FET conducts, so no gain reduction means no added colour. Other characters ignore it for now. Default 0 (clean). The squared term doubles the signal bandwidth: on synthetic full-scale HF material wrap the compressor in an oversampled section (see docs/cookbook.md) if the folded 2nd harmonic matters.

Definition at line 678 of file Compressor.h.

◆ setDetector()

template<FloatType T>
void dspark::Compressor< T >::setDetector ( DetectorType  type)
inlinenoexcept

Changes the level detection algorithm (Peak, RMS, TruePeak, Hilbert).

Definition at line 613 of file Compressor.h.

◆ setHoldTime()

template<FloatType T>
void dspark::Compressor< T >::setHoldTime ( ms)
inlinenoexcept

Sets the gain-reduction hold time.

The deepest gain reduction is held for this long before the release stage may recover, the classic tool against pumping on dense material.

Parameters
msHold time in milliseconds (0 = off, mastering range 0-500).

Definition at line 628 of file Compressor.h.

◆ setKnee()

template<FloatType T>
void dspark::Compressor< T >::setKnee ( dB)
inlinenoexcept

Sets knee width in dB (0 = hard knee, >0 = soft knee).

Definition at line 544 of file Compressor.h.

◆ setLookahead()

template<FloatType T>
void dspark::Compressor< T >::setLookahead ( ms)
inlinenoexcept

Sets lookahead time in ms (0 = off, max = 10ms).

Warning
Automatically disabled internally if topology is set to FeedBack.

Definition at line 605 of file Compressor.h.

◆ setMakeupGain()

template<FloatType T>
void dspark::Compressor< T >::setMakeupGain ( dB)
inlinenoexcept

Sets manual static makeup gain in dB.

Definition at line 551 of file Compressor.h.

◆ setMix()

template<FloatType T>
void dspark::Compressor< T >::setMix ( dryWet)
inlinenoexcept

Sets dry/wet balance for parallel (New York) compression (1.0 = fully wet).

Definition at line 595 of file Compressor.h.

◆ setMode()

template<FloatType T>
void dspark::Compressor< T >::setMode ( Mode  mode)
inlinenoexcept

Sets processing mode (Downward or Upward compression).

Definition at line 580 of file Compressor.h.

◆ setRange()

template<FloatType T>
void dspark::Compressor< T >::setRange ( dB)
inlinenoexcept

Limits the maximum gain change the compressor may apply.

Classic "range" control: gain reduction (or upward boost) never exceeds this many dB regardless of how far the signal passes the threshold.

Parameters
dBMaximum |gain change| in dB (default 100 = unlimited in practice).

Definition at line 643 of file Compressor.h.

◆ setRatio()

template<FloatType T>
void dspark::Compressor< T >::setRatio ( ratio)
inlinenoexcept

Sets the compression ratio (1.0 = off, >20.0 = limiting).

Definition at line 501 of file Compressor.h.

◆ setRelease()

template<FloatType T>
void dspark::Compressor< T >::setRelease ( ms)
inlinenoexcept

Sets the release time in milliseconds (clamped to >= 1 ms: below that the envelope stops smoothing at all and the gain path degenerates into a waveshaper).

Reads as the t63 time constant of the dB envelope for Clean/Varimu. For Opto it is the time to ~50% recovery (the slow memory tail extends up to ~35x longer); for FET it clamps to the 1176 range 50-1100 ms.

Definition at line 536 of file Compressor.h.

◆ setRmsWindow()

template<FloatType T>
void dspark::Compressor< T >::setRmsWindow ( ms)
inlinenoexcept

Sets the RMS analysis window size in milliseconds.

Published atomically; the audio thread applies the new window (and resets the sliding state) at its next block, so no control-thread write ever races the per-sample RMS accumulators.

Warning
Clamped to the 1-500 ms range of the prepare() pre-allocation.

Definition at line 716 of file Compressor.h.

◆ setSidechainHPF()

template<FloatType T>
void dspark::Compressor< T >::setSidechainHPF ( bool  enabled,
cutoffHz = T(80) 
)
inlinenoexcept

Toggles the internal sidechain high-pass filter.

An invalid cutoff (non-positive or non-finite) keeps the previous frequency and only applies the toggle: a negative cutoff would make the one-pole coefficient exceed 1 (an unstable, runaway filter).

Parameters
enabledTrue to activate HPF.
cutoffHzCutoff frequency in Hz (Default: 80Hz).

Definition at line 700 of file Compressor.h.

◆ setState()

template<FloatType T>
bool dspark::Compressor< T >::setState ( const uint8_t *  data,
size_t  size 
)
inline

Restores parameters from a blob (tolerant; rejects foreign ids).

Definition at line 798 of file Compressor.h.

◆ setStereoLink()

template<FloatType T>
void dspark::Compressor< T >::setStereoLink ( amount)
inlinenoexcept

Sets stereo linking amount (0.0 = unlinked dual mono, 1.0 = fully linked).

Definition at line 588 of file Compressor.h.

◆ setThreshold()

template<FloatType T>
void dspark::Compressor< T >::setThreshold ( dB)
inlinenoexcept

Sets the compression threshold in dB.

Definition at line 494 of file Compressor.h.

◆ setTopology()

template<FloatType T>
void dspark::Compressor< T >::setTopology ( Topology  topo)
inlinenoexcept

Changes signal routing topology (FeedForward or FeedBack).

Definition at line 650 of file Compressor.h.

◆ solveFeedbackGain()

template<FloatType T>
FeedbackSolve dspark::Compressor< T >::solveFeedbackGain ( inDb,
k,
effB,
thresh,
ratio,
knee,
Character  charType 
) const
inlineprotectednoexcept

Solves one feedback ballistics step against the current input.

With the peak detector the level the loop will read is a known function of the gain (out = in + G), so the one-pole step G = k + effB * gel(in + G) is solved simultaneously with it, piece by piece: the element law is linear or quadratic per piece and F(G) = G - k - effB * gel(in + G) is strictly monotonic, so a piece whose solution verifies its own range IS the unique solution. This is the backward-Euler view of the analog loop (a first-order system): unconditionally stable at any attack, unlike the explicit iteration whose one-sample delay rings once the loop gain (R - 1) exceeds the ballistics speed.

Parameters
inDbInput level in dB (post link and sidechain filter).
kExplicit part of the ballistics step (coeff-weighted history).
effBImplicit weight: (1 - coeff) times the fast-stage blend.

Definition at line 1469 of file Compressor.h.

◆ updateHpfCoefficients()

template<FloatType T>
void dspark::Compressor< T >::updateHpfCoefficients ( )
inlineprotectednoexcept

Updates the normalized DC-blocker / High-pass filter coefficients.

Definition at line 1642 of file Compressor.h.

◆ updateRmsWindow()

template<FloatType T>
void dspark::Compressor< T >::updateRmsWindow ( )
inlineprotectednoexcept

Safely recalculates the RMS window size ensuring zero heap allocations.

Definition at line 1672 of file Compressor.h.

◆ updateTimeConstants()

template<FloatType T>
void dspark::Compressor< T >::updateTimeConstants ( fs)
inlineprotectednoexcept

Pre-calculates recursive exponential decay coefficients.

Parameters
fsCurrent sample rate.

Definition at line 1058 of file Compressor.h.

Member Data Documentation

◆ attackMs_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::attackMs_ { T(5) }
protected

Attack time in milliseconds.

Definition at line 1715 of file Compressor.h.

◆ autoMakeupCoeff_

template<FloatType T>
T dspark::Compressor< T >::autoMakeupCoeff_ = T(0.9995)
protected

Auto-makeup tracking factor.

Definition at line 1731 of file Compressor.h.

◆ autoMakeupEnv_

template<FloatType T>
T dspark::Compressor< T >::autoMakeupEnv_ = T(0)
protected

Smoothed internal auto-makeup envelope.

Definition at line 1732 of file Compressor.h.

◆ autoMakeupMode_

template<FloatType T>
std::atomic<AutoMakeupMode> dspark::Compressor< T >::autoMakeupMode_ { AutoMakeupMode::Off }
protected

Auto-makeup behavior.

Definition at line 1723 of file Compressor.h.

◆ channelLevelDb_

template<FloatType T>
std::array<T, kMaxChannels> dspark::Compressor< T >::channelLevelDb_ {}
protected

Raw detected level buffer.

Definition at line 1763 of file Compressor.h.

◆ character_

template<FloatType T>
std::atomic<Character> dspark::Compressor< T >::character_ { Character::Clean }
protected

Selected ballistics.

Definition at line 1727 of file Compressor.h.

◆ characterColor_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::characterColor_ { T(0) }
protected

Character harmonic amount (0 to 1).

Definition at line 1722 of file Compressor.h.

◆ charAttCoeff_

template<FloatType T>
T dspark::Compressor< T >::charAttCoeff_ = T(0)
protected

Attack coefficient of the fast envelope.

Definition at line 1738 of file Compressor.h.

◆ charChargeCoeff_

template<FloatType T>
T dspark::Compressor< T >::charChargeCoeff_ = T(0)
protected

History charge coefficient of the memory stage.

Definition at line 1741 of file Compressor.h.

◆ charFastWeight_

template<FloatType T>
T dspark::Compressor< T >::charFastWeight_ = T(1)
protected

Fast/slow blend (1 = single envelope).

Definition at line 1742 of file Compressor.h.

◆ charRelCoeff_

template<FloatType T>
T dspark::Compressor< T >::charRelCoeff_ = T(0)
protected

Release coefficient (fast stage).

Definition at line 1739 of file Compressor.h.

◆ charSlowRelCoeff_

template<FloatType T>
T dspark::Compressor< T >::charSlowRelCoeff_ = T(0)
protected

Release coefficient of the memory stage.

Definition at line 1740 of file Compressor.h.

◆ colorSmooth_

template<FloatType T>
SmoothedValue<T> dspark::Compressor< T >::colorSmooth_
protected

De-zippered character colour amount.

Definition at line 1749 of file Compressor.h.

◆ detectorType_

template<FloatType T>
std::atomic<DetectorType> dspark::Compressor< T >::detectorType_ { DetectorType::Peak }
protected

Selected detection method.

Definition at line 1725 of file Compressor.h.

◆ envFastDb_

template<FloatType T>
std::array<T, kMaxChannels> dspark::Compressor< T >::envFastDb_ {}
protected

Fast gain envelope per channel (dB).

Definition at line 1758 of file Compressor.h.

◆ envSlowDb_

template<FloatType T>
std::array<T, kMaxChannels> dspark::Compressor< T >::envSlowDb_ {}
protected

Slow memory envelope per channel (dB).

Definition at line 1759 of file Compressor.h.

◆ fbLastOutput_

template<FloatType T>
std::array<T, kMaxChannels> dspark::Compressor< T >::fbLastOutput_ {}
protected

Feedback topology history buffer.

Definition at line 1762 of file Compressor.h.

◆ fetDcCoeff_

template<FloatType T>
T dspark::Compressor< T >::fetDcCoeff_ = T(0)
protected

~10 Hz DC-tracking coefficient.

Definition at line 1755 of file Compressor.h.

◆ fetDcState_

template<FloatType T>
std::array<T, kMaxChannels> dspark::Compressor< T >::fetDcState_ {}
protected

Per-channel DC estimate of wet^2.

Definition at line 1756 of file Compressor.h.

◆ gainReductionDb_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::gainReductionDb_ { T(0) }
protected

Publicly readable Gain Reduction meter.

Definition at line 1805 of file Compressor.h.

◆ heldGrDb_

template<FloatType T>
std::array<T, kMaxChannels> dspark::Compressor< T >::heldGrDb_ {}
protected

Definition at line 1803 of file Compressor.h.

◆ hilbertDetectors_

template<FloatType T>
std::array<Hilbert<T>, kMaxChannels> dspark::Compressor< T >::hilbertDetectors_ {}
protected

Analytic signal generators for detection.

Definition at line 1768 of file Compressor.h.

◆ holdCounters_

template<FloatType T>
std::array<int, kMaxChannels> dspark::Compressor< T >::holdCounters_ {}
protected

Definition at line 1802 of file Compressor.h.

◆ holdMs_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::holdMs_ { T(0) }
protected

Gain-hold time in ms (0 = off).

Definition at line 1799 of file Compressor.h.

◆ holdSamples_

template<FloatType T>
int dspark::Compressor< T >::holdSamples_ = 0
protected

Definition at line 1801 of file Compressor.h.

◆ kFetColorH2

template<FloatType T>
constexpr T dspark::Compressor< T >::kFetColorH2 = T(0.028)
staticconstexprprotected

Definition at line 1754 of file Compressor.h.

◆ kMaxChannels

template<FloatType T>
constexpr int dspark::Compressor< T >::kMaxChannels = 16
staticconstexprprotected

Definition at line 828 of file Compressor.h.

◆ kneeSmooth_

template<FloatType T>
SmoothedValue<T> dspark::Compressor< T >::kneeSmooth_
protected

De-zippered knee.

Definition at line 1746 of file Compressor.h.

◆ kneeWidth_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::kneeWidth_ { T(0) }
protected

Knee width in dB.

Definition at line 1717 of file Compressor.h.

◆ kRmsRecomputePeriod

template<FloatType T>
constexpr int dspark::Compressor< T >::kRmsRecomputePeriod = 4096
staticconstexprprotected

Re-summation interval to halt drift.

Definition at line 1792 of file Compressor.h.

◆ lookaheadBuffers_

template<FloatType T>
std::array<RingBuffer<T>, kMaxChannels> dspark::Compressor< T >::lookaheadBuffers_ {}
protected

Lookahead delay lines.

Definition at line 1765 of file Compressor.h.

◆ lookaheadMs_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::lookaheadMs_ { T(0) }
protected

Lookahead latency target in ms.

Definition at line 1721 of file Compressor.h.

◆ lookaheadSamples_

template<FloatType T>
int dspark::Compressor< T >::lookaheadSamples_ = 0
protected

Active lookahead latency in samples.

Definition at line 1766 of file Compressor.h.

◆ makeupGain_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::makeupGain_ { T(0) }
protected

Static makeup gain in dB.

Definition at line 1718 of file Compressor.h.

◆ makeupSmooth_

template<FloatType T>
SmoothedValue<T> dspark::Compressor< T >::makeupSmooth_
protected

De-zippered makeup gain (dB).

Definition at line 1747 of file Compressor.h.

◆ mix_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::mix_ { T(1) }
protected

Wet/Dry mix (1 = full wet).

Definition at line 1720 of file Compressor.h.

◆ mixSmooth_

template<FloatType T>
SmoothedValue<T> dspark::Compressor< T >::mixSmooth_
protected

De-zippered parallel mix.

Definition at line 1748 of file Compressor.h.

◆ mode_

template<FloatType T>
std::atomic<Mode> dspark::Compressor< T >::mode_ { Mode::Downward }
protected

Selected compression mode.

Definition at line 1728 of file Compressor.h.

◆ rangeDb_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::rangeDb_ { T(100) }
protected

Max |gain change| in dB.

Definition at line 1800 of file Compressor.h.

◆ ratio_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::ratio_ { T(4) }
protected

Ratio (e.g., 4 = 4:1).

Definition at line 1714 of file Compressor.h.

◆ ratioSmooth_

template<FloatType T>
SmoothedValue<T> dspark::Compressor< T >::ratioSmooth_
protected

De-zippered ratio.

Definition at line 1745 of file Compressor.h.

◆ releaseMs_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::releaseMs_ { T(100) }
protected

Release time in milliseconds.

Definition at line 1716 of file Compressor.h.

◆ rmsBuffers_

template<FloatType T>
std::array<std::vector<T>, kMaxChannels> dspark::Compressor< T >::rmsBuffers_
protected

Pre-allocated RMS sliding windows.

Definition at line 1789 of file Compressor.h.

◆ rmsIndices_

template<FloatType T>
std::array<int, kMaxChannels> dspark::Compressor< T >::rmsIndices_ {}
protected

Write heads for RMS buffers.

Definition at line 1791 of file Compressor.h.

◆ rmsRecomputeCounters_

template<FloatType T>
std::array<int, kMaxChannels> dspark::Compressor< T >::rmsRecomputeCounters_ {}
protected

Re-summation counters.

Definition at line 1793 of file Compressor.h.

◆ rmsSums_

template<FloatType T>
std::array<T, kMaxChannels> dspark::Compressor< T >::rmsSums_ {}
protected

Running sums for RMS.

Definition at line 1790 of file Compressor.h.

◆ rmsWindowDirty_

template<FloatType T>
std::atomic<bool> dspark::Compressor< T >::rmsWindowDirty_ { false }
protected

Applied at the next block.

Definition at line 1787 of file Compressor.h.

◆ rmsWindowMs_

template<FloatType T>
T dspark::Compressor< T >::rmsWindowMs_ = T(10)
protected

Active RMS length in ms (audio-thread copy).

Definition at line 1785 of file Compressor.h.

◆ rmsWindowMsAtomic_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::rmsWindowMsAtomic_ { T(10) }
protected

Control-thread published target.

Definition at line 1786 of file Compressor.h.

◆ rmsWindowSamples_

template<FloatType T>
int dspark::Compressor< T >::rmsWindowSamples_ = 0
protected

Active RMS length in samples.

Definition at line 1788 of file Compressor.h.

◆ sampleRate_

template<FloatType T>
double dspark::Compressor< T >::sampleRate_ = 0
protected

Cached operating sample rate.

Definition at line 1710 of file Compressor.h.

◆ scHpfA0_

template<FloatType T>
T dspark::Compressor< T >::scHpfA0_ = T(0)
protected

HPF normalized feedforward coefficient.

Definition at line 1774 of file Compressor.h.

◆ scHpfB1_

template<FloatType T>
T dspark::Compressor< T >::scHpfB1_ = T(0)
protected

HPF internal feedback coefficient.

Definition at line 1773 of file Compressor.h.

◆ scHpfEnabled_

template<FloatType T>
std::atomic<bool> dspark::Compressor< T >::scHpfEnabled_ { false }
protected

HPF toggle.

Definition at line 1771 of file Compressor.h.

◆ scHpfFreq_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::scHpfFreq_ { T(80) }
protected

HPF Cutoff frequency.

Definition at line 1772 of file Compressor.h.

◆ scHpfPrev_

template<FloatType T>
std::array<T, kMaxChannels> dspark::Compressor< T >::scHpfPrev_ {}
protected

HPF x[n-1] state.

Definition at line 1776 of file Compressor.h.

◆ scHpfState_

template<FloatType T>
std::array<T, kMaxChannels> dspark::Compressor< T >::scHpfState_ {}
protected

HPF y[n-1] state.

Definition at line 1775 of file Compressor.h.

◆ spec_

template<FloatType T>
AudioSpec dspark::Compressor< T >::spec_ {}
protected

Active audio environment specification.

Definition at line 1709 of file Compressor.h.

◆ splitDetAttCoeff_

template<FloatType T>
T dspark::Compressor< T >::splitDetAttCoeff_ = T(0.6)
protected

Detector attack coefficient (sample-rate derived).

Definition at line 1781 of file Compressor.h.

◆ splitDetRelCoeff_

template<FloatType T>
T dspark::Compressor< T >::splitDetRelCoeff_ = T(0.99)
protected

Detector release coefficient (sample-rate derived).

Definition at line 1782 of file Compressor.h.

◆ splitNegEnv_

template<FloatType T>
std::array<T, kMaxChannels> dspark::Compressor< T >::splitNegEnv_ {}
protected

Negative half-wave tracking.

Definition at line 1780 of file Compressor.h.

◆ splitPosEnv_

template<FloatType T>
std::array<T, kMaxChannels> dspark::Compressor< T >::splitPosEnv_ {}
protected

Positive half-wave tracking.

Definition at line 1779 of file Compressor.h.

◆ stereoLink_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::stereoLink_ { T(1) }
protected

Stereo linking amount (0 to 1).

Definition at line 1719 of file Compressor.h.

◆ threshold_

template<FloatType T>
std::atomic<T> dspark::Compressor< T >::threshold_ { T(-20) }
protected

Threshold in dB.

Definition at line 1713 of file Compressor.h.

◆ thresholdSmooth_

template<FloatType T>
SmoothedValue<T> dspark::Compressor< T >::thresholdSmooth_
protected

De-zippered threshold.

Definition at line 1744 of file Compressor.h.

◆ timeConstantsDirty_

template<FloatType T>
std::atomic<bool> dspark::Compressor< T >::timeConstantsDirty_ { true }
protected

Coefficients need a recompute.

Definition at line 1737 of file Compressor.h.

◆ topology_

template<FloatType T>
std::atomic<Topology> dspark::Compressor< T >::topology_ { Topology::FeedForward }
protected

Selected topology.

Definition at line 1726 of file Compressor.h.

◆ truePeak_

template<FloatType T>
TruePeakDetector<T, kMaxChannels> dspark::Compressor< T >::truePeak_
protected

Definition at line 1796 of file Compressor.h.

◆ upwardGuardDb_

template<FloatType T>
std::array<T, kMaxChannels> dspark::Compressor< T >::upwardGuardDb_ {}
protected

Peak-held sustained level (Upward guard).

Definition at line 1760 of file Compressor.h.

◆ upwardGuardDecay_

template<FloatType T>
T dspark::Compressor< T >::upwardGuardDecay_ = T(0.00125)
protected

Guard decay per sample (60 dB/s).

Definition at line 1761 of file Compressor.h.


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