Audacity 3.2.0
|
#include <GainReductionComputer.h>
Public Member Functions | |
GainReductionComputer () | |
~GainReductionComputer () | |
void | setAttackTime (const float attackTimeInSeconds) |
void | setReleaseTime (const float releaseTimeInSeconds) |
void | setKnee (const float kneeInDecibels) |
const float | getKnee () |
void | setThreshold (const float thresholdInDecibels) |
const float | getThreshold () |
void | setMakeUpGain (const float makeUpGainInDecibels) |
const float | getMakeUpGain () |
void | setRatio (const float ratio) |
void | getCharacteristic (float *inputLevelsInDecibels, float *destination, const int numSamples) |
float | getCharacteristicSample (const float inputLevelInDecibels) |
void | prepare (const double sampleRate) |
void | reset () |
void | computeGainInDecibelsFromSidechainSignal (const float *sideChainSignal, float *destination, const int numSamples) |
void | computeLinearGainFromSidechainSignal (const float *sideChainSignal, float *destination, const int numSamples) |
const float | getMaxInputLevelInDecibels () |
const float | getMaxGainReductionInDecibels () |
Static Public Member Functions | |
static float | getCharacteristicSample (float inputLevelInDecibels, float kneeInDecibels, float thresholdInDecibels, float ratio, float makeUpGainInDecibels) |
Private Member Functions | |
const float | timeToGain (const float timeInSeconds) |
const float | applyCharacteristicToOverShoot (const float overShootInDecibels) |
Static Private Member Functions | |
static float | applyCharacteristicToOverShoot (float overShootInDecibels, float knee, float slope) |
Private Attributes | |
double | sampleRate |
float | knee |
float | kneeHalf |
float | threshold |
float | attackTime |
float | releaseTime |
float | slope |
float | makeUpGain |
std::atomic< float > | maxInputLevel {-std::numeric_limits<float>::infinity()} |
std::atomic< float > | maxGainReduction {0} |
float | state |
float | alphaAttack |
float | alphaRelease |
This class acts as the side-chain path of a dynamic range compressor. It processes a given side-chain signal and computes the gain reduction samples depending on the parameters threshold, knee, attack-time, release-time, ratio, and make-up gain.
Definition at line 30 of file GainReductionComputer.h.
DanielRudrich::GainReductionComputer::GainReductionComputer | ( | ) |
Definition at line 41 of file GainReductionComputer.cpp.
References attackTime, knee, kneeHalf, makeUpGain, releaseTime, reset(), sampleRate, setRatio(), and threshold.
|
inline |
Definition at line 34 of file GainReductionComputer.h.
|
inlineprivate |
Definition at line 102 of file GainReductionComputer.cpp.
References applyCharacteristicToOverShoot(), knee, and slope.
|
staticprivate |
Definition at line 107 of file GainReductionComputer.cpp.
References knee, kneeHalf, and slope.
Referenced by applyCharacteristicToOverShoot(), computeGainInDecibelsFromSidechainSignal(), and getCharacteristicSample().
void DanielRudrich::GainReductionComputer::computeGainInDecibelsFromSidechainSignal | ( | const float * | sideChainSignal, |
float * | destination, | ||
const int | numSamples | ||
) |
Computes the gain reduction for a given side-chain signal. The values will be in decibels and will NOT contain the make-up gain.
Definition at line 119 of file GainReductionComputer.cpp.
References alphaAttack, alphaRelease, applyCharacteristicToOverShoot(), FastLog2(), log2ToDb, maxGainReduction, maxInputLevel, state, and threshold.
Referenced by computeLinearGainFromSidechainSignal().
void DanielRudrich::GainReductionComputer::computeLinearGainFromSidechainSignal | ( | const float * | sideChainSignal, |
float * | destination, | ||
const int | numSamples | ||
) |
Computes the linear gain including make-up gain for a given side-chain signal. The gain written to the destination can be directly applied to the signals which should be compressed.
Definition at line 152 of file GainReductionComputer.cpp.
References computeGainInDecibelsFromSidechainSignal(), and makeUpGain.
void DanielRudrich::GainReductionComputer::getCharacteristic | ( | float * | inputLevelsInDecibels, |
float * | destination, | ||
const int | numSamples | ||
) |
Computes the static output levels for an array of input levels in decibels. Useful for visualization of the compressor's characteristic. Will contain make-up gain.
Definition at line 160 of file GainReductionComputer.cpp.
References getCharacteristicSample().
float DanielRudrich::GainReductionComputer::getCharacteristicSample | ( | const float | inputLevelInDecibels | ) |
Computes the static output levels for a given input level in decibels. Useful for visualization of the compressor's characteristic. Will contain make-up gain.
Definition at line 166 of file GainReductionComputer.cpp.
References getCharacteristicSample(), DanielRudrich::anonymous_namespace{GainReductionComputer.cpp}::getRatio(), knee, makeUpGain, slope, and threshold.
|
static |
Definition at line 29 of file GainReductionComputer.cpp.
References applyCharacteristicToOverShoot(), DanielRudrich::anonymous_namespace{GainReductionComputer.cpp}::getSlope(), and slope.
Referenced by CompressorProcessor::EvaluateTransferFunction(), getCharacteristic(), and getCharacteristicSample().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void DanielRudrich::GainReductionComputer::prepare | ( | const double | sampleRate | ) |
Prepares the compressor with sampleRate and expected blockSize. Make sure you call this before you do any processing!
Definition at line 55 of file GainReductionComputer.cpp.
References alphaAttack, alphaRelease, attackTime, releaseTime, sampleRate, and timeToGain().
|
inline |
Resets the internal state of the compressor.
Definition at line 95 of file GainReductionComputer.h.
References state.
Referenced by GainReductionComputer().
void DanielRudrich::GainReductionComputer::setAttackTime | ( | const float | attackTimeInSeconds | ) |
Sets the attack time of the compressor in seconds.
Definition at line 63 of file GainReductionComputer.cpp.
References alphaAttack, attackTime, and timeToGain().
void DanielRudrich::GainReductionComputer::setKnee | ( | const float | kneeInDecibels | ) |
void DanielRudrich::GainReductionComputer::setMakeUpGain | ( | const float | makeUpGainInDecibels | ) |
Sets the make-up-gain of the compressor in decibels.
Definition at line 91 of file GainReductionComputer.cpp.
References makeUpGain.
void DanielRudrich::GainReductionComputer::setRatio | ( | const float | ratio | ) |
Sets the ratio of input-output signal above threshold. Set to 1 for no compression, up to infinity for a brickwall limiter.
Definition at line 96 of file GainReductionComputer.cpp.
References DanielRudrich::anonymous_namespace{GainReductionComputer.cpp}::getSlope(), and slope.
Referenced by GainReductionComputer().
void DanielRudrich::GainReductionComputer::setReleaseTime | ( | const float | releaseTimeInSeconds | ) |
Sets the release time of the compressorin seconds
Definition at line 69 of file GainReductionComputer.cpp.
References alphaRelease, releaseTime, and timeToGain().
void DanielRudrich::GainReductionComputer::setThreshold | ( | const float | thresholdInDecibels | ) |
Sets the threshold above which the compressor will start to compress the signal.
Definition at line 86 of file GainReductionComputer.cpp.
References threshold.
|
inlineprivate |
Definition at line 75 of file GainReductionComputer.cpp.
References sampleRate.
Referenced by prepare(), setAttackTime(), and setReleaseTime().
|
private |
Definition at line 133 of file GainReductionComputer.h.
Referenced by computeGainInDecibelsFromSidechainSignal(), prepare(), and setAttackTime().
|
private |
Definition at line 134 of file GainReductionComputer.h.
Referenced by computeGainInDecibelsFromSidechainSignal(), prepare(), and setReleaseTime().
|
private |
Definition at line 122 of file GainReductionComputer.h.
Referenced by GainReductionComputer(), prepare(), and setAttackTime().
|
private |
Definition at line 120 of file GainReductionComputer.h.
Referenced by applyCharacteristicToOverShoot(), GainReductionComputer(), getCharacteristicSample(), getKnee(), and setKnee().
|
private |
Definition at line 120 of file GainReductionComputer.h.
Referenced by applyCharacteristicToOverShoot(), GainReductionComputer(), and setKnee().
|
private |
Definition at line 125 of file GainReductionComputer.h.
Referenced by computeLinearGainFromSidechainSignal(), GainReductionComputer(), getCharacteristicSample(), getMakeUpGain(), and setMakeUpGain().
|
private |
Definition at line 128 of file GainReductionComputer.h.
Referenced by computeGainInDecibelsFromSidechainSignal(), and getMaxGainReductionInDecibels().
|
private |
Definition at line 127 of file GainReductionComputer.h.
Referenced by computeGainInDecibelsFromSidechainSignal(), and getMaxInputLevelInDecibels().
|
private |
Definition at line 123 of file GainReductionComputer.h.
Referenced by GainReductionComputer(), prepare(), and setReleaseTime().
|
private |
Definition at line 117 of file GainReductionComputer.h.
Referenced by GainReductionComputer(), prepare(), and timeToGain().
|
private |
Definition at line 124 of file GainReductionComputer.h.
Referenced by applyCharacteristicToOverShoot(), getCharacteristicSample(), and setRatio().
|
private |
Definition at line 131 of file GainReductionComputer.h.
Referenced by computeGainInDecibelsFromSidechainSignal(), and reset().
|
private |
Definition at line 121 of file GainReductionComputer.h.
Referenced by computeGainInDecibelsFromSidechainSignal(), GainReductionComputer(), getCharacteristicSample(), getThreshold(), and setThreshold().