summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-09-25 17:08:35 +0200
committerJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-09-25 17:12:30 +0200
commitda13a03b551d141a46c52365c634904c30e37bd9 (patch)
treee40609a2fe18214ba7b312417f9df63e22819fd2 /src/engine
parent14bbb1c900e108e586e36727f02799e8b2524173 (diff)
engine/enginetalkoverducking: Make lossy type casts explicit
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/enginetalkoverducking.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/engine/enginetalkoverducking.cpp b/src/engine/enginetalkoverducking.cpp
index e67df8b131..d6f41ebea9 100644
--- a/src/engine/enginetalkoverducking.cpp
+++ b/src/engine/enginetalkoverducking.cpp
@@ -1,7 +1,11 @@
#include "control/controlproxy.h"
#include "engine/enginetalkoverducking.h"
-#define DUCK_THRESHOLD 0.1
+namespace {
+
+constexpr CSAMPLE kDuckThreshold = 0.1f;
+
+}
EngineTalkoverDucking::EngineTalkoverDucking(
UserSettingsPointer pConfig, const QString& group)
@@ -23,10 +27,10 @@ EngineTalkoverDucking::EngineTalkoverDucking(
// candidate for customization is the threshold, which may be too low for
// noisy club situations.
setParameters(
- DUCK_THRESHOLD,
- m_pDuckStrength->get(),
- m_pMasterSampleRate->get() / 2 * .1,
- m_pMasterSampleRate->get() / 2);
+ kDuckThreshold,
+ static_cast<CSAMPLE>(m_pDuckStrength->get()),
+ static_cast<unsigned int>(m_pMasterSampleRate->get() / 2 * .1),
+ static_cast<unsigned int>(m_pMasterSampleRate->get() / 2));
m_pTalkoverDucking = new ControlPushButton(ConfigKey(m_group, "talkoverDucking"));
m_pTalkoverDucking->setButtonMode(ControlPushButton::TOGGLE);
@@ -49,14 +53,17 @@ EngineTalkoverDucking::~EngineTalkoverDucking() {
void EngineTalkoverDucking::slotSampleRateChanged(double samplerate) {
setParameters(
- DUCK_THRESHOLD, m_pDuckStrength->get(),
- samplerate / 2 * .1, samplerate / 2);
+ kDuckThreshold,
+ static_cast<CSAMPLE>(m_pDuckStrength->get()),
+ static_cast<unsigned int>(samplerate / 2 * .1),
+ static_cast<unsigned int>(samplerate / 2));
}
void EngineTalkoverDucking::slotDuckStrengthChanged(double strength) {
- setParameters(
- DUCK_THRESHOLD, strength,
- m_pMasterSampleRate->get() / 2 * .1, m_pMasterSampleRate->get() / 2);
+ setParameters(kDuckThreshold,
+ static_cast<CSAMPLE>(strength),
+ static_cast<unsigned int>(m_pMasterSampleRate->get() / 2 * .1),
+ static_cast<unsigned int>(m_pMasterSampleRate->get() / 2));
m_pConfig->set(ConfigKey(m_group, "duckStrength"), ConfigValue(strength * 100));
}
@@ -68,12 +75,12 @@ CSAMPLE EngineTalkoverDucking::getGain(int numFrames) {
// Apply microphone ducking.
switch (getMode()) {
case EngineTalkoverDucking::OFF:
- return 1.0;
+ return 1.0f;
case EngineTalkoverDucking::AUTO:
case EngineTalkoverDucking::MANUAL:
- return calculateCompressedGain(numFrames);
+ return static_cast<CSAMPLE>(calculateCompressedGain(numFrames));
default:
DEBUG_ASSERT("!Unknown Ducking mode");
- return 1.0;
+ return 1.0f;
}
}