|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
High-fidelity modular compressor designed for real-time applications. More...
#include <Compressor.h>

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. | |
| T | 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). | |
| T | 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. | |
| T | 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. | |
| T | applyHoldAndRange (T targetGR_Db, int ch) noexcept |
| Applies the hold and range stages to the static gain target (dB). | |
| T | detectLevel (T sample, int ch, DetectorType detType) noexcept |
| Computes level detection in Decibels. | |
| T | 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. | |
| T | 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. | |
| T | applyBallisticsFeedbackImplicit (T inDb, int ch, Character charType, T thresh, T ratio, T knee) noexcept |
| Feedback ballistics with the loop resolved semi-implicitly. | |
| T | 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. | |
| T | 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< AutoMakeupMode > | autoMakeupMode_ { AutoMakeupMode::Off } |
| Auto-makeup behavior. | |
| std::atomic< DetectorType > | detectorType_ { DetectorType::Peak } |
| Selected detection method. | |
| std::atomic< Topology > | topology_ { Topology::FeedForward } |
| Selected topology. | |
| std::atomic< Character > | character_ { Character::Clean } |
| Selected ballistics. | |
| std::atomic< Mode > | mode_ { Mode::Downward } |
| Selected compression mode. | |
| T | autoMakeupCoeff_ = T(0.9995) |
| Auto-makeup tracking factor. | |
| T | autoMakeupEnv_ = T(0) |
| Smoothed internal auto-makeup envelope. | |
| std::atomic< bool > | timeConstantsDirty_ { true } |
| Coefficients need a recompute. | |
| T | charAttCoeff_ = T(0) |
| Attack coefficient of the fast envelope. | |
| T | charRelCoeff_ = T(0) |
| Release coefficient (fast stage). | |
| T | charSlowRelCoeff_ = T(0) |
| Release coefficient of the memory stage. | |
| T | charChargeCoeff_ = T(0) |
| History charge coefficient of the memory stage. | |
| T | 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. | |
| T | fetDcCoeff_ = T(0) |
| ~10 Hz DC-tracking coefficient. | |
| std::array< T, kMaxChannels > | fetDcState_ {} |
| Per-channel DC estimate of wet^2. | |
| std::array< T, kMaxChannels > | envFastDb_ {} |
| Fast gain envelope per channel (dB). | |
| std::array< T, kMaxChannels > | envSlowDb_ {} |
| Slow memory envelope per channel (dB). | |
| std::array< T, kMaxChannels > | upwardGuardDb_ {} |
| Peak-held sustained level (Upward guard). | |
| T | upwardGuardDecay_ = T(0.00125) |
| Guard decay per sample (60 dB/s). | |
| std::array< T, kMaxChannels > | fbLastOutput_ {} |
| Feedback topology history buffer. | |
| std::array< T, kMaxChannels > | channelLevelDb_ {} |
| Raw detected level buffer. | |
| std::array< RingBuffer< T >, kMaxChannels > | lookaheadBuffers_ {} |
| Lookahead delay lines. | |
| int | lookaheadSamples_ = 0 |
| Active lookahead latency in samples. | |
| std::array< Hilbert< T >, kMaxChannels > | hilbertDetectors_ {} |
| Analytic signal generators for detection. | |
| std::atomic< bool > | scHpfEnabled_ { false } |
| HPF toggle. | |
| std::atomic< T > | scHpfFreq_ { T(80) } |
| HPF Cutoff frequency. | |
| T | scHpfB1_ = T(0) |
| HPF internal feedback coefficient. | |
| T | scHpfA0_ = T(0) |
| HPF normalized feedforward coefficient. | |
| std::array< T, kMaxChannels > | scHpfState_ {} |
| HPF y[n-1] state. | |
| std::array< T, kMaxChannels > | scHpfPrev_ {} |
| HPF x[n-1] state. | |
| std::array< T, kMaxChannels > | splitPosEnv_ {} |
| Positive half-wave tracking. | |
| std::array< T, kMaxChannels > | splitNegEnv_ {} |
| Negative half-wave tracking. | |
| T | splitDetAttCoeff_ = T(0.6) |
| Detector attack coefficient (sample-rate derived). | |
| T | splitDetRelCoeff_ = T(0.99) |
| Detector release coefficient (sample-rate derived). | |
| T | 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 >, kMaxChannels > | rmsBuffers_ |
| Pre-allocated RMS sliding windows. | |
| std::array< T, kMaxChannels > | rmsSums_ {} |
| Running sums for RMS. | |
| std::array< int, kMaxChannels > | rmsIndices_ {} |
| Write heads for RMS buffers. | |
| std::array< int, kMaxChannels > | rmsRecomputeCounters_ {} |
| Re-summation counters. | |
| TruePeakDetector< T, kMaxChannels > | truePeak_ |
| 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, kMaxChannels > | holdCounters_ {} |
| std::array< T, kMaxChannels > | heldGrDb_ {} |
| 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. | |
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.
| T | Floating-point sample type (float or double). |
Definition at line 87 of file Compressor.h.
|
strong |
Automatic makeup-gain behavior (applies in Downward mode).
Definition at line 168 of file Compressor.h.
|
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.
|
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.
|
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.
|
strong |
Signal routing topology for the detector sidechain.
Definition at line 109 of file Compressor.h.
|
default |
|
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.
| targetGrDb | Static gain change target in dB (negative = reduction). |
| ch | Channel index. |
| splitAdaptive | True 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). |
| loopSlope | Incremental 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). |
Definition at line 1592 of file Compressor.h.
|
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.
| inDb | Input level in dB (post link and sidechain filter). |
Definition at line 1512 of file Compressor.h.
|
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.
|
inlineprotectednoexcept |
Applies sidechain filtering for a specific channel.
| input | Raw sidechain sample. |
| ch | Channel index. |
Definition at line 1659 of file Compressor.h.
|
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.
|
inlineprotectednoexcept |
Calculates static target gain reduction based on knee and ratio.
| inputDb | Detected level in decibels. |
| thresh | Threshold parameter in dB. |
| ratio | Ratio parameter. |
| knee | Soft-knee width parameter in dB. |
| charType | Applies the character's knee floor and ratio law. |
| modeType | Upward or Downward processing mode. |
Definition at line 1299 of file Compressor.h.
|
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).
| outDb | Detected output level (dB). |
Definition at line 1427 of file Compressor.h.
|
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.
|
inlineprotectednoexcept |
Computes level detection in Decibels.
| sample | Input sample. |
| ch | Channel index (for state tracking). |
| detType | Selected detector methodology. |
Definition at line 1196 of file Compressor.h.
|
inlinestaticprotectednoexcept |
Physical knee floor of the character (dB).
Definition at line 1280 of file Compressor.h.
|
inlinestaticprotectednoexcept |
Level-dependent effective ratio of the character (Varimu grows).
| excessDb | Input level above the threshold in dB. |
Definition at line 1270 of file Compressor.h.
|
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.
| eOut | Detected output level relative to the threshold (dB). |
| r | Effective ratio (>= 1). |
| w | Effective knee width (dB, >= 0). |
Definition at line 1395 of file Compressor.h.
|
inlinenoexcept |
Returns the currently active character.
Definition at line 737 of file Compressor.h.
|
inlinenoexcept |
Returns the character colour amount (see setCharacterColor).
Definition at line 685 of file Compressor.h.
|
inlinenoexcept |
Returns the currently active detector type.
Definition at line 731 of file Compressor.h.
|
inlinenoexcept |
Returns current active gain reduction in dB (negative value).
Definition at line 728 of file Compressor.h.
|
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.
|
inline |
Serializes the parameter state (setup/UI threads; allocates).
Definition at line 767 of file Compressor.h.
|
inlinenoexcept |
Returns the currently active topology.
Definition at line 734 of file Compressor.h.
|
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.
| spec | Audio environment specification (sample rate, block size, channels). |
Definition at line 190 of file Compressor.h.
|
inlinenoexcept |
Prepares the compressor using sample rate only (backward compatibility).
| sampleRate | The operating sample rate. |
Definition at line 252 of file Compressor.h.
|
inlinenoexcept |
Processes audio with an independent external sidechain.
The detector analyzes the sidechain buffer, but gain reduction is applied to the audio buffer.
| audio | Audio buffer to be compressed (modified in-place). |
| sidechain | Key/Sidechain signal (read-only). |
Definition at line 276 of file Compressor.h.
|
inlinenoexcept |
Processes an audio buffer in-place using its own signal as the sidechain.
| buffer | Mutable reference to the audio block. |
Definition at line 262 of file Compressor.h.
|
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.
| audio | Buffer to modify. |
| sidechain | Buffer to read for level detection. |
Definition at line 855 of file Compressor.h.
|
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.
| input | Audio sample to process. Returned unchanged (with no state touched) before prepare() or for a channel outside [0, 16). |
| channel | Index of the audio channel (used for state tracking). |
Definition at line 306 of file Compressor.h.
|
inlinenoexcept |
Resets all internal DSP history, states, and buffers to neutral.
Definition at line 448 of file Compressor.h.
|
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.
|
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.
|
inlinenoexcept |
Convenience overload: true selects Adaptive, false turns auto makeup off.
Definition at line 574 of file Compressor.h.
|
inlinenoexcept |
Changes ballistics and envelope behavior character.
Definition at line 658 of file Compressor.h.
|
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.
|
inlinenoexcept |
Changes the level detection algorithm (Peak, RMS, TruePeak, Hilbert).
Definition at line 613 of file Compressor.h.
|
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.
| ms | Hold time in milliseconds (0 = off, mastering range 0-500). |
Definition at line 628 of file Compressor.h.
|
inlinenoexcept |
Sets knee width in dB (0 = hard knee, >0 = soft knee).
Definition at line 544 of file Compressor.h.
|
inlinenoexcept |
Sets lookahead time in ms (0 = off, max = 10ms).
Definition at line 605 of file Compressor.h.
|
inlinenoexcept |
Sets manual static makeup gain in dB.
Definition at line 551 of file Compressor.h.
|
inlinenoexcept |
Sets dry/wet balance for parallel (New York) compression (1.0 = fully wet).
Definition at line 595 of file Compressor.h.
|
inlinenoexcept |
Sets processing mode (Downward or Upward compression).
Definition at line 580 of file Compressor.h.
|
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.
| dB | Maximum |gain change| in dB (default 100 = unlimited in practice). |
Definition at line 643 of file Compressor.h.
|
inlinenoexcept |
Sets the compression ratio (1.0 = off, >20.0 = limiting).
Definition at line 501 of file Compressor.h.
|
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.
|
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.
Definition at line 716 of file Compressor.h.
|
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).
| enabled | True to activate HPF. |
| cutoffHz | Cutoff frequency in Hz (Default: 80Hz). |
Definition at line 700 of file Compressor.h.
|
inline |
Restores parameters from a blob (tolerant; rejects foreign ids).
Definition at line 798 of file Compressor.h.
|
inlinenoexcept |
Sets stereo linking amount (0.0 = unlinked dual mono, 1.0 = fully linked).
Definition at line 588 of file Compressor.h.
|
inlinenoexcept |
Sets the compression threshold in dB.
Definition at line 494 of file Compressor.h.
|
inlinenoexcept |
Changes signal routing topology (FeedForward or FeedBack).
Definition at line 650 of file Compressor.h.
|
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.
| inDb | Input level in dB (post link and sidechain filter). |
| k | Explicit part of the ballistics step (coeff-weighted history). |
| effB | Implicit weight: (1 - coeff) times the fast-stage blend. |
Definition at line 1469 of file Compressor.h.
|
inlineprotectednoexcept |
Updates the normalized DC-blocker / High-pass filter coefficients.
Definition at line 1642 of file Compressor.h.
|
inlineprotectednoexcept |
Safely recalculates the RMS window size ensuring zero heap allocations.
Definition at line 1672 of file Compressor.h.
|
inlineprotectednoexcept |
Pre-calculates recursive exponential decay coefficients.
| fs | Current sample rate. |
Definition at line 1058 of file Compressor.h.
|
protected |
Attack time in milliseconds.
Definition at line 1715 of file Compressor.h.
|
protected |
Auto-makeup tracking factor.
Definition at line 1731 of file Compressor.h.
|
protected |
Smoothed internal auto-makeup envelope.
Definition at line 1732 of file Compressor.h.
|
protected |
Auto-makeup behavior.
Definition at line 1723 of file Compressor.h.
|
protected |
Raw detected level buffer.
Definition at line 1763 of file Compressor.h.
|
protected |
Selected ballistics.
Definition at line 1727 of file Compressor.h.
|
protected |
Character harmonic amount (0 to 1).
Definition at line 1722 of file Compressor.h.
|
protected |
Attack coefficient of the fast envelope.
Definition at line 1738 of file Compressor.h.
|
protected |
History charge coefficient of the memory stage.
Definition at line 1741 of file Compressor.h.
|
protected |
Fast/slow blend (1 = single envelope).
Definition at line 1742 of file Compressor.h.
|
protected |
Release coefficient (fast stage).
Definition at line 1739 of file Compressor.h.
|
protected |
Release coefficient of the memory stage.
Definition at line 1740 of file Compressor.h.
|
protected |
De-zippered character colour amount.
Definition at line 1749 of file Compressor.h.
|
protected |
Selected detection method.
Definition at line 1725 of file Compressor.h.
|
protected |
Fast gain envelope per channel (dB).
Definition at line 1758 of file Compressor.h.
|
protected |
Slow memory envelope per channel (dB).
Definition at line 1759 of file Compressor.h.
|
protected |
Feedback topology history buffer.
Definition at line 1762 of file Compressor.h.
|
protected |
~10 Hz DC-tracking coefficient.
Definition at line 1755 of file Compressor.h.
|
protected |
Per-channel DC estimate of wet^2.
Definition at line 1756 of file Compressor.h.
|
protected |
Publicly readable Gain Reduction meter.
Definition at line 1805 of file Compressor.h.
|
protected |
Definition at line 1803 of file Compressor.h.
|
protected |
Analytic signal generators for detection.
Definition at line 1768 of file Compressor.h.
|
protected |
Definition at line 1802 of file Compressor.h.
|
protected |
Gain-hold time in ms (0 = off).
Definition at line 1799 of file Compressor.h.
|
protected |
Definition at line 1801 of file Compressor.h.
|
staticconstexprprotected |
Definition at line 1754 of file Compressor.h.
|
staticconstexprprotected |
Definition at line 828 of file Compressor.h.
|
protected |
De-zippered knee.
Definition at line 1746 of file Compressor.h.
|
protected |
Knee width in dB.
Definition at line 1717 of file Compressor.h.
|
staticconstexprprotected |
Re-summation interval to halt drift.
Definition at line 1792 of file Compressor.h.
|
protected |
Lookahead delay lines.
Definition at line 1765 of file Compressor.h.
|
protected |
Lookahead latency target in ms.
Definition at line 1721 of file Compressor.h.
|
protected |
Active lookahead latency in samples.
Definition at line 1766 of file Compressor.h.
|
protected |
Static makeup gain in dB.
Definition at line 1718 of file Compressor.h.
|
protected |
De-zippered makeup gain (dB).
Definition at line 1747 of file Compressor.h.
|
protected |
Wet/Dry mix (1 = full wet).
Definition at line 1720 of file Compressor.h.
|
protected |
De-zippered parallel mix.
Definition at line 1748 of file Compressor.h.
|
protected |
Selected compression mode.
Definition at line 1728 of file Compressor.h.
|
protected |
Max |gain change| in dB.
Definition at line 1800 of file Compressor.h.
|
protected |
Ratio (e.g., 4 = 4:1).
Definition at line 1714 of file Compressor.h.
|
protected |
De-zippered ratio.
Definition at line 1745 of file Compressor.h.
|
protected |
Release time in milliseconds.
Definition at line 1716 of file Compressor.h.
|
protected |
Pre-allocated RMS sliding windows.
Definition at line 1789 of file Compressor.h.
|
protected |
Write heads for RMS buffers.
Definition at line 1791 of file Compressor.h.
|
protected |
Re-summation counters.
Definition at line 1793 of file Compressor.h.
|
protected |
Running sums for RMS.
Definition at line 1790 of file Compressor.h.
|
protected |
Applied at the next block.
Definition at line 1787 of file Compressor.h.
|
protected |
Active RMS length in ms (audio-thread copy).
Definition at line 1785 of file Compressor.h.
|
protected |
Control-thread published target.
Definition at line 1786 of file Compressor.h.
|
protected |
Active RMS length in samples.
Definition at line 1788 of file Compressor.h.
|
protected |
Cached operating sample rate.
Definition at line 1710 of file Compressor.h.
|
protected |
HPF normalized feedforward coefficient.
Definition at line 1774 of file Compressor.h.
|
protected |
HPF internal feedback coefficient.
Definition at line 1773 of file Compressor.h.
|
protected |
HPF toggle.
Definition at line 1771 of file Compressor.h.
|
protected |
HPF Cutoff frequency.
Definition at line 1772 of file Compressor.h.
|
protected |
HPF x[n-1] state.
Definition at line 1776 of file Compressor.h.
|
protected |
HPF y[n-1] state.
Definition at line 1775 of file Compressor.h.
|
protected |
Active audio environment specification.
Definition at line 1709 of file Compressor.h.
|
protected |
Detector attack coefficient (sample-rate derived).
Definition at line 1781 of file Compressor.h.
|
protected |
Detector release coefficient (sample-rate derived).
Definition at line 1782 of file Compressor.h.
|
protected |
Negative half-wave tracking.
Definition at line 1780 of file Compressor.h.
|
protected |
Positive half-wave tracking.
Definition at line 1779 of file Compressor.h.
|
protected |
Stereo linking amount (0 to 1).
Definition at line 1719 of file Compressor.h.
|
protected |
Threshold in dB.
Definition at line 1713 of file Compressor.h.
|
protected |
De-zippered threshold.
Definition at line 1744 of file Compressor.h.
|
protected |
Coefficients need a recompute.
Definition at line 1737 of file Compressor.h.
|
protected |
Selected topology.
Definition at line 1726 of file Compressor.h.
|
protected |
Definition at line 1796 of file Compressor.h.
|
protected |
Peak-held sustained level (Upward guard).
Definition at line 1760 of file Compressor.h.
|
protected |
Guard decay per sample (60 dB/s).
Definition at line 1761 of file Compressor.h.