25float getSlope(
float ratio) {
return 1 / ratio - 1; }
26float getRatio(
float slope) {
return 1 / (slope + 1); }
31 float thresholdInDecibels,
33 float makeUpGainInDecibels)
36 float overShoot = inputLevelInDecibels - thresholdInDecibels;
38 return overShoot + inputLevelInDecibels + makeUpGainInDecibels;
77 return std::exp (-1.0f / (
static_cast<float> (
sampleRate) * timeInSeconds));
82 knee = kneeInDecibels;
108 float overShootInDecibels,
float knee,
float slope)
111 if (overShootInDecibels <= -
kneeHalf)
113 else if (overShootInDecibels > -
kneeHalf && overShootInDecibels <=
kneeHalf)
116 return slope * overShootInDecibels;
124 for (
int i = 0; i < numSamples; ++i)
127 const float levelInDecibels =
134 const float overShoot = levelInDecibels -
threshold;
138 const float diff = gainReduction -
state;
145 destination[i] =
state;
155 for (
int i = 0; i < numSamples; ++i)
156 destination[i] = std::pow (10.0f, 0.05f * (destination[i] +
makeUpGain));
162 for (
int i = 0; i < numSamples; ++i)
constexpr float FastLog2(float x)
Approximates the base-2 logarithm of a float to two decimal places, adapted from https://stackoverflo...
static constexpr float log2ToDb
void prepare(const double sampleRate)
void setMakeUpGain(const float makeUpGainInDecibels)
void getCharacteristic(float *inputLevelsInDecibels, float *destination, const int numSamples)
static float getCharacteristicSample(float inputLevelInDecibels, float kneeInDecibels, float thresholdInDecibels, float ratio, float makeUpGainInDecibels)
std::atomic< float > maxInputLevel
void computeGainInDecibelsFromSidechainSignal(const float *sideChainSignal, float *destination, const int numSamples)
static float applyCharacteristicToOverShoot(float overShootInDecibels, float knee, float slope)
void setThreshold(const float thresholdInDecibels)
void setReleaseTime(const float releaseTimeInSeconds)
std::atomic< float > maxGainReduction
void setAttackTime(const float attackTimeInSeconds)
void setRatio(const float ratio)
void setKnee(const float kneeInDecibels)
const float timeToGain(const float timeInSeconds)
void computeLinearGainFromSidechainSignal(const float *sideChainSignal, float *destination, const int numSamples)
float getRatio(float slope)
float getSlope(float ratio)