|
Gin
|
Dynamics processor supporting compression, limiting, expansion, and gating. More...
#include <gin_dynamics.h>
Public Types | |
| enum | Type { compressor , limiter , expander , gate , compexp } |
| Dynamics processing types. More... | |
Public Member Functions | |
| 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:
Usage:
Dynamics processing types.
Determines the type of dynamics processing applied:
|
default |
|
default |
| void Dynamics::setParams | ( | float | attackS, |
| float | holdS, | ||
| float | releaseS, | ||
| float | thresh, | ||
| float | ratio, | ||
| float | kneeWidth | ||
| ) |
| void Dynamics::setDetectorMode | ( | EnvelopeDetector::Mode | m | ) |
How the detector measures level: peak, mean square or RMS.
Averaging window for the ms and rms detector modes, in seconds.
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.
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.
| int Dynamics::getLatencySamples | ( | ) | const |
Lookahead delay in samples, for AudioProcessor::setLatencySamples().
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.
| highpassHz | detector high pass, 0 for none |
| lowpassHz | detector low pass, 0 for none |
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.
| freqHz | centre frequency |
| q | width |
| gainDb | boost or cut, 0 disables the filter |
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.
| enabled | True to enable auto makeup gain |
| void Dynamics::reset | ( | ) |
| void Dynamics::process | ( | juce::AudioSampleBuffer & | buffer, |
| juce::AudioSampleBuffer * | envelopeOut = nullptr |
||
| ) |
Processes a buffer, with the detector following that same buffer.
| 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. |
| 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.
| 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 |
| const LevelTracker & Dynamics::getInputTracker | ( | ) |
| const LevelTracker & Dynamics::getOutputTracker | ( | ) |
| const LevelTracker & Dynamics::getReductionTracker | ( | ) |