diff options
author | Daniel Schürmann <daschuer@mixxx.org> | 2020-05-06 23:40:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-06 23:40:13 +0200 |
commit | e2b0fc574fca418825a239bc6cdfaef0449d3016 (patch) | |
tree | c0ef53c160ec1dbc07ae24ea9d1d1b113d110ba2 | |
parent | c5e816431a07dc39f976947727dd4a1b8fe266d2 (diff) | |
parent | 6232a3364ee71dd0c6d8b77d5e919288faf1c434 (diff) |
Merge pull request #2750 from ronso0/mic-ducking-strength
make mic ducking use strength the same way in Auto & Man mode
-rw-r--r-- | src/engine/enginesidechaincompressor.cpp | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/engine/enginesidechaincompressor.cpp b/src/engine/enginesidechaincompressor.cpp index 4f9b6fc634..7ef6793994 100644 --- a/src/engine/enginesidechaincompressor.cpp +++ b/src/engine/enginesidechaincompressor.cpp @@ -3,10 +3,10 @@ #include "engine/enginesidechaincompressor.h" EngineSideChainCompressor::EngineSideChainCompressor(const char* group) - : m_compressRatio(0.0), + : m_compressRatio(1.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), @@ -54,28 +54,27 @@ 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) { + VERIFY_OR_DEBUG_ASSERT(m_compressRatio >= 0) { + qWarning() << "Programming error, below-zero compression detected."; + } + if (m_compressRatio < 1) { + 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; } |