Squared gain when using double-smoothing
This commit is contained in:
parent
5bfcf6f151
commit
64c739b4fc
12
limiter.h
12
limiter.h
@ -116,6 +116,7 @@ struct LimiterSTFX : public BaseEffect {
|
|||||||
void reset() {
|
void reset() {
|
||||||
multiBuffer.reset();
|
multiBuffer.reset();
|
||||||
for (auto &e : channelEnvelopes) e.reset();
|
for (auto &e : channelEnvelopes) e.reset();
|
||||||
|
sqrtWet = (smoothingStages > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int latencySamples() const {
|
int latencySamples() const {
|
||||||
@ -134,8 +135,9 @@ struct LimiterSTFX : public BaseEffect {
|
|||||||
|
|
||||||
int attackSamples = delaySamplesTo;
|
int attackSamples = delaySamplesTo;
|
||||||
int holdSamples = std::ceil(holdMs*0.001*sampleRate);
|
int holdSamples = std::ceil(holdMs*0.001*sampleRate);
|
||||||
Sample releaseSamples = releaseMs*0.001*sampleRate;
|
Sample releaseSamples = releaseMs*0.001*sampleRate*smoothingStages;
|
||||||
int stages = smoothingStages;
|
int stages = smoothingStages;
|
||||||
|
sqrtWetSlew = 1/(Sample(attackSamples)*2 + 1);
|
||||||
|
|
||||||
for (auto &envelope : channelEnvelopes) {
|
for (auto &envelope : channelEnvelopes) {
|
||||||
envelope.peakHold.set(attackSamples + holdSamples);
|
envelope.peakHold.set(attackSamples + holdSamples);
|
||||||
@ -168,9 +170,16 @@ struct LimiterSTFX : public BaseEffect {
|
|||||||
Sample gain = channelGains[c];
|
Sample gain = channelGains[c];
|
||||||
// blend between individual/minimum gain
|
// blend between individual/minimum gain
|
||||||
gain += (minChannelGain - gain)*linkChannels;
|
gain += (minChannelGain - gain)*linkChannels;
|
||||||
|
if (smoothingStages > 1) {
|
||||||
|
gain *= gain;
|
||||||
|
sqrtWet += (1 - sqrtWet)*sqrtWetSlew;
|
||||||
|
} else {
|
||||||
|
sqrtWet *= 1 - sqrtWetSlew;
|
||||||
|
}
|
||||||
// smooth envelope gain
|
// smooth envelope gain
|
||||||
auto &envelope = channelEnvelopes[c];
|
auto &envelope = channelEnvelopes[c];
|
||||||
gain = envelope(gain);
|
gain = envelope(gain);
|
||||||
|
if (sqrtWet > Sample(1e-30)) gain += (std::sqrt(gain) - gain)*sqrtWet;
|
||||||
|
|
||||||
Sample delayed = block.fade(i,
|
Sample delayed = block.fade(i,
|
||||||
multiBuffer[c][i - delaySamplesFrom],
|
multiBuffer[c][i - delaySamplesFrom],
|
||||||
@ -185,6 +194,7 @@ struct LimiterSTFX : public BaseEffect {
|
|||||||
private:
|
private:
|
||||||
int channels = 0;
|
int channels = 0;
|
||||||
double maxDelayMs = 0;
|
double maxDelayMs = 0;
|
||||||
|
Sample sqrtWet = 0, sqrtWetSlew = 1;
|
||||||
signalsmith::delay::MultiBuffer<Sample> multiBuffer;
|
signalsmith::delay::MultiBuffer<Sample> multiBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user