summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/effects/builtin/phasereffect.cpp47
-rw-r--r--src/effects/builtin/reverbeffect.cpp8
-rw-r--r--src/effects/builtin/tremoloeffect.cpp17
-rw-r--r--src/engine/bufferscalers/enginebufferscalelinear.cpp10
-rw-r--r--src/engine/effects/engineeffectchain.cpp18
-rw-r--r--src/engine/enginemaster.cpp8
-rw-r--r--src/engine/enginepregain.cpp37
-rw-r--r--src/engine/enginepregain.h8
-rw-r--r--src/engine/enginetalkoverducking.cpp33
-rw-r--r--src/engine/enginevumeter.cpp39
-rw-r--r--src/engine/enginevumeter.h30
-rw-r--r--src/engine/sidechain/enginerecord.cpp3
12 files changed, 125 insertions, 133 deletions
diff --git a/src/effects/builtin/phasereffect.cpp b/src/effects/builtin/phasereffect.cpp
index 1556d3b8aa..718e9fd6dc 100644
--- a/src/effects/builtin/phasereffect.cpp
+++ b/src/effects/builtin/phasereffect.cpp
@@ -4,7 +4,10 @@
#include "util/math.h"
-const unsigned int updateCoef = 32;
+namespace {
+constexpr unsigned int updateCoef = 32;
+constexpr auto kDoublePi = static_cast<CSAMPLE>(2.0 * M_PI);
+} // namespace
// static
QString PhaserEffect::getId() {
@@ -149,7 +152,7 @@ void PhaserEffect::processChannel(const ChannelHandle& handle,
CSAMPLE depth = 0;
if (enableState != EffectEnableState::Disabling) {
- depth = m_pDepthParameter->value();
+ depth = static_cast<CSAMPLE>(m_pDepthParameter->value());
}
double periodParameter = m_pLFOPeriodParameter->value();
@@ -167,11 +170,11 @@ void PhaserEffect::processChannel(const ChannelHandle& handle,
}
// freqSkip is used to calculate the phase independently for each channel,
// so do not multiply periodSamples by the number of channels.
- CSAMPLE freqSkip = 1.0 / periodSamples * 2.0 * M_PI;
+ const auto freqSkip = static_cast<CSAMPLE>(1.0f / periodSamples * kDoublePi);
- CSAMPLE feedback = m_pFeedbackParameter->value();
- CSAMPLE range = m_pRangeParameter->value();
- int stages = 2 * m_pStagesParameter->value();
+ const auto feedback = static_cast<CSAMPLE>(m_pFeedbackParameter->value());
+ const auto range = static_cast<CSAMPLE>(m_pRangeParameter->value());
+ const auto stages = static_cast<int>(2 * m_pStagesParameter->value());
CSAMPLE* oldInLeft = pState->oldInLeft;
CSAMPLE* oldOutLeft = pState->oldOutLeft;
@@ -189,7 +192,7 @@ void PhaserEffect::processChannel(const ChannelHandle& handle,
/ bufferParameters.framesPerBuffer();
const CSAMPLE_GAIN depthStart = oldDepth + depthDelta;
- int stereoCheck = m_pStereoParameter->value();
+ const auto stereoCheck = static_cast<int>(m_pStereoParameter->value());
int counter = 0;
for (unsigned int i = 0;
@@ -199,25 +202,27 @@ void PhaserEffect::processChannel(const ChannelHandle& handle,
right = pInput[i + 1] + tanh(right * feedback);
// For stereo enabled, the channels are out of phase
- pState->leftPhase = fmodf(pState->leftPhase + freqSkip, 2.0 * M_PI);
- pState->rightPhase = fmodf(pState->rightPhase + freqSkip + M_PI * stereoCheck, 2.0 * M_PI);
+ pState->leftPhase = fmodf(pState->leftPhase + freqSkip, kDoublePi);
+ pState->rightPhase = fmodf(
+ pState->rightPhase + freqSkip + static_cast<float>(M_PI) * stereoCheck,
+ kDoublePi);
// Updating filter coefficients once every 'updateCoef' samples to avoid
// extra computing
if ((counter++) % updateCoef == 0) {
- CSAMPLE delayLeft = 0.5 + 0.5 * sin(pState->leftPhase);
- CSAMPLE delayRight = 0.5 + 0.5 * sin(pState->rightPhase);
+ const auto delayLeft = static_cast<CSAMPLE>(0.5 + 0.5 * sin(pState->leftPhase));
+ const auto delayRight = static_cast<CSAMPLE>(0.5 + 0.5 * sin(pState->rightPhase));
- // Coefficient computing based on the following:
- // https://ccrma.stanford.edu/~jos/pasp/Classic_Virtual_Analog_Phase.html
- CSAMPLE wLeft = range * delayLeft;
- CSAMPLE wRight = range * delayRight;
+ // Coefficient computing based on the following:
+ // https://ccrma.stanford.edu/~jos/pasp/Classic_Virtual_Analog_Phase.html
+ CSAMPLE wLeft = range * delayLeft;
+ CSAMPLE wRight = range * delayRight;
- CSAMPLE tanwLeft = tanh(wLeft / 2);
- CSAMPLE tanwRight = tanh(wRight / 2);
+ CSAMPLE tanwLeft = tanh(wLeft / 2);
+ CSAMPLE tanwRight = tanh(wRight / 2);
- filterCoefLeft = (1.0 - tanwLeft) / (1.0 + tanwLeft);
- filterCoefRight = (1.0 - tanwRight) / (1.0 + tanwRight);
+ filterCoefLeft = (1.0f - tanwLeft) / (1.0f + tanwLeft);
+ filterCoefRight = (1.0f - tanwRight) / (1.0f + tanwRight);
}
left = processSample(left, oldInLeft, oldOutLeft, filterCoefLeft, stages);
@@ -226,8 +231,8 @@ void PhaserEffect::processChannel(const ChannelHandle& handle,
const CSAMPLE_GAIN depth = depthStart + depthDelta * (i / bufferParameters.channelCount());
// Computing output combining the original and processed sample
- pOutput[i] = pInput[i] * (1.0 - 0.5 * depth) + left * depth * 0.5;
- pOutput[i + 1] = pInput[i + 1] * (1.0 - 0.5 * depth) + right * depth * 0.5;
+ pOutput[i] = pInput[i] * (1.0f - 0.5f * depth) + left * depth * 0.5f;
+ pOutput[i + 1] = pInput[i + 1] * (1.0f - 0.5f * depth) + right * depth * 0.5f;
}
pState->oldDepth = depth;
diff --git a/src/effects/builtin/reverbeffect.cpp b/src/effects/builtin/reverbeffect.cpp
index 7fdf3ade0f..320b693490 100644
--- a/src/effects/builtin/reverbeffect.cpp
+++ b/src/effects/builtin/reverbeffect.cpp
@@ -100,10 +100,10 @@ void ReverbEffect::processChannel(const ChannelHandle& handle,
Q_UNUSED(handle);
Q_UNUSED(groupFeatures);
- const auto decay = m_pDecayParameter->value();
- const auto bandwidth = m_pBandWidthParameter->value();
- const auto damping = m_pDampingParameter->value();
- const auto sendCurrent = m_pSendParameter->value();
+ const auto decay = static_cast<sample_t>(m_pDecayParameter->value());
+ const auto bandwidth = static_cast<sample_t>(m_pBandWidthParameter->value());
+ const auto damping = static_cast<sample_t>(m_pDampingParameter->value());
+ const auto sendCurrent = static_cast<sample_t>(m_pSendParameter->value());
// Reinitialize the effect when turning it on to prevent replaying the old buffer
// from the last time the effect was enabled.
diff --git a/src/effects/builtin/tremoloeffect.cpp b/src/effects/builtin/tremoloeffect.cpp
index 17200a7d1c..e030942904 100644
--- a/src/effects/builtin/tremoloeffect.cpp
+++ b/src/effects/builtin/tremoloeffect.cpp
@@ -165,7 +165,8 @@ void TremoloEffect::processChannel(const ChannelHandle& handle,
|| quantizeEnabling
|| tripletDisabling) {
if (gf.has_beat_length_sec && gf.has_beat_fraction) {
- currentFrame = gf.beat_fraction * gf.beat_length_sec * bufferParameters.sampleRate();
+ currentFrame = static_cast<unsigned int>(gf.beat_fraction *
+ gf.beat_length_sec * bufferParameters.sampleRate());
} else {
currentFrame = 0;
}
@@ -176,20 +177,22 @@ void TremoloEffect::processChannel(const ChannelHandle& handle,
double rate = m_pRateParameter->value();
if (gf.has_beat_length_sec && gf.has_beat_fraction) {
if (m_pQuantizeParameter->toBool()) {
- int divider = log2(rate);
+ const auto divider = static_cast<int>(log2(rate));
rate = pow(2, divider);
if (m_pTripletParameter->toBool()) {
rate *= 3.0;
}
}
- int framePerBeat = gf.beat_length_sec * bufferParameters.sampleRate();
- framePerPeriod = framePerBeat / rate;
+ const auto framePerBeat = static_cast<int>(
+ gf.beat_length_sec * bufferParameters.sampleRate());
+ framePerPeriod = static_cast<int>(framePerBeat / rate);
} else {
- framePerPeriod = bufferParameters.sampleRate() / rate;
+ framePerPeriod = static_cast<int>(bufferParameters.sampleRate() / rate);
}
- unsigned int phaseOffsetFrame = m_pPhaseParameter->value() * framePerPeriod;
+ const auto phaseOffsetFrame = static_cast<unsigned int>(
+ m_pPhaseParameter->value() * framePerPeriod);
currentFrame = currentFrame % framePerPeriod;
for (unsigned int i = 0;
@@ -226,7 +229,7 @@ void TremoloEffect::processChannel(const ChannelHandle& handle,
}
for (int channel = 0; channel < bufferParameters.channelCount(); channel++) {
- pOutput[i+channel] = gain * pInput[i+channel];
+ pOutput[i + channel] = static_cast<CSAMPLE_GAIN>(gain) * pInput[i + channel];
}
currentFrame++;
diff --git a/src/engine/bufferscalers/enginebufferscalelinear.cpp b/src/engine/bufferscalers/enginebufferscalelinear.cpp
index 89e19a2a60..78aca3ecb4 100644
--- a/src/engine/bufferscalers/enginebufferscalelinear.cpp
+++ b/src/engine/bufferscalers/enginebufferscalelinear.cpp
@@ -67,8 +67,8 @@ double EngineBufferScaleLinear::scaleBuffer(
m_dOldRate = m_dRate; // If cleared, don't interpolate rate.
m_bClear = false;
}
- float rate_add_old = m_dOldRate; // Smoothly interpolate to new playback rate
- float rate_add_new = m_dRate;
+ double rate_add_old = m_dOldRate; // Smoothly interpolate to new playback rate
+ double rate_add_new = m_dRate;
SINT frames_read = 0;
if (rate_add_new * rate_add_old < 0) {
@@ -177,9 +177,9 @@ SINT EngineBufferScaleLinear::do_copy(CSAMPLE* buf, SINT buf_size) {
// Stretch a specified buffer worth of audio using linear interpolation
SINT EngineBufferScaleLinear::do_scale(CSAMPLE* buf, SINT buf_size) {
- float rate_old = m_dOldRate;
- const float rate_new = m_dRate;
- const float rate_diff = rate_new - rate_old;
+ double rate_old = m_dOldRate;
+ const double rate_new = m_dRate;
+ const double rate_diff = rate_new - rate_old;
// Update the old base rate because we only need to
// interpolate/ramp up the pitch changes once.
diff --git a/src/engine/effects/engineeffectchain.cpp b/src/engine/effects/engineeffectchain.cpp
index 9ea84e669f..2a8b5ac137 100644
--- a/src/engine/effects/engineeffectchain.cpp
+++ b/src/engine/effects/engineeffectchain.cpp
@@ -77,7 +77,7 @@ bool EngineEffectChain::removeEffect(EngineEffect* pEffect, int iIndex) {
bool EngineEffectChain::updateParameters(const EffectsRequest& message) {
// TODO(rryan): Parameter interpolation.
m_mixMode = message.SetEffectChainParameters.mix_mode;
- m_dMix = message.SetEffectChainParameters.mix;
+ m_dMix = static_cast<CSAMPLE>(message.SetEffectChainParameters.mix);
if (m_enableState != EffectEnableState::Disabled && !message.SetEffectParameters.enabled) {
m_enableState = EffectEnableState::Disabling;
@@ -315,15 +315,23 @@ bool EngineEffectChain::process(const ChannelHandle& inputHandle,
// Dry/Wet mode: output = (input * (1-mix knob)) + (wet * mix knob)
SampleUtil::copy2WithRampingGain(
pOut,
- pIn, 1.0 - lastCallbackMixKnob, 1.0 - currentMixKnob,
- pIntermediateInput, lastCallbackMixKnob, currentMixKnob,
+ pIn,
+ 1.0f - lastCallbackMixKnob,
+ 1.0f - currentMixKnob,
+ pIntermediateInput,
+ lastCallbackMixKnob,
+ currentMixKnob,
numSamples);
} else {
// Dry+Wet mode: output = input + (wet * mix knob)
SampleUtil::copy2WithRampingGain(
pOut,
- pIn, 1.0, 1.0,
- pIntermediateInput, lastCallbackMixKnob, currentMixKnob,
+ pIn,
+ 1.0f,
+ 1.0f,
+ pIntermediateInput,
+ lastCallbackMixKnob,
+ currentMixKnob,
numSamples);
}
}
diff --git a/src/engine/enginemaster.cpp b/src/engine/enginemaster.cpp
index b38914eaea..e86457b2eb 100644
--- a/src/engine/enginemaster.cpp
+++ b/src/engine/enginemaster.cpp
@@ -412,9 +412,9 @@ void EngineMaster::process(const int iBufferSize) {
CSAMPLE pflMixGainInHeadphones = 1;
CSAMPLE masterMixGainInHeadphones = 0;
if (masterEnabled) {
- CSAMPLE cf_val = m_pHeadMix->get();
- pflMixGainInHeadphones = 0.5 * (-cf_val + 1.);
- masterMixGainInHeadphones = 0.5 * (cf_val + 1.);
+ const auto cf_val = static_cast<CSAMPLE_GAIN>(m_pHeadMix->get());
+ pflMixGainInHeadphones = 0.5f * (-cf_val + 1.0f);
+ masterMixGainInHeadphones = 0.5f * (cf_val + 1.0f);
// qDebug() << "head val " << cf_val << ", head " << chead_gain
// << ", master " << cmaster_gain;
}
@@ -710,7 +710,7 @@ void EngineMaster::process(const int iBufferSize) {
// Balance values
CSAMPLE balright = 1.;
CSAMPLE balleft = 1.;
- CSAMPLE bal = m_pBalance->get();
+ const auto bal = static_cast<CSAMPLE_GAIN>(m_pBalance->get());
if (bal > 0.) {
balleft -= bal;
} else if (bal < 0.) {
diff --git a/src/engine/enginepregain.cpp b/src/engine/enginepregain.cpp
index ee68846028..7a256b26d8 100644
--- a/src/engine/enginepregain.cpp
+++ b/src/engine/enginepregain.cpp
@@ -11,10 +11,13 @@
#include "util/sample.h"
namespace {
- constexpr double kSpeedGainMultiplyer = 4.0; // Bends the speed to gain curve for a natural vinyl sound
- constexpr double kMaxTotalGainBySpeed = 0.9; // -1 dB to not risk any clipping even for lossy track that may
- // have samples above 1.0
- const double kSpeedOneDiv = log10((1 * kSpeedGainMultiplyer) + 1); // value to normalize gain to 1 at speed one
+
+// Bends the speed to gain curve for a natural vinyl sound
+constexpr float kSpeedGainMultiplier = 4.0f;
+// -1 dB to not risk any clipping even for lossy track that may have samples above 1.0
+constexpr float kMaxTotalGainBySpeed = 0.9f;
+// value to normalize gain to 1 at speed one
+const float kSpeedOneDiv = log10((1 * kSpeedGainMultiplier) + 1);
} // anonymous namespace
ControlPotmeter* EnginePregain::s_pReplayGainBoost = NULL;
@@ -64,8 +67,8 @@ void EnginePregain::setSpeedAndScratching(double speed, bool scratching) {
}
void EnginePregain::process(CSAMPLE* pInOut, const int iBufferSize) {
- const float fReplayGain = m_pCOReplayGain->get();
- float fReplayGainCorrection;
+ const auto fReplayGain = static_cast<CSAMPLE_GAIN>(m_pCOReplayGain->get());
+ CSAMPLE_GAIN fReplayGainCorrection;
if (!s_pEnableReplayGain->toBool() || m_pPassthroughEnabled->toBool()) {
// Override replaygain value if passing through
// TODO(XXX): consider a good default.
@@ -87,19 +90,19 @@ void EnginePregain::process(CSAMPLE* pInOut, const int iBufferSize) {
// full process for one second.
// So we need to alter gain each time ::process is called.
- const float fullReplayGainBoost = fReplayGain *
- (float)s_pReplayGainBoost->get();
+ const float fullReplayGainBoost =
+ fReplayGain * static_cast<float>(s_pReplayGainBoost->get());
// This means that a ReplayGain value has been calculated after the
// track has been loaded
- const double kFadeSeconds = 1.0;
+ const float kFadeSeconds = 1.0;
if (m_bSmoothFade) {
- double seconds = m_timer.elapsed().toDoubleSeconds();
+ float seconds = static_cast<float>(m_timer.elapsed().toDoubleSeconds());
if (seconds < kFadeSeconds) {
// Fade smoothly
- double fadeFrac = seconds / kFadeSeconds;
- fReplayGainCorrection = m_fPrevGain * (1.0 - fadeFrac) +
+ const float fadeFrac = seconds / kFadeSeconds;
+ fReplayGainCorrection = m_fPrevGain * (1.0f - fadeFrac) +
fadeFrac * fullReplayGainBoost;
} else {
m_bSmoothFade = false;
@@ -131,16 +134,19 @@ void EnginePregain::process(CSAMPLE* pInOut, const int iBufferSize) {
// we do not add more gain then we found in the original track.
// This compensates a negative ReplayGain or PreGain setting.
- double speedGain = log10((fabs(m_dSpeed) * kSpeedGainMultiplyer) + 1) / kSpeedOneDiv;
+ CSAMPLE_GAIN speedGain = log10((fabs(static_cast<CSAMPLE_GAIN>(m_dSpeed)) *
+ kSpeedGainMultiplier) +
+ 1) /
+ kSpeedOneDiv;
// Limit speed Gain to 0 dB if totalGain is already > 0.9 or Limit the
// resulting totalGain to 0.9 for all other cases. This should avoid clipping even
// if the source track has some samples above 1.0 due to lossy codecs.
if (totalGain > kMaxTotalGainBySpeed) {
- speedGain = math_min(1.0, speedGain);
+ speedGain = math_min(1.0f, speedGain);
} else {
speedGain = math_min(kMaxTotalGainBySpeed / totalGain, speedGain);
}
- totalGain *= speedGain;
+ totalGain *= static_cast<CSAMPLE_GAIN>(speedGain);
if ((m_dSpeed * m_dOldSpeed < 0) && m_scratching) {
// direction changed, go though zero if scratching
@@ -160,4 +166,3 @@ void EnginePregain::collectFeatures(GroupFeatureState* pGroupFeatures) const {
pGroupFeatures->gain = m_pPotmeterPregain->get();
pGroupFeatures->has_gain = true;
}
-
diff --git a/src/engine/enginepregain.h b/src/engine/enginepregain.h
index 7e99332157..6248b40261 100644
--- a/src/engine/enginepregain.h
+++ b/src/engine/enginepregain.h
@@ -1,5 +1,4 @@
-#ifndef ENGINEPREGAIN_H
-#define ENGINEPREGAIN_H
+#pragma once
#include "engine/engineobject.h"
#include "control/controlobject.h"
@@ -33,8 +32,7 @@ class EnginePregain : public EngineObject {
double m_dOldSpeed;
double m_dNonScratchSpeed;
bool m_scratching;
- CSAMPLE_GAIN
- m_fPrevGain;
+ CSAMPLE_GAIN m_fPrevGain;
ControlAudioTaperPot* m_pPotmeterPregain;
ControlObject* m_pTotalGain;
ControlObject* m_pCOReplayGain;
@@ -45,5 +43,3 @@ class EnginePregain : public EngineObject {
bool m_bSmoothFade;
PerformanceTimer m_timer;
};
-
-#endif
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;
}
}
diff --git a/src/engine/enginevumeter.cpp b/src/engine/enginevumeter.cpp
index 87989b5ca3..6443de799f 100644
--- a/src/engine/enginevumeter.cpp
+++ b/src/engine/enginevumeter.cpp
@@ -1,19 +1,3 @@
-/***************************************************************************
- enginevumeter.cpp - description
- -------------------
- copyright : (C) 2002 by Tue and Ken Haste Andersen
- email :
-***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
#include "engine/enginevumeter.h"
#include "control/controlproxy.h"
@@ -21,6 +5,19 @@
#include "util/math.h"
#include "util/sample.h"
+namespace {
+
+// Rate at which the vumeter is updated (using a sample rate of 44100 Hz):
+constexpr int kVuUpdateRate = 30; // in 1/s, fits to display frame rate
+constexpr int kPeakDuration = 500; // in ms
+
+// Smoothing Factors
+// Must be from 0-1 the lower the factor, the more smoothing that is applied
+constexpr CSAMPLE kAttackSmoothing = 1.0f; // .85
+constexpr CSAMPLE kDecaySmoothing = 0.1f; //.16//.4
+
+} // namespace
+
EngineVuMeter::EngineVuMeter(QString group) {
// The VUmeter widget is controlled via a controlpotmeter, which means
// that it should react on the setValue(int) signal.
@@ -68,7 +65,7 @@ void EngineVuMeter::process(CSAMPLE* pIn, const int iBufferSize) {
m_iSamplesCalculated += iBufferSize / 2;
// Are we ready to update the VU meter?:
- if (m_iSamplesCalculated > (sampleRate / VU_UPDATE_RATE)) {
+ if (m_iSamplesCalculated > (sampleRate / kVuUpdateRate)) {
doSmooth(m_fRMSvolumeL,
log10(SHRT_MAX * m_fRMSvolumeSumL
/ (m_iSamplesCalculated * 1000) + 1));
@@ -99,7 +96,7 @@ void EngineVuMeter::process(CSAMPLE* pIn, const int iBufferSize) {
if (clipped & SampleUtil::CLIPPING_LEFT) {
m_ctrlPeakIndicatorL->set(1.);
- m_peakDurationL = PEAK_DURATION * sampleRate / iBufferSize / 2000;
+ m_peakDurationL = kPeakDuration * sampleRate / iBufferSize / 2000;
} else if (m_peakDurationL <= 0) {
m_ctrlPeakIndicatorL->set(0.);
} else {
@@ -108,7 +105,7 @@ void EngineVuMeter::process(CSAMPLE* pIn, const int iBufferSize) {
if (clipped & SampleUtil::CLIPPING_RIGHT) {
m_ctrlPeakIndicatorR->set(1.);
- m_peakDurationR = PEAK_DURATION * sampleRate / iBufferSize / 2000;
+ m_peakDurationR = kPeakDuration * sampleRate / iBufferSize / 2000;
} else if (m_peakDurationR <= 0) {
m_ctrlPeakIndicatorR->set(0.);
} else {
@@ -121,9 +118,9 @@ void EngineVuMeter::process(CSAMPLE* pIn, const int iBufferSize) {
void EngineVuMeter::doSmooth(CSAMPLE &currentVolume, CSAMPLE newVolume)
{
if (currentVolume > newVolume)
- currentVolume -= DECAY_SMOOTHING * (currentVolume - newVolume);
+ currentVolume -= kDecaySmoothing * (currentVolume - newVolume);
else
- currentVolume += ATTACK_SMOOTHING * (newVolume - currentVolume);
+ currentVolume += kAttackSmoothing * (newVolume - currentVolume);
if (currentVolume < 0)
currentVolume=0;
if (currentVolume > 1.0)
diff --git a/src/engine/enginevumeter.h b/src/engine/enginevumeter.h
index bf6bee4219..a39da1bcc1 100644
--- a/src/engine/enginevumeter.h
+++ b/src/engine/enginevumeter.h
@@ -1,33 +1,7 @@
-/***************************************************************************
- enginevumeter.h - description
- -------------------
- copyright : (C) 2002 by Tue and Ken Haste Andersen
- email :
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#ifndef ENGINEVUMETER_H
-#define ENGINEVUMETER_H
+#pragma once
#include "engine/engineobject.h"
-// Rate at which the vumeter is updated (using a sample rate of 44100 Hz):
-#define VU_UPDATE_RATE 30 // in 1/s, fits to display frame rate
-#define PEAK_DURATION 500 // in ms
-
-// SMOOTHING FACTORS
-// Must be from 0-1 the lower the factor, the more smoothing that is applied
-#define ATTACK_SMOOTHING 1. // .85
-#define DECAY_SMOOTHING .1 //.16//.4
-
class ControlPotmeter;
class ControlProxy;
@@ -61,5 +35,3 @@ class EngineVuMeter : public EngineObject {
ControlProxy* m_pSampleRate;
};
-
-#endif
diff --git a/src/engine/sidechain/enginerecord.cpp b/src/engine/sidechain/enginerecord.cpp
index d8d39ab188..8878ad1296 100644
--- a/src/engine/sidechain/enginerecord.cpp
+++ b/src/engine/sidechain/enginerecord.cpp
@@ -108,8 +108,7 @@ bool EngineRecord::metaDataHasChanged()
}
void EngineRecord::process(const CSAMPLE* pBuffer, const int iBufferSize) {
-
- float recordingStatus = m_pRecReady->get();
+ const auto recordingStatus = static_cast<int>(m_pRecReady->get());
static const QString tag("EngineRecord recording");
if (recordingStatus == RECORD_OFF) {