diff options
author | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-10-27 22:58:00 +0100 |
---|---|---|
committer | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-10-27 23:07:32 +0100 |
commit | 758341f6b30a51e28e3052a1a3f8850ddcf4ec20 (patch) | |
tree | ad709910a989b7ed5e89b257c2602faf89db47c6 /src | |
parent | c60e8e727dcbd878c8aea08240c7df7defec7c4e (diff) |
Use more comparisons instead of implicit casts to double
Diffstat (limited to 'src')
-rw-r--r-- | src/control/controlbehavior.cpp | 12 | ||||
-rw-r--r-- | src/control/controllinpotmeter.cpp | 4 | ||||
-rw-r--r-- | src/controllers/controllerengine.cpp | 4 | ||||
-rw-r--r-- | src/effects/builtin/graphiceqeffect.cpp | 7 | ||||
-rw-r--r-- | src/effects/builtin/lvmixeqbase.h | 12 | ||||
-rw-r--r-- | src/effects/builtin/parametriceqeffect.cpp | 6 | ||||
-rw-r--r-- | src/engine/controls/loopingcontrol.cpp | 16 | ||||
-rw-r--r-- | src/engine/enginebuffer.cpp | 4 | ||||
-rw-r--r-- | src/engine/sync/synccontrol.cpp | 4 | ||||
-rw-r--r-- | src/library/librarycontrol.cpp | 4 | ||||
-rw-r--r-- | src/track/cue.cpp | 2 | ||||
-rw-r--r-- | src/util/sample.cpp | 10 | ||||
-rw-r--r-- | src/vinylcontrol/vinylcontrolprocessor.cpp | 3 | ||||
-rw-r--r-- | src/widget/wspinny.cpp | 4 |
14 files changed, 46 insertions, 46 deletions
diff --git a/src/control/controlbehavior.cpp b/src/control/controlbehavior.cpp index 720fa7399e..f6de005a90 100644 --- a/src/control/controlbehavior.cpp +++ b/src/control/controlbehavior.cpp @@ -187,7 +187,7 @@ double ControlAudioTaperPotBehavior::valueToParameter(double dValue) { // m_minDB = 0 // 0 dB = m_neutralParameter double overlay = m_offset * (1 - dValue); - if (m_minDB) { + if (m_minDB != 0) { dParam = (ratio2db(dValue + overlay) - m_minDB) / m_minDB * m_neutralParameter * -1; } else { dParam = dValue * m_neutralParameter; @@ -211,7 +211,7 @@ double ControlAudioTaperPotBehavior::parameterToValue(double dParam) { // db + linear overlay to reach // m_minDB = 0 // 0 dB = m_neutralParameter; - if (m_minDB) { + if (m_minDB != 0) { double db = (dParam * m_minDB / (m_neutralParameter * -1)) + m_minDB; dValue = (db2ratio(db) - m_offset) / (1 - m_offset) ; } else { @@ -232,7 +232,7 @@ double ControlAudioTaperPotBehavior::parameterToValue(double dParam) { double ControlAudioTaperPotBehavior::midiToParameter(double midiValue) { double dParam; - if (m_neutralParameter && m_neutralParameter != 1.0) { + if (m_neutralParameter != 0 && m_neutralParameter != 1.0) { double neutralTest = (midiValue - m_midiCorrection) / 127.0; if (neutralTest < m_neutralParameter) { dParam = midiValue / @@ -255,7 +255,7 @@ double ControlAudioTaperPotBehavior::valueToMidiParameter(double dValue) { // always on a full Midi integer double dParam = valueToParameter(dValue); double dMidiParam = dParam * 127.0; - if (m_neutralParameter && m_neutralParameter != 1.0) { + if (m_neutralParameter != 0 && m_neutralParameter != 1.0) { if (dParam < m_neutralParameter) { dMidiParam += m_midiCorrection * dParam / m_neutralParameter; } else { @@ -316,8 +316,8 @@ void ControlPushButtonBehavior::setValueFromMidi( auto* timer = getTimer(); if (pressed) { // Toggle on press - double value = pControl->get(); - pControl->set(!value, NULL); + bool value = (pControl->get() != 0); + pControl->set(!value, nullptr); timer->setSingleShot(true); timer->start(kPowerWindowTimeMillis); } else if (!timer->isActive()) { diff --git a/src/control/controllinpotmeter.cpp b/src/control/controllinpotmeter.cpp index e3f16d44b4..c3ab24cca5 100644 --- a/src/control/controllinpotmeter.cpp +++ b/src/control/controllinpotmeter.cpp @@ -9,10 +9,10 @@ ControlLinPotmeter::ControlLinPotmeter(ConfigKey key, m_pControl->setBehavior( new ControlLinPotmeterBehavior(dMinValue, dMaxValue, allowOutOfBounds)); } - if (dStep) { + if (dStep != 0) { setStepCount(static_cast<int>((dMaxValue - dMinValue) / dStep)); } - if (dSmallStep) { + if (dSmallStep != 0) { setSmallStepCount(static_cast<int>((dMaxValue - dMinValue) / dSmallStep)); } } diff --git a/src/controllers/controllerengine.cpp b/src/controllers/controllerengine.cpp index eab1d6ecaf..c7f1b44c3c 100644 --- a/src/controllers/controllerengine.cpp +++ b/src/controllers/controllerengine.cpp @@ -1258,7 +1258,7 @@ void ControllerEngine::scratchEnable(int deck, int intervalsPerRev, double rpm, double alpha, double beta, bool ramp) { // If we're already scratching this deck, override that with this request - if (m_dx[deck]) { + if (m_dx[deck] != 0) { //qDebug() << "Already scratching deck" << deck << ". Overriding."; int timerId = m_scratchTimers.key(deck); killTimer(timerId); @@ -1307,7 +1307,7 @@ void ControllerEngine::scratchEnable(int deck, int intervalsPerRev, double rpm, } // Initialize scratch filter - if (alpha && beta) { + if (alpha != 0 && beta != 0) { m_scratchFilters[deck]->init(kAlphaBetaDt, initVelocity, alpha, beta); } else { // Use filter's defaults if not specified diff --git a/src/effects/builtin/graphiceqeffect.cpp b/src/effects/builtin/graphiceqeffect.cpp index 9429f5bbd1..dbeeb8d63c 100644 --- a/src/effects/builtin/graphiceqeffect.cpp +++ b/src/effects/builtin/graphiceqeffect.cpp @@ -200,7 +200,7 @@ void GraphicEQEffect::processChannel(const ChannelHandle& handle, } int bufIndex = 0; - if (fLow) { + if (fLow != 0) { pState->m_low->process(pInput, pState->m_pBufs[1 - bufIndex], bufferParameters.samplesPerBuffer()); bufIndex = 1 - bufIndex; } else { @@ -209,7 +209,7 @@ void GraphicEQEffect::processChannel(const ChannelHandle& handle, } for (int i = 0; i < 6; i++) { - if (fMid[i]) { + if (fMid[i] != 0) { pState->m_bands[i]->process(pState->m_pBufs[bufIndex], pState->m_pBufs[1 - bufIndex], bufferParameters.samplesPerBuffer()); bufIndex = 1 - bufIndex; @@ -218,7 +218,7 @@ void GraphicEQEffect::processChannel(const ChannelHandle& handle, } } - if (fHigh) { + if (fHigh != 0) { pState->m_high->process(pState->m_pBufs[bufIndex], pOutput, bufferParameters.samplesPerBuffer()); } else { @@ -226,7 +226,6 @@ void GraphicEQEffect::processChannel(const ChannelHandle& handle, pState->m_high->pauseFilter(); } - pState->m_oldLow = fLow; pState->m_oldHigh = fHigh; for (int i = 0; i < 6; i++) { diff --git a/src/effects/builtin/lvmixeqbase.h b/src/effects/builtin/lvmixeqbase.h index 41bc4800ca..d99df1ef15 100644 --- a/src/effects/builtin/lvmixeqbase.h +++ b/src/effects/builtin/lvmixeqbase.h @@ -88,16 +88,16 @@ class LVMixEQEffectGroupState : public EffectState { // buffer size-dependent start delay. During such start delay some unwanted // frequencies are slipping though or wanted frequencies are damped. // We know the exact group delay here so we can just hold off the ramping. - if (fHigh || m_oldHigh) { + if (fHigh != 0 || m_oldHigh != 0) { m_delay3->process(pInput, m_pHighBuf, numSamples); } - if (fMid || m_oldMid) { + if (fMid != 0 || m_oldMid != 0) { m_delay2->process(pInput, m_pBandBuf, numSamples); m_low2->process(m_pBandBuf, m_pBandBuf, numSamples); } - if (fLow || m_oldLow) { + if (fLow != 0 || m_oldLow != 0) { m_low1->process(pInput, m_pLowBuf, numSamples); } @@ -118,9 +118,9 @@ class LVMixEQEffectGroupState : public EffectState { } else { int copySamples = 0; int rampingSamples = numSamples; - if ((fLow && !m_oldLow) || - (fMid && !m_oldMid) || - (fHigh && !m_oldHigh)) { + if ((fLow != 0 && m_oldLow == 0) || + (fMid != 0 && m_oldMid == 0) || + (fHigh != 0 && m_oldHigh == 0)) { // we have just switched at least one filter on // Hold off ramping for the group delay if (m_rampHoldOff == kRampDone) { diff --git a/src/effects/builtin/parametriceqeffect.cpp b/src/effects/builtin/parametriceqeffect.cpp index 2a6f8c4250..1d56d38b52 100644 --- a/src/effects/builtin/parametriceqeffect.cpp +++ b/src/effects/builtin/parametriceqeffect.cpp @@ -192,16 +192,16 @@ void ParametricEQEffect::processChannel(const ChannelHandle& handle, } } - if (fGain[0]) { + if (fGain[0] != 0) { pState->m_bands[0]->process(pInput, pOutput, bufferParameters.samplesPerBuffer()); - if (fGain[1]) { + if (fGain[1] != 0) { pState->m_bands[1]->process(pOutput, pOutput, bufferParameters.samplesPerBuffer()); } else { pState->m_bands[1]->pauseFilter(); } } else { pState->m_bands[0]->pauseFilter(); - if (fGain[1]) { + if (fGain[1] != 0) { pState->m_bands[1]->process(pInput, pOutput, bufferParameters.samplesPerBuffer()); } else { pState->m_bands[1]->pauseFilter(); diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp index f86332ffd0..a7885325d5 100644 --- a/src/engine/controls/loopingcontrol.cpp +++ b/src/engine/controls/loopingcontrol.cpp @@ -1214,13 +1214,13 @@ void LoopingControl::slotBeatJump(double beats) { } void LoopingControl::slotBeatJumpForward(double pressed) { - if (pressed) { + if (pressed != 0) { slotBeatJump(m_pCOBeatJumpSize->get()); } } void LoopingControl::slotBeatJumpBackward(double pressed) { - if (pressed) { + if (pressed != 0) { slotBeatJump(-1.0 * m_pCOBeatJumpSize->get()); } } @@ -1436,9 +1436,9 @@ void BeatLoopingControl::slotLegacy(double v) { } } -void BeatLoopingControl::slotActivate(double v) { - //qDebug() << "slotActivate" << m_dBeatLoopSize << "v" << v; - if (!v) { +void BeatLoopingControl::slotActivate(double value) { + //qDebug() << "slotActivate" << m_dBeatLoopSize << "value" << value; + if (value == 0) { return; } emit activateBeatLoop(this); @@ -1453,9 +1453,9 @@ void BeatLoopingControl::slotActivateRoll(double v) { } } -void BeatLoopingControl::slotToggle(double v) { - //qDebug() << "slotToggle" << m_dBeatLoopSize << "v" << v; - if (!v) { +void BeatLoopingControl::slotToggle(double value) { + //qDebug() << "slotToggle" << m_dBeatLoopSize << "value" << value; + if (value == 0) { return; } if (m_bActive) { diff --git a/src/engine/enginebuffer.cpp b/src/engine/enginebuffer.cpp index 1087fd505b..d81289e1a5 100644 --- a/src/engine/enginebuffer.cpp +++ b/src/engine/enginebuffer.cpp @@ -306,7 +306,7 @@ EngineBuffer::~EngineBuffer() { double EngineBuffer::fractionalPlayposFromAbsolute(double absolutePlaypos) { double fFractionalPlaypos = 0.0; - if (m_trackSamplesOld) { + if (m_trackSamplesOld != 0) { fFractionalPlaypos = math_min<double>(absolutePlaypos, m_trackSamplesOld); fFractionalPlaypos /= m_trackSamplesOld; } @@ -1238,7 +1238,7 @@ void EngineBuffer::postProcess(const int iBufferSize) { } void EngineBuffer::updateIndicators(double speed, int iBufferSize) { - if (!m_trackSampleRateOld) { + if (m_trackSampleRateOld == 0) { // This happens if Deck Passthrough is active but no track is loaded. // We skip indicator updates. return; diff --git a/src/engine/sync/synccontrol.cpp b/src/engine/sync/synccontrol.cpp index 1f6c842d01..acdf45eb46 100644 --- a/src/engine/sync/synccontrol.cpp +++ b/src/engine/sync/synccontrol.cpp @@ -363,14 +363,14 @@ void SyncControl::slotControlPlay(double play) { } void SyncControl::slotVinylControlChanged(double enabled) { - if (enabled && getSyncMode() == SYNC_FOLLOWER) { + if (enabled != 0 && getSyncMode() == SYNC_FOLLOWER) { // If vinyl control was enabled and we're a follower, disable sync mode. m_pChannel->getEngineBuffer()->requestSyncMode(SYNC_NONE); } } void SyncControl::slotPassthroughChanged(double enabled) { - if (enabled && isSynchronized()) { + if (enabled != 0 && isSynchronized()) { // If passthrough was enabled and sync was on, disable it. m_pChannel->getEngineBuffer()->requestSyncMode(SYNC_NONE); } diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index e3c573771c..5e471505ec 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -655,8 +655,8 @@ void LibraryControl::slotSortColumn(double v) { void LibraryControl::slotSortColumnToggle(double v) { int column = static_cast<int>(v); - if (static_cast<int>(m_pSortColumn->get()) == column) { - m_pSortOrder->set(!m_pSortOrder->get()); + if (column == static_cast<int>(m_pSortColumn->get())) { + m_pSortOrder->set((m_pSortOrder->get() == 0) ? 1 : 0); } else { m_pSortColumn->set(v); m_pSortOrder->set(0); diff --git a/src/track/cue.cpp b/src/track/cue.cpp index 96d0365f64..1a04e716d0 100644 --- a/src/track/cue.cpp +++ b/src/track/cue.cpp @@ -74,7 +74,7 @@ Cue::Cue( m_iHotCue(hotCue), m_label(label), m_color(color) { - if (length) { + if (length != 0) { if (position != Cue::kNoPosition) { m_sampleEndPosition = position + length; } else { diff --git a/src/util/sample.cpp b/src/util/sample.cpp index ba79d67ab9..6c3183fe08 100644 --- a/src/util/sample.cpp +++ b/src/util/sample.cpp @@ -135,7 +135,7 @@ void SampleUtil::applyRampingGain(CSAMPLE* pBuffer, CSAMPLE_GAIN old_gain, const CSAMPLE_GAIN gain_delta = (new_gain - old_gain) / CSAMPLE_GAIN(numSamples / 2); - if (gain_delta) { + if (gain_delta != 0) { const CSAMPLE_GAIN start_gain = old_gain + gain_delta; // note: LOOP VECTORIZED. for (int i = 0; i < numSamples / 2; ++i) { @@ -178,7 +178,7 @@ void SampleUtil::applyRampingAlternatingGain(CSAMPLE* pBuffer, const CSAMPLE_GAIN gain1Delta = (gain1 - gain1Old) / CSAMPLE_GAIN(numSamples / 2); - if (gain1Delta) { + if (gain1Delta != 0) { const CSAMPLE_GAIN start_gain = gain1Old + gain1Delta; // note: LOOP VECTORIZED. for (int i = 0; i < numSamples / 2; ++i) { @@ -194,7 +194,7 @@ void SampleUtil::applyRampingAlternatingGain(CSAMPLE* pBuffer, const CSAMPLE_GAIN gain2Delta = (gain2 - gain2Old) / CSAMPLE_GAIN(numSamples / 2); - if (gain2Delta) { + if (gain2Delta != 0) { const CSAMPLE_GAIN start_gain = gain2Old + gain2Delta; // note: LOOP VECTORIZED. for (int i = 0; i < numSamples / 2; ++i) { @@ -243,7 +243,7 @@ void SampleUtil::addWithRampingGain(CSAMPLE* M_RESTRICT pDest, const CSAMPLE_GAIN gain_delta = (new_gain - old_gain) / CSAMPLE_GAIN(numSamples / 2); - if (gain_delta) { + if (gain_delta != 0) { const CSAMPLE_GAIN start_gain = old_gain + gain_delta; // note: LOOP VECTORIZED. for (int i = 0; i < numSamples / 2; ++i) { @@ -336,7 +336,7 @@ void SampleUtil::copyWithRampingGain(CSAMPLE* M_RESTRICT pDest, const CSAMPLE_GAIN gain_delta = (new_gain - old_gain) / CSAMPLE_GAIN(numSamples / 2); - if (gain_delta) { + if (gain_delta != 0) { const CSAMPLE_GAIN start_gain = old_gain + gain_delta; // note: LOOP VECTORIZED only with "int i" for (int i = 0; i < numSamples / 2; ++i) { diff --git a/src/vinylcontrol/vinylcontrolprocessor.cpp b/src/vinylcontrol/vinylcontrolprocessor.cpp index 837f62ca1c..1fd8e6a202 100644 --- a/src/vinylcontrol/vinylcontrolprocessor.cpp +++ b/src/vinylcontrol/vinylcontrolprocessor.cpp @@ -239,8 +239,9 @@ void VinylControlProcessor::receiveBuffer(AudioInput input, } void VinylControlProcessor::toggleDeck(double value) { - if (!value) + if (value == 0) { return; + } /** few different cases here: * 1. No decks have vinyl control enabled. diff --git a/src/widget/wspinny.cpp b/src/widget/wspinny.cpp index b5eb0b1127..192f6b5790 100644 --- a/src/widget/wspinny.cpp +++ b/src/widget/wspinny.cpp @@ -526,9 +526,9 @@ void WSpinny::updateVinylControlSignalEnabled(double enabled) { if (m_pVCManager == nullptr) { return; } - m_bSignalActive = enabled; + m_bSignalActive = (enabled != 0); - if (enabled != 0 && m_iVinylInput != -1) { + if (m_bSignalActive && m_iVinylInput != -1) { m_pVCManager->addSignalQualityListener(this); } else { m_pVCManager->removeSignalQualityListener(this); |