Skip to content

Commit

Permalink
make mic ducking use strength the same way in Auto & Man mode
Browse files Browse the repository at this point in the history
Previously, engine/enginetalkoverducking returned opposite values
for 'strength' in Auto and Manual mode. This commit removes the
inversion from Auto mode, thus the Strength knob always affects the
music volume in the same way with both modes:
* fully left: music muted completely
* fully right: music volume unchanged
  • Loading branch information
ronso0 committed May 5, 2020
1 parent 212b198 commit 689395d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/engine/enginesidechaincompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ EngineSideChainCompressor::EngineSideChainCompressor(const char* group)
: m_compressRatio(0.0),
m_bAboveThreshold(false),
m_threshold(1.0),
m_strength(0.0),
m_strength(1.0),
m_attackTime(0),
m_decayTime(0),
m_attackPerFrame(0.0),
Expand Down Expand Up @@ -54,28 +54,28 @@ void EngineSideChainCompressor::processKey(const CSAMPLE* pIn, const int iBuffer

double EngineSideChainCompressor::calculateCompressedGain(int frames) {
if (m_bAboveThreshold) {
if (m_compressRatio < m_strength) {
m_compressRatio += m_attackPerFrame * frames;
if (m_compressRatio > m_strength) {
if (m_compressRatio > m_strength) {
m_compressRatio -= m_attackPerFrame * frames;
if (m_compressRatio < m_strength) {
// If we overshot, clamp.
m_compressRatio = m_strength;
}
} else if (m_compressRatio > m_strength) {
} else if (m_compressRatio < m_strength) {
// If the strength param was changed, we might be compressing too much.
m_compressRatio -= m_decayPerFrame * frames;
m_compressRatio += m_decayPerFrame * frames;
}
} else {
if (m_compressRatio > 0) {
m_compressRatio -= m_decayPerFrame * frames;
if (m_compressRatio < 0) {
m_compressRatio += m_decayPerFrame * frames;
if (m_compressRatio > 1) {
// If we overshot, clamp.
m_compressRatio = 0;
m_compressRatio = 1;
}
} else if (m_compressRatio < 0) {
// Complain loudly.
qWarning() << "Programming error, below-zero compression detected.";
m_compressRatio += m_attackPerFrame * frames;
}
}
return (1. - m_compressRatio);
return m_compressRatio;
}

0 comments on commit 689395d

Please sign in to comment.