summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorronso0 <ronso0@mixxx.org>2020-05-05 07:28:31 +0200
committerDaniel Schürmann <daschuer@mixxx.org>2020-05-07 09:52:33 +0200
commita87a8ea6acfabd25c6d295f97f2ec50bf9d2905b (patch)
treecc594b7a0a3041cbd2f5a9a72eea9b50d169f000 /src
parent8af17c2a35b1fb14b348ff9bbfecbb45171972e0 (diff)
make mic ducking use strength the same way in Auto & Man mode
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, much like a Muisc Volume knob: * fully left: music muted completely * fully right: music volume unchanged
Diffstat (limited to 'src')
-rw-r--r--src/engine/enginesidechaincompressor.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/engine/enginesidechaincompressor.cpp b/src/engine/enginesidechaincompressor.cpp
index bd21e53914..e2bf54f2d6 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),
@@ -55,28 +55,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;
}