Dynamics processor supporting compression, limiting, expansion, and gating.
More...
#include <gin_dynamics.h>
|
| | Dynamics ()=default |
| | ~Dynamics ()=default |
| void | setSampleRate (double sampleRate) |
| void | setNumChannels (int ch) |
| void | setMode (Type t) |
| void | setLinked (bool l) |
| void | setParams (float attackS, float holdS, float releaseS, float thresh, float ratio, float kneeWidth) |
| void | setInputGain (float g) |
| void | setOutputGain (float g) |
| void | setDetectorMode (EnvelopeDetector::Mode m) |
| | How the detector measures level: peak, mean square or RMS.
|
| void | setRMSWindow (float seconds) |
| | Averaging window for the ms and rms detector modes, in seconds.
|
| void | setAnalogTC (bool analog) |
| | Analog rather than digital time constants.
|
| void | setLookahead (float seconds) |
| | Delays the audio so the detector sees each transient before the gain does, in seconds.
|
| int | getLatencySamples () const |
| | Lookahead delay in samples, for AudioProcessor::setLatencySamples().
|
| void | setSidechainFilter (float highpassHz, float lowpassHz) |
| | Filters the detector's view of the signal without touching what is heard.
|
| void | setDetectorPeak (float freqHz, float q, float gainDb) |
| | A peak in the detector path, again heard only through what it makes the gain do.
|
| void | setAutoMakeupGain (bool enabled) |
| | Enables automatic makeup gain for compressor/limiter modes.
|
| void | reset () |
| void | process (juce::AudioSampleBuffer &buffer, juce::AudioSampleBuffer *envelopeOut=nullptr) |
| | Processes a buffer, with the detector following that same buffer.
|
| void | process (juce::AudioSampleBuffer &buffer, const juce::AudioSampleBuffer &sidechain, juce::AudioSampleBuffer *envelopeOut=nullptr) |
| | Processes a buffer, with the detector following a separate side chain.
|
| const LevelTracker & | getInputTracker () |
| const LevelTracker & | getOutputTracker () |
| const LevelTracker & | getReductionTracker () |
| float | calcCurve (float detectorValue) |
Dynamics processor supporting compression, limiting, expansion, and gating.
Dynamics provides a versatile dynamics processing engine that can function as a compressor, limiter, expander, or gate. Based on algorithms from "Designing
Audio Effect Plug-ins in C++" by Will Pirkle, it features attack/hold/release envelope detection, adjustable ratio and threshold, soft knee, and optional channel linking for stereo operation.
The compexp mode combines downward compression (above threshold) with upward compression (below the inverted threshold), using the same ratio for both.
Key Features:
- Five processing types: compressor, limiter, expander, gate, compexp
- Configurable attack, hold, release times
- Adjustable threshold and ratio
- Soft knee for smooth compression
- Independent input/output gain
- Stereo linking (process based on max of both channels)
- Side chain input for ducking, de-essing and source keyed gating
- Optional envelope output for visualization
- Level tracking for input/output metering
Usage:
0.0f,
0.1f,
-20.0f,
4.0f,
6.0f);
comp.
process(musicBuffer, voiceBuffer);
void process(juce::AudioSampleBuffer &buffer, juce::AudioSampleBuffer *envelopeOut=nullptr)
Processes a buffer, with the detector following that same buffer.
void setSampleRate(double sampleRate)
void setLinked(bool l)
Definition gin_dynamics.h:175
@ compressor
Compression (reduce loud signals).
Definition gin_dynamics.h:165
void setParams(float attackS, float holdS, float releaseS, float thresh, float ratio, float kneeWidth)
void setInputGain(float g)
Definition gin_dynamics.h:179
const LevelTracker & getInputTracker()
Definition gin_dynamics.h:270
const LevelTracker & getOutputTracker()
Definition gin_dynamics.h:271
void setMode(Type t)
Definition gin_dynamics.h:174
void setNumChannels(int ch)
void setOutputGain(float g)
Definition gin_dynamics.h:180
- See also
- EnvelopeDetector, LevelTracker
◆ Type
Dynamics processing types.
Determines the type of dynamics processing applied:
- compressor: Reduces gain above threshold (ratio > 1:1)
- limiter: Hard limiting (very high ratio, fast attack)
- expander: Increases dynamic range (reduces gain below threshold)
- gate: Attenuates signals below threshold (extreme expansion)
- compexp: Combined compressor + expander (expander threshold is inverse of compressor threshold)
| Enumerator |
|---|
| compressor | Compression (reduce loud signals).
|
| limiter | Limiting (prevent peaks above threshold).
|
| expander | Expansion (increase dynamic range).
|
| gate | Gate (cut quiet signals).
|
| compexp | Combined compressor and expander (expander uses inverse threshold).
|
◆ Dynamics()
◆ ~Dynamics()
◆ setSampleRate()
| void Dynamics::setSampleRate |
( |
double | sampleRate | ) |
|
◆ setNumChannels()
| void Dynamics::setNumChannels |
( |
int | ch | ) |
|
◆ setMode()
| void Dynamics::setMode |
( |
Type | t | ) |
|
◆ setLinked()
| void Dynamics::setLinked |
( |
bool | l | ) |
|
◆ setParams()
| void Dynamics::setParams |
( |
float | attackS, |
|
|
float | holdS, |
|
|
float | releaseS, |
|
|
float | thresh, |
|
|
float | ratio, |
|
|
float | kneeWidth ) |
◆ setInputGain()
| void Dynamics::setInputGain |
( |
float | g | ) |
|
◆ setOutputGain()
| void Dynamics::setOutputGain |
( |
float | g | ) |
|
◆ setDetectorMode()
◆ setRMSWindow()
| void Dynamics::setRMSWindow |
( |
float | seconds | ) |
|
◆ setAnalogTC()
| void Dynamics::setAnalogTC |
( |
bool | analog | ) |
|
Analog rather than digital time constants.
Digital constants reach 99% of the target in the time you asked for, analog ones 63% - the same curve a real capacitor charging through a resistor follows. Analog is slower to arrive and sounds gentler on the attack; digital does what the number says.
◆ setLookahead()
| void Dynamics::setLookahead |
( |
float | seconds | ) |
|
Delays the audio so the detector sees each transient before the gain does, in seconds.
Without it, an attack fast enough to catch a peak has already let the front of that peak through.
Costs latency, which the host has to be told about - see getLatencySamples(). 5 ms is plenty for most material.
◆ getLatencySamples()
| int Dynamics::getLatencySamples |
( |
| ) |
const |
Lookahead delay in samples, for AudioProcessor::setLatencySamples().
◆ setSidechainFilter()
| void Dynamics::setSidechainFilter |
( |
float | highpassHz, |
|
|
float | lowpassHz ) |
Filters the detector's view of the signal without touching what is heard.
A high pass stops kick drums pumping the whole mix; a low pass stops cymbals doing the same.
- Parameters
-
| highpassHz | detector high pass, 0 for none |
| lowpassHz | detector low pass, 0 for none |
◆ setDetectorPeak()
| void Dynamics::setDetectorPeak |
( |
float | freqHz, |
|
|
float | q, |
|
|
float | gainDb ) |
A peak in the detector path, again heard only through what it makes the gain do.
Boost around 6 kHz and the compressor turns into a de-esser; boost the low mids and it leans on boxiness.
- Parameters
-
| freqHz | centre frequency |
| q | width |
| gainDb | boost or cut, 0 disables the filter |
◆ setAutoMakeupGain()
| void Dynamics::setAutoMakeupGain |
( |
bool | enabled | ) |
|
Enables automatic makeup gain for compressor/limiter modes.
When enabled, gain is automatically applied to compensate for the gain reduction, bringing peaks back to 0dB.
- Parameters
-
| enabled | True to enable auto makeup gain |
◆ reset()
◆ process() [1/2]
| void Dynamics::process |
( |
juce::AudioSampleBuffer & | buffer, |
|
|
juce::AudioSampleBuffer * | envelopeOut = nullptr ) |
Processes a buffer, with the detector following that same buffer.
- Parameters
-
| buffer | audio to process, in place |
| envelopeOut | optional detector envelope, as a linear level. Written to channel 0 when linked and to every channel otherwise, so it needs as many channels as the processor has. |
◆ process() [2/2]
| void Dynamics::process |
( |
juce::AudioSampleBuffer & | buffer, |
|
|
const juce::AudioSampleBuffer & | sidechain, |
|
|
juce::AudioSampleBuffer * | envelopeOut = nullptr ) |
Processes a buffer, with the detector following a separate side chain.
The gain is worked out from sidechain and applied to buffer: ducking, de-essing, and gating something on a source other than itself. A gated reverb is the case that shows why it matters - keyed off its own output, a gate can only chase an envelope the reverb has already smeared, so it opens softly instead of on the transient and its timing shifts whenever the decay does.
- Parameters
-
| buffer | audio to process, in place |
| sidechain | what the detector follows. Needs at least as many samples as buffer; fewer channels is fine, the last one is reused, so a mono key drives them all. Input gain scales what the detector sees here just as it does without a side chain. |
| envelopeOut | optional detector envelope, as above |
◆ getInputTracker()
◆ getOutputTracker()
◆ getReductionTracker()
◆ calcCurve()
| float Dynamics::calcCurve |
( |
float | detectorValue | ) |
|
The documentation for this class was generated from the following file: