From 1ecaaedb0deca3fa4e35303e3c292ba5b8d096da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 13 Nov 2020 22:24:13 +0100 Subject: Bypass quantize setting when beat jumping. Fixing lp1904132 --- src/engine/controls/loopingcontrol.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/engine') diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp index a7885325d5..0f3619d0e3 100644 --- a/src/engine/controls/loopingcontrol.cpp +++ b/src/engine/controls/loopingcontrol.cpp @@ -1209,7 +1209,8 @@ void LoopingControl::slotBeatJump(double beats) { // If inside an active loop, move loop slotLoopMove(beats); } else { - seekAbs(pBeats->findNBeatsFromSample(currentSample, beats)); + // seekExact bypasses Quantize, because a beat jump is implicit quantized + seekExact(pBeats->findNBeatsFromSample(currentSample, beats)); } } -- cgit v1.2.3 From de839a0799eba87fd5e8e61c77c014ded16b8dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 17 Nov 2020 23:22:58 +0100 Subject: Fix hotcue_focus off by one issue not matching the hotcue CO names --- src/engine/controls/cuecontrol.cpp | 131 ++++++++++++++++++++----------------- src/engine/controls/cuecontrol.h | 45 +++++++------ 2 files changed, 95 insertions(+), 81 deletions(-) (limited to 'src/engine') diff --git a/src/engine/controls/cuecontrol.cpp b/src/engine/controls/cuecontrol.cpp index ab53d49e46..773a925241 100644 --- a/src/engine/controls/cuecontrol.cpp +++ b/src/engine/controls/cuecontrol.cpp @@ -223,7 +223,7 @@ CueControl::CueControl(QString group, m_pVinylControlMode = new ControlProxy(group, "vinylcontrol_mode"); m_pHotcueFocus = new ControlObject(ConfigKey(group, "hotcue_focus")); - m_pHotcueFocus->set(Cue::kNoHotCue); + m_pHotcueFocus->set(Cue::kNoHotCue + 1); m_pHotcueFocusColorPrev = new ControlObject(ConfigKey(group, "hotcue_focus_color_prev")); connect(m_pHotcueFocusColorPrev, @@ -358,7 +358,7 @@ void CueControl::trackLoaded(TrackPointer pNewTrack) { m_pOutroStartEnabled->forceSet(0.0); m_pOutroEndPosition->set(Cue::kNoPosition); m_pOutroEndEnabled->forceSet(0.0); - m_pHotcueFocus->set(Cue::kNoHotCue); + m_pHotcueFocus->set(Cue::kNoHotCue + 1); m_pLoadedTrack.reset(); m_usedSeekOnLoadPosition.setValue(kDefaultLoadPosition); } @@ -647,15 +647,16 @@ void CueControl::quantizeChanged(double v) { void CueControl::hotcueSet(HotcueControl* pControl, double value) { //qDebug() << "CueControl::hotcueSet" << value; - if (value == 0) { + if (value <= 0) { return; } QMutexLocker lock(&m_mutex); - if (!m_pLoadedTrack) + if (!m_pLoadedTrack) { return; + } - int hotcue = pControl->getHotcueNumber(); + int hotcueIndex = pControl->getHotcueIndex(); // Note: the cue is just detached from the hotcue control // It remains in the database for later use // TODO: find a rule, that allows us to delete the cue as well @@ -665,14 +666,14 @@ void CueControl::hotcueSet(HotcueControl* pControl, double value) { CuePointer pCue(m_pLoadedTrack->createAndAddCue()); double cuePosition = getQuantizedCurrentPosition(); pCue->setStartPosition(cuePosition); - pCue->setHotCue(hotcue); + pCue->setHotCue(hotcueIndex); pCue->setLabel(); pCue->setType(mixxx::CueType::HotCue); const ColorPalette hotcueColorPalette = m_colorPaletteSettings.getHotcueColorPalette(); if (getConfig()->getValue(ConfigKey("[Controls]", "auto_hotcue_colors"), false)) { - pCue->setColor(hotcueColorPalette.colorForHotcueIndex(hotcue)); + pCue->setColor(hotcueColorPalette.colorForHotcueIndex(hotcueIndex)); } else { int hotcueDefaultColorIndex = m_pConfig->getValue(ConfigKey("[Controls]", "HotcueDefaultColorIndex"), -1); if (hotcueDefaultColorIndex < 0 || hotcueDefaultColorIndex >= hotcueColorPalette.size()) { @@ -816,7 +817,7 @@ void CueControl::hotcueActivate(HotcueControl* pControl, double value) { } } - m_pHotcueFocus->set(pControl->getHotcueNumber()); + m_pHotcueFocus->set(pControl->getHotcueIndex() + 1); } void CueControl::hotcueActivatePreview(HotcueControl* pControl, double value) { @@ -861,7 +862,7 @@ void CueControl::hotcueActivatePreview(HotcueControl* pControl, double value) { } void CueControl::hotcueClear(HotcueControl* pControl, double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -876,7 +877,7 @@ void CueControl::hotcueClear(HotcueControl* pControl, double value) { } detachCue(pControl); m_pLoadedTrack->removeCue(pCue); - m_pHotcueFocus->set(Cue::kNoHotCue); + m_pHotcueFocus->set(Cue::kNoHotCue + 1); } void CueControl::hotcuePositionChanged(HotcueControl* pControl, double newPosition) { @@ -1764,12 +1765,12 @@ void CueControl::hotcueFocusColorPrev(double value) { return; } - int hotcueNumber = static_cast(m_pHotcueFocus->get()); - if (hotcueNumber < 0 || hotcueNumber >= m_hotcueControls.size()) { + int hotcueIndex = static_cast(m_pHotcueFocus->get()) - 1; + if (hotcueIndex < 0 || hotcueIndex >= m_hotcueControls.size()) { return; } - HotcueControl* pControl = m_hotcueControls.at(hotcueNumber); + HotcueControl* pControl = m_hotcueControls.at(hotcueIndex); if (!pControl) { return; } @@ -1793,12 +1794,12 @@ void CueControl::hotcueFocusColorNext(double value) { return; } - int hotcueNumber = static_cast(m_pHotcueFocus->get()); - if (hotcueNumber < 0 || hotcueNumber >= m_hotcueControls.size()) { + int hotcueIndex = static_cast(m_pHotcueFocus->get()) - 1; + if (hotcueIndex < 0 || hotcueIndex >= m_hotcueControls.size()) { return; } - HotcueControl* pControl = m_hotcueControls.at(hotcueNumber); + HotcueControl* pControl = m_hotcueControls.at(hotcueIndex); if (!pControl) { return; } @@ -1817,90 +1818,98 @@ void CueControl::hotcueFocusColorNext(double value) { pCue->setColor(colorPalette.nextColor(*color)); } -ConfigKey HotcueControl::keyForControl(int hotcue, const char* name) { +ConfigKey HotcueControl::keyForControl(const QString& name) { ConfigKey key; key.group = m_group; // Add one to hotcue so that we don't have a hotcue_0 - key.item = QLatin1String("hotcue_") % QString::number(hotcue+1) % "_" % name; + key.item = + QStringLiteral("hotcue_") + QString::number(m_hotcueIndex + 1) + QChar('_') + name; return key; } -HotcueControl::HotcueControl(QString group, int i) +HotcueControl::HotcueControl(const QString& group, int hotcueIndex) : m_group(group), - m_iHotcueNumber(i), - m_pCue(NULL), + m_hotcueIndex(hotcueIndex), + m_pCue(nullptr), m_bPreviewing(false), m_previewingPosition(-1) { - m_hotcuePosition = new ControlObject(keyForControl(i, "position")); - connect(m_hotcuePosition, &ControlObject::valueChanged, - this, &HotcueControl::slotHotcuePositionChanged, + m_hotcuePosition = std::make_unique(keyForControl(QStringLiteral("position"))); + connect(m_hotcuePosition.get(), + &ControlObject::valueChanged, + this, + &HotcueControl::slotHotcuePositionChanged, Qt::DirectConnection); m_hotcuePosition->set(Cue::kNoPosition); - m_hotcueEnabled = new ControlObject(keyForControl(i, "enabled")); + m_hotcueEnabled = std::make_unique(keyForControl(QStringLiteral("enabled"))); m_hotcueEnabled->setReadOnly(); // The rgba value of the color assigned to this color. - m_hotcueColor = new ControlObject(keyForControl(i, "color")); + m_hotcueColor = std::make_unique(keyForControl(QStringLiteral("color"))); m_hotcueColor->connectValueChangeRequest( this, &HotcueControl::slotHotcueColorChangeRequest, Qt::DirectConnection); - connect(m_hotcueColor, + connect(m_hotcueColor.get(), &ControlObject::valueChanged, this, &HotcueControl::slotHotcueColorChanged, Qt::DirectConnection); - m_hotcueSet = new ControlPushButton(keyForControl(i, "set")); - connect(m_hotcueSet, &ControlObject::valueChanged, - this, &HotcueControl::slotHotcueSet, + m_hotcueSet = std::make_unique(keyForControl(QStringLiteral("set"))); + connect(m_hotcueSet.get(), + &ControlObject::valueChanged, + this, + &HotcueControl::slotHotcueSet, Qt::DirectConnection); - m_hotcueGoto = new ControlPushButton(keyForControl(i, "goto")); - connect(m_hotcueGoto, &ControlObject::valueChanged, - this, &HotcueControl::slotHotcueGoto, + m_hotcueGoto = std::make_unique(keyForControl(QStringLiteral("goto"))); + connect(m_hotcueGoto.get(), + &ControlObject::valueChanged, + this, + &HotcueControl::slotHotcueGoto, Qt::DirectConnection); - m_hotcueGotoAndPlay = new ControlPushButton(keyForControl(i, "gotoandplay")); - connect(m_hotcueGotoAndPlay, &ControlObject::valueChanged, - this, &HotcueControl::slotHotcueGotoAndPlay, + m_hotcueGotoAndPlay = std::make_unique( + keyForControl(QStringLiteral("gotoandplay"))); + connect(m_hotcueGotoAndPlay.get(), + &ControlObject::valueChanged, + this, + &HotcueControl::slotHotcueGotoAndPlay, Qt::DirectConnection); - m_hotcueGotoAndStop = new ControlPushButton(keyForControl(i, "gotoandstop")); - connect(m_hotcueGotoAndStop, &ControlObject::valueChanged, - this, &HotcueControl::slotHotcueGotoAndStop, + m_hotcueGotoAndStop = std::make_unique( + keyForControl(QStringLiteral("gotoandstop"))); + connect(m_hotcueGotoAndStop.get(), + &ControlObject::valueChanged, + this, + &HotcueControl::slotHotcueGotoAndStop, Qt::DirectConnection); - m_hotcueActivate = new ControlPushButton(keyForControl(i, "activate")); - connect(m_hotcueActivate, &ControlObject::valueChanged, - this, &HotcueControl::slotHotcueActivate, + m_hotcueActivate = std::make_unique( + keyForControl(QStringLiteral("activate"))); + connect(m_hotcueActivate.get(), + &ControlObject::valueChanged, + this, + &HotcueControl::slotHotcueActivate, Qt::DirectConnection); - m_hotcueActivatePreview = new ControlPushButton(keyForControl(i, "activate_preview")); - connect(m_hotcueActivatePreview, &ControlObject::valueChanged, - this, &HotcueControl::slotHotcueActivatePreview, + m_hotcueActivatePreview = std::make_unique( + keyForControl(QStringLiteral("activate_preview"))); + connect(m_hotcueActivatePreview.get(), + &ControlObject::valueChanged, + this, + &HotcueControl::slotHotcueActivatePreview, Qt::DirectConnection); - m_hotcueClear = new ControlPushButton(keyForControl(i, "clear")); - connect(m_hotcueClear, &ControlObject::valueChanged, - this, &HotcueControl::slotHotcueClear, + m_hotcueClear = std::make_unique(keyForControl(QStringLiteral("clear"))); + connect(m_hotcueClear.get(), + &ControlObject::valueChanged, + this, + &HotcueControl::slotHotcueClear, Qt::DirectConnection); } -HotcueControl::~HotcueControl() { - delete m_hotcuePosition; - delete m_hotcueEnabled; - delete m_hotcueColor; - delete m_hotcueSet; - delete m_hotcueGoto; - delete m_hotcueGotoAndPlay; - delete m_hotcueGotoAndStop; - delete m_hotcueActivate; - delete m_hotcueActivatePreview; - delete m_hotcueClear; -} - void HotcueControl::slotHotcueSet(double v) { emit hotcueSet(this, v); } diff --git a/src/engine/controls/cuecontrol.h b/src/engine/controls/cuecontrol.h index ee17926cf3..61a84b9096 100644 --- a/src/engine/controls/cuecontrol.h +++ b/src/engine/controls/cuecontrol.h @@ -43,11 +43,16 @@ inline SeekOnLoadMode seekOnLoadModeFromDouble(double value) { class HotcueControl : public QObject { Q_OBJECT public: - HotcueControl(QString group, int hotcueNumber); - ~HotcueControl() override; + HotcueControl(const QString& group, int hotcueIndex); + ~HotcueControl() override = default; - inline int getHotcueNumber() { return m_iHotcueNumber; } - inline CuePointer getCue() { return m_pCue; } + int getHotcueIndex() const { + return m_hotcueIndex; + } + + CuePointer getCue() { + return m_pCue; + } double getPosition() const; void setCue(CuePointer pCue); void resetCue(); @@ -56,16 +61,16 @@ class HotcueControl : public QObject { mixxx::RgbColor::optional_t getColor() const; // Used for caching the preview state of this hotcue control. - inline bool isPreviewing() { + bool isPreviewing() const { return m_bPreviewing; } - inline void setPreviewing(bool bPreviewing) { + void setPreviewing(bool bPreviewing) { m_bPreviewing = bPreviewing; } - inline double getPreviewingPosition() { + double getPreviewingPosition() const { return m_previewingPosition; } - inline void setPreviewingPosition(double position) { + void setPreviewingPosition(double position) { m_previewingPosition = position; } @@ -94,24 +99,24 @@ class HotcueControl : public QObject { void hotcuePlay(double v); private: - ConfigKey keyForControl(int hotcue, const char* name); + ConfigKey keyForControl(const QString& name); const QString m_group; - int m_iHotcueNumber; + const int m_hotcueIndex; CuePointer m_pCue; // Hotcue state controls - ControlObject* m_hotcuePosition; - ControlObject* m_hotcueEnabled; - ControlObject* m_hotcueColor; + std::unique_ptr m_hotcuePosition; + std::unique_ptr m_hotcueEnabled; + std::unique_ptr m_hotcueColor; // Hotcue button controls - ControlObject* m_hotcueSet; - ControlObject* m_hotcueGoto; - ControlObject* m_hotcueGotoAndPlay; - ControlObject* m_hotcueGotoAndStop; - ControlObject* m_hotcueActivate; - ControlObject* m_hotcueActivatePreview; - ControlObject* m_hotcueClear; + std::unique_ptr m_hotcueSet; + std::unique_ptr m_hotcueGoto; + std::unique_ptr m_hotcueGotoAndPlay; + std::unique_ptr m_hotcueGotoAndStop; + std::unique_ptr m_hotcueActivate; + std::unique_ptr m_hotcueActivatePreview; + std::unique_ptr m_hotcueClear; bool m_bPreviewing; double m_previewingPosition; -- cgit v1.2.3 From 708fc542a8850c6937fde9b97c7ace6264a3aa34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 19 Nov 2020 08:36:36 +0100 Subject: use correct boolean interpreatation for CO values --- src/engine/controls/cuecontrol.cpp | 54 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'src/engine') diff --git a/src/engine/controls/cuecontrol.cpp b/src/engine/controls/cuecontrol.cpp index 773a925241..b2d04ca974 100644 --- a/src/engine/controls/cuecontrol.cpp +++ b/src/engine/controls/cuecontrol.cpp @@ -697,7 +697,7 @@ void CueControl::hotcueSet(HotcueControl* pControl, double value) { } void CueControl::hotcueGoto(HotcueControl* pControl, double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -720,7 +720,7 @@ void CueControl::hotcueGoto(HotcueControl* pControl, double value) { } void CueControl::hotcueGotoAndStop(HotcueControl* pControl, double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -743,7 +743,7 @@ void CueControl::hotcueGotoAndStop(HotcueControl* pControl, double value) { } void CueControl::hotcueGotoAndPlay(HotcueControl* pControl, double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -788,7 +788,7 @@ void CueControl::hotcueActivate(HotcueControl* pControl, double value) { lock.unlock(); if (pCue) { - if (value != 0) { + if (value > 0) { if (pCue->getPosition() == Cue::kNoPosition) { hotcueSet(pControl, value); } else { @@ -805,7 +805,7 @@ void CueControl::hotcueActivate(HotcueControl* pControl, double value) { } } else { // The cue is non-existent ... - if (value != 0) { + if (value > 0) { // set it to the current position hotcueSet(pControl, value); } else if (m_iCurrentlyPreviewingHotcues) { @@ -827,7 +827,7 @@ void CueControl::hotcueActivatePreview(HotcueControl* pControl, double value) { } CuePointer pCue(pControl->getCue()); - if (value != 0) { + if (value > 0) { if (pCue && pCue->getPosition() != Cue::kNoPosition) { m_iCurrentlyPreviewingHotcues++; double position = pCue->getPosition(); @@ -923,7 +923,7 @@ void CueControl::hintReader(HintVector* pHintList) { // Moves the cue point to current position or to closest beat in case // quantize is enabled void CueControl::cueSet(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -941,7 +941,7 @@ void CueControl::cueSet(double value) { } void CueControl::cueClear(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -956,7 +956,7 @@ void CueControl::cueClear(double value) { } void CueControl::cueGoto(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -971,7 +971,7 @@ void CueControl::cueGoto(double value) { } void CueControl::cueGotoAndPlay(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -989,7 +989,7 @@ void CueControl::cueGotoAndPlay(double value) { } void CueControl::cueGotoAndStop(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -1006,7 +1006,7 @@ void CueControl::cueGotoAndStop(double value) { void CueControl::cuePreview(double value) { QMutexLocker lock(&m_mutex); - if (value != 0) { + if (value > 0) { m_bPreviewing = true; m_bypassCueSetByPlay = true; m_pPlay->set(1.0); @@ -1037,7 +1037,7 @@ void CueControl::cueCDJ(double value) { const auto freely_playing = m_pPlay->toBool() && !getEngineBuffer()->getScratching(); TrackAt trackAt = getTrackAt(); - if (value != 0) { + if (value > 0) { if (m_iCurrentlyPreviewingHotcues) { // we are already previewing by hotcues // just jump to cue point and continue previewing @@ -1104,7 +1104,7 @@ void CueControl::cueDenon(double value) { bool playing = (m_pPlay->toBool()); TrackAt trackAt = getTrackAt(); - if (value != 0) { + if (value > 0) { if (m_iCurrentlyPreviewingHotcues) { // we are already previewing by hotcues // just jump to cue point and continue previewing @@ -1150,7 +1150,7 @@ void CueControl::cuePlay(double value) { TrackAt trackAt = getTrackAt(); // pressed - if (value != 0) { + if (value > 0) { if (freely_playing) { m_bPreviewing = false; m_pPlay->set(0.0); @@ -1216,7 +1216,7 @@ void CueControl::playStutter(double v) { } void CueControl::introStartSet(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -1257,7 +1257,7 @@ void CueControl::introStartSet(double value) { } void CueControl::introStartClear(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -1294,7 +1294,7 @@ void CueControl::introStartActivate(double value) { } void CueControl::introEndSet(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -1335,7 +1335,7 @@ void CueControl::introEndSet(double value) { } void CueControl::introEndClear(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -1372,7 +1372,7 @@ void CueControl::introEndActivate(double value) { } void CueControl::outroStartSet(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -1413,7 +1413,7 @@ void CueControl::outroStartSet(double value) { } void CueControl::outroStartClear(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -1434,7 +1434,7 @@ void CueControl::outroStartClear(double value) { } void CueControl::outroStartActivate(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -1450,7 +1450,7 @@ void CueControl::outroStartActivate(double value) { } void CueControl::outroEndSet(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -1491,7 +1491,7 @@ void CueControl::outroEndSet(double value) { } void CueControl::outroEndClear(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -1512,7 +1512,7 @@ void CueControl::outroEndClear(double value) { } void CueControl::outroEndActivate(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -1761,7 +1761,7 @@ SeekOnLoadMode CueControl::getSeekOnLoadPreference() { } void CueControl::hotcueFocusColorPrev(double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -1790,7 +1790,7 @@ void CueControl::hotcueFocusColorPrev(double value) { } void CueControl::hotcueFocusColorNext(double value) { - if (value == 0) { + if (value <= 0) { return; } -- cgit v1.2.3 From 9b922b30c48cd74d5a58494d514dfdc23ca7afde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 19 Nov 2020 08:55:22 +0100 Subject: Added helper functions for the HotcueIndex vs. HotcueNumber issue --- src/engine/controls/cuecontrol.cpp | 33 +++++++++++++++++++++++++-------- src/engine/controls/cuecontrol.h | 2 ++ 2 files changed, 27 insertions(+), 8 deletions(-) (limited to 'src/engine') diff --git a/src/engine/controls/cuecontrol.cpp b/src/engine/controls/cuecontrol.cpp index b2d04ca974..09f667cd03 100644 --- a/src/engine/controls/cuecontrol.cpp +++ b/src/engine/controls/cuecontrol.cpp @@ -44,6 +44,14 @@ inline mixxx::RgbColor::optional_t doubleToRgbColor(double value) { return mixxx::RgbColor::optional(colorCode); } +inline int hotcueIndexToHotcueNumber(int hotcueIndex) { + return hotcueIndex + 1; +} + +inline int hotcueNumberToHotcueIndex(int hotcueNumber) { + return hotcueNumber - 1; +} + } // namespace CueControl::CueControl(QString group, @@ -223,7 +231,7 @@ CueControl::CueControl(QString group, m_pVinylControlMode = new ControlProxy(group, "vinylcontrol_mode"); m_pHotcueFocus = new ControlObject(ConfigKey(group, "hotcue_focus")); - m_pHotcueFocus->set(Cue::kNoHotCue + 1); + setHotcueFocusIndex(Cue::kNoHotCue); m_pHotcueFocusColorPrev = new ControlObject(ConfigKey(group, "hotcue_focus_color_prev")); connect(m_pHotcueFocusColorPrev, @@ -358,7 +366,7 @@ void CueControl::trackLoaded(TrackPointer pNewTrack) { m_pOutroStartEnabled->forceSet(0.0); m_pOutroEndPosition->set(Cue::kNoPosition); m_pOutroEndEnabled->forceSet(0.0); - m_pHotcueFocus->set(Cue::kNoHotCue + 1); + setHotcueFocusIndex(Cue::kNoHotCue); m_pLoadedTrack.reset(); m_usedSeekOnLoadPosition.setValue(kDefaultLoadPosition); } @@ -817,7 +825,7 @@ void CueControl::hotcueActivate(HotcueControl* pControl, double value) { } } - m_pHotcueFocus->set(pControl->getHotcueIndex() + 1); + setHotcueFocusIndex(pControl->getHotcueIndex()); } void CueControl::hotcueActivatePreview(HotcueControl* pControl, double value) { @@ -877,7 +885,7 @@ void CueControl::hotcueClear(HotcueControl* pControl, double value) { } detachCue(pControl); m_pLoadedTrack->removeCue(pCue); - m_pHotcueFocus->set(Cue::kNoHotCue + 1); + setHotcueFocusIndex(Cue::kNoHotCue); } void CueControl::hotcuePositionChanged(HotcueControl* pControl, double newPosition) { @@ -1765,7 +1773,7 @@ void CueControl::hotcueFocusColorPrev(double value) { return; } - int hotcueIndex = static_cast(m_pHotcueFocus->get()) - 1; + int hotcueIndex = getHotcueFocusIndex(); if (hotcueIndex < 0 || hotcueIndex >= m_hotcueControls.size()) { return; } @@ -1794,7 +1802,7 @@ void CueControl::hotcueFocusColorNext(double value) { return; } - int hotcueIndex = static_cast(m_pHotcueFocus->get()) - 1; + int hotcueIndex = getHotcueFocusIndex(); if (hotcueIndex < 0 || hotcueIndex >= m_hotcueControls.size()) { return; } @@ -1818,12 +1826,21 @@ void CueControl::hotcueFocusColorNext(double value) { pCue->setColor(colorPalette.nextColor(*color)); } +void CueControl::setHotcueFocusIndex(int hotcueIndex) { + m_pHotcueFocus->set(hotcueIndexToHotcueNumber(hotcueIndex)); +} + +int CueControl::getHotcueFocusIndex() const { + return hotcueNumberToHotcueIndex(static_cast(m_pHotcueFocus->get())); +} + ConfigKey HotcueControl::keyForControl(const QString& name) { ConfigKey key; key.group = m_group; // Add one to hotcue so that we don't have a hotcue_0 - key.item = - QStringLiteral("hotcue_") + QString::number(m_hotcueIndex + 1) + QChar('_') + name; + key.item = QStringLiteral("hotcue_") + + QString::number(hotcueIndexToHotcueNumber(m_hotcueIndex)) + + QChar('_') + name; return key; } diff --git a/src/engine/controls/cuecontrol.h b/src/engine/controls/cuecontrol.h index 61a84b9096..3634a0d32a 100644 --- a/src/engine/controls/cuecontrol.h +++ b/src/engine/controls/cuecontrol.h @@ -200,6 +200,8 @@ class CueControl : public EngineControl { double getQuantizedCurrentPosition(); TrackAt getTrackAt() const; void seekOnLoad(double seekOnLoadPosition); + void setHotcueFocusIndex(int hotcueIndex); + int getHotcueFocusIndex() const; UserSettingsPointer m_pConfig; ColorPaletteSettings m_colorPaletteSettings; -- cgit v1.2.3 From 4e1bebf0f5e06ecdd99c41771e7b4ee19c0cdcf3 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 17 Nov 2020 20:02:14 +0100 Subject: Pass non-trivial/large function args by reference Fixes a bunch of `-Wclazy-function-args-by-ref` warnings. See https://github.com/KDE/clazy/blob/master/docs/checks/README-function-args-by-ref.md for details. Most of these changes are automated, using the clazy fixit by setting the `CLAZY_EXPORT_FIXES` before compilation and then running: $ mkdir /tmp/patch $ find ../src -iname "*.yaml" -exec mv {} /tmp/patch \; $ clang-apply-replacements /tmp/patch --- src/engine/cachingreader/cachingreader.cpp | 2 +- src/engine/cachingreader/cachingreader.h | 6 +- src/engine/cachingreader/cachingreaderworker.cpp | 2 +- src/engine/cachingreader/cachingreaderworker.h | 4 +- src/engine/channels/engineaux.cpp | 8 +- src/engine/channels/engineaux.h | 9 +- src/engine/channels/enginedeck.cpp | 7 +- src/engine/channels/enginedeck.h | 9 +- src/engine/channels/enginemicrophone.cpp | 8 +- src/engine/channels/enginemicrophone.h | 9 +- src/engine/controls/bpmcontrol.cpp | 2 +- src/engine/controls/bpmcontrol.h | 2 +- src/engine/controls/clockcontrol.cpp | 2 +- src/engine/controls/clockcontrol.h | 4 +- src/engine/controls/cuecontrol.cpp | 8 +- src/engine/controls/cuecontrol.h | 10 +- src/engine/controls/enginecontrol.cpp | 4 +- src/engine/controls/enginecontrol.h | 4 +- src/engine/controls/keycontrol.cpp | 4 +- src/engine/controls/keycontrol.h | 2 +- src/engine/controls/loopingcontrol.cpp | 12 +- src/engine/controls/loopingcontrol.h | 8 +- src/engine/controls/quantizecontrol.cpp | 4 +- src/engine/controls/quantizecontrol.h | 2 +- src/engine/controls/ratecontrol.cpp | 14 +- src/engine/controls/ratecontrol.h | 282 +++++++++++------------ src/engine/controls/vinylcontrolcontrol.cpp | 2 +- src/engine/controls/vinylcontrolcontrol.h | 2 +- src/engine/enginebuffer.cpp | 2 +- src/engine/enginebuffer.h | 4 +- src/engine/enginedelay.cpp | 2 +- src/engine/enginedelay.h | 2 +- src/engine/enginemaster.cpp | 12 +- src/engine/enginemaster.h | 12 +- src/engine/enginepregain.cpp | 2 +- src/engine/enginepregain.h | 2 +- src/engine/enginevumeter.cpp | 2 +- src/engine/enginevumeter.h | 2 +- src/engine/positionscratchcontroller.cpp | 22 +- src/engine/positionscratchcontroller.h | 2 +- src/engine/sidechain/enginesidechain.cpp | 6 +- src/engine/sidechain/enginesidechain.h | 6 +- src/engine/sidechain/shoutconnection.cpp | 4 +- src/engine/sidechain/shoutconnection.h | 4 +- 44 files changed, 261 insertions(+), 257 deletions(-) (limited to 'src/engine') diff --git a/src/engine/cachingreader/cachingreader.cpp b/src/engine/cachingreader/cachingreader.cpp index d7332eb27c..592371a686 100644 --- a/src/engine/cachingreader/cachingreader.cpp +++ b/src/engine/cachingreader/cachingreader.cpp @@ -40,7 +40,7 @@ const SINT kNumberOfCachedChunksInMemory = 80; } // anonymous namespace -CachingReader::CachingReader(QString group, +CachingReader::CachingReader(const QString& group, UserSettingsPointer config) : m_pConfig(config), // Limit the number of in-flight requests to the worker. This should diff --git a/src/engine/cachingreader/cachingreader.h b/src/engine/cachingreader/cachingreader.h index 24b039f11e..01529342ea 100644 --- a/src/engine/cachingreader/cachingreader.h +++ b/src/engine/cachingreader/cachingreader.h @@ -75,8 +75,8 @@ class CachingReader : public QObject { public: // Construct a CachingReader with the given group. - CachingReader(QString group, - UserSettingsPointer _config); + CachingReader(const QString& group, + UserSettingsPointer _config); ~CachingReader() override; void process(); @@ -115,7 +115,7 @@ class CachingReader : public QObject { // Emitted once a new track is loaded and ready to be read from. void trackLoading(); void trackLoaded(TrackPointer pTrack, int iSampleRate, int iNumSamples); - void trackLoadFailed(TrackPointer pTrack, QString reason); + void trackLoadFailed(TrackPointer pTrack, const QString& reason); private: const UserSettingsPointer m_pConfig; diff --git a/src/engine/cachingreader/cachingreaderworker.cpp b/src/engine/cachingreader/cachingreaderworker.cpp index ae5b9d8256..aefd482d04 100644 --- a/src/engine/cachingreader/cachingreaderworker.cpp +++ b/src/engine/cachingreader/cachingreaderworker.cpp @@ -18,7 +18,7 @@ mixxx::Logger kLogger("CachingReaderWorker"); } // anonymous namespace CachingReaderWorker::CachingReaderWorker( - QString group, + const QString& group, FIFO* pChunkReadRequestFIFO, FIFO* pReaderStatusFIFO) : m_group(group), diff --git a/src/engine/cachingreader/cachingreaderworker.h b/src/engine/cachingreader/cachingreaderworker.h index eb0f68081c..6118c58c94 100644 --- a/src/engine/cachingreader/cachingreaderworker.h +++ b/src/engine/cachingreader/cachingreaderworker.h @@ -97,7 +97,7 @@ class CachingReaderWorker : public EngineWorker { public: // Construct a CachingReader with the given group. - CachingReaderWorker(QString group, + CachingReaderWorker(const QString& group, FIFO* pChunkReadRequestFIFO, FIFO* pReaderStatusFIFO); ~CachingReaderWorker() override = default; @@ -115,7 +115,7 @@ class CachingReaderWorker : public EngineWorker { // Emitted once a new track is loaded and ready to be read from. void trackLoading(); void trackLoaded(TrackPointer pTrack, int iSampleRate, int iNumSamples); - void trackLoadFailed(TrackPointer pTrack, QString reason); + void trackLoadFailed(TrackPointer pTrack, const QString& reason); private: const QString m_group; diff --git a/src/engine/channels/engineaux.cpp b/src/engine/channels/engineaux.cpp index eaaef154ae..9f75ec6d68 100644 --- a/src/engine/channels/engineaux.cpp +++ b/src/engine/channels/engineaux.cpp @@ -46,7 +46,7 @@ bool EngineAux::isActive() { return m_wasActive; } -void EngineAux::onInputConfigured(AudioInput input) { +void EngineAux::onInputConfigured(const AudioInput& input) { if (input.getType() != AudioPath::AUXILIARY) { // This is an error! qDebug() << "WARNING: EngineAux connected to AudioInput for a non-auxiliary type!"; @@ -56,7 +56,7 @@ void EngineAux::onInputConfigured(AudioInput input) { m_pInputConfigured->forceSet(1.0); } -void EngineAux::onInputUnconfigured(AudioInput input) { +void EngineAux::onInputUnconfigured(const AudioInput& input) { if (input.getType() != AudioPath::AUXILIARY) { // This is an error! qDebug() << "WARNING: EngineAux connected to AudioInput for a non-auxiliary type!"; @@ -66,8 +66,8 @@ void EngineAux::onInputUnconfigured(AudioInput input) { m_pInputConfigured->forceSet(0.0); } -void EngineAux::receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, - unsigned int nFrames) { +void EngineAux::receiveBuffer( + const AudioInput& input, const CSAMPLE* pBuffer, unsigned int nFrames) { Q_UNUSED(input); Q_UNUSED(nFrames); m_sampleBuffer = pBuffer; diff --git a/src/engine/channels/engineaux.h b/src/engine/channels/engineaux.h index cf01a5aad3..d12f65ad8b 100644 --- a/src/engine/channels/engineaux.h +++ b/src/engine/channels/engineaux.h @@ -35,16 +35,17 @@ class EngineAux : public EngineChannel, public AudioDestination { // the soundcard this AudioDestination was registered for! Beware, in the // case of multiple soundcards, this method is not re-entrant but it may be // concurrent with EngineMaster processing. - virtual void receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, - unsigned int nFrames); + virtual void receiveBuffer(const AudioInput& input, + const CSAMPLE* pBuffer, + unsigned int nFrames); // Called by SoundManager whenever the aux input is connected to a // soundcard input. - virtual void onInputConfigured(AudioInput input); + virtual void onInputConfigured(const AudioInput& input); // Called by SoundManager whenever the aux input is disconnected from // a soundcard input. - virtual void onInputUnconfigured(AudioInput input); + virtual void onInputUnconfigured(const AudioInput& input); private: QScopedPointer m_pInputConfigured; diff --git a/src/engine/channels/enginedeck.cpp b/src/engine/channels/enginedeck.cpp index 27431078c6..8eeb3d1bad 100644 --- a/src/engine/channels/enginedeck.cpp +++ b/src/engine/channels/enginedeck.cpp @@ -131,7 +131,8 @@ bool EngineDeck::isActive() { return active; } -void EngineDeck::receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, unsigned int nFrames) { +void EngineDeck::receiveBuffer( + const AudioInput& input, const CSAMPLE* pBuffer, unsigned int nFrames) { Q_UNUSED(input); Q_UNUSED(nFrames); // Skip receiving audio input if passthrough is not active @@ -143,7 +144,7 @@ void EngineDeck::receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, unsigne } } -void EngineDeck::onInputConfigured(AudioInput input) { +void EngineDeck::onInputConfigured(const AudioInput& input) { if (input.getType() != AudioPath::VINYLCONTROL) { // This is an error! qDebug() << "WARNING: EngineDeck connected to AudioInput for a non-vinylcontrol type!"; @@ -153,7 +154,7 @@ void EngineDeck::onInputConfigured(AudioInput input) { m_sampleBuffer = NULL; } -void EngineDeck::onInputUnconfigured(AudioInput input) { +void EngineDeck::onInputUnconfigured(const AudioInput& input) { if (input.getType() != AudioPath::VINYLCONTROL) { // This is an error! qDebug() << "WARNING: EngineDeck connected to AudioInput for a non-vinylcontrol type!"; diff --git a/src/engine/channels/enginedeck.h b/src/engine/channels/enginedeck.h index f571dadb38..cc0006c9c7 100644 --- a/src/engine/channels/enginedeck.h +++ b/src/engine/channels/enginedeck.h @@ -62,16 +62,17 @@ class EngineDeck : public EngineChannel, public AudioDestination { // the soundcard this AudioDestination was registered for! Beware, in the // case of multiple soundcards, this method is not re-entrant but it may be // concurrent with EngineMaster processing. - virtual void receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, - unsigned int nFrames); + virtual void receiveBuffer(const AudioInput& input, + const CSAMPLE* pBuffer, + unsigned int nFrames); // Called by SoundManager whenever the passthrough input is connected to a // soundcard input. - virtual void onInputConfigured(AudioInput input); + virtual void onInputConfigured(const AudioInput& input); // Called by SoundManager whenever the passthrough input is disconnected // from a soundcard input. - virtual void onInputUnconfigured(AudioInput input); + virtual void onInputUnconfigured(const AudioInput& input); // Return whether or not passthrough is active bool isPassthroughActive() const; diff --git a/src/engine/channels/enginemicrophone.cpp b/src/engine/channels/enginemicrophone.cpp index be6e8c4174..ceefe6f5b1 100644 --- a/src/engine/channels/enginemicrophone.cpp +++ b/src/engine/channels/enginemicrophone.cpp @@ -43,7 +43,7 @@ bool EngineMicrophone::isActive() { return m_wasActive; } -void EngineMicrophone::onInputConfigured(AudioInput input) { +void EngineMicrophone::onInputConfigured(const AudioInput& input) { if (input.getType() != AudioPath::MICROPHONE) { // This is an error! qWarning() << "EngineMicrophone connected to AudioInput for a non-Microphone type!"; @@ -53,7 +53,7 @@ void EngineMicrophone::onInputConfigured(AudioInput input) { m_pInputConfigured->forceSet(1.0); } -void EngineMicrophone::onInputUnconfigured(AudioInput input) { +void EngineMicrophone::onInputUnconfigured(const AudioInput& input) { if (input.getType() != AudioPath::MICROPHONE) { // This is an error! qWarning() << "EngineMicrophone connected to AudioInput for a non-Microphone type!"; @@ -63,8 +63,8 @@ void EngineMicrophone::onInputUnconfigured(AudioInput input) { m_pInputConfigured->forceSet(0.0); } -void EngineMicrophone::receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, - unsigned int nFrames) { +void EngineMicrophone::receiveBuffer( + const AudioInput& input, const CSAMPLE* pBuffer, unsigned int nFrames) { Q_UNUSED(input); Q_UNUSED(nFrames); m_sampleBuffer = pBuffer; diff --git a/src/engine/channels/enginemicrophone.h b/src/engine/channels/enginemicrophone.h index f3ac6f0b3e..0cca9c294c 100644 --- a/src/engine/channels/enginemicrophone.h +++ b/src/engine/channels/enginemicrophone.h @@ -38,16 +38,17 @@ class EngineMicrophone : public EngineChannel, public AudioDestination { // the soundcard this AudioDestination was registered for! Beware, in the // case of multiple soundcards, this method is not re-entrant but it may be // concurrent with EngineMaster processing. - virtual void receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, - unsigned int iNumSamples); + virtual void receiveBuffer(const AudioInput& input, + const CSAMPLE* pBuffer, + unsigned int iNumSamples); // Called by SoundManager whenever the microphone input is connected to a // soundcard input. - virtual void onInputConfigured(AudioInput input); + virtual void onInputConfigured(const AudioInput& input); // Called by SoundManager whenever the microphone input is disconnected from // a soundcard input. - virtual void onInputUnconfigured(AudioInput input); + virtual void onInputUnconfigured(const AudioInput& input); bool isSolo(); double getSoloDamping(); diff --git a/src/engine/controls/bpmcontrol.cpp b/src/engine/controls/bpmcontrol.cpp index 20285ca89f..52370da16d 100644 --- a/src/engine/controls/bpmcontrol.cpp +++ b/src/engine/controls/bpmcontrol.cpp @@ -40,7 +40,7 @@ constexpr int kLocalBpmSpan = 4; constexpr SINT kSamplesPerFrame = 2; } -BpmControl::BpmControl(QString group, +BpmControl::BpmControl(const QString& group, UserSettingsPointer pConfig) : EngineControl(group, pConfig), m_tapFilter(this, kBpmTapFilterLength, kBpmTapMaxInterval), diff --git a/src/engine/controls/bpmcontrol.h b/src/engine/controls/bpmcontrol.h index c23716dd1a..fc753a2e80 100644 --- a/src/engine/controls/bpmcontrol.h +++ b/src/engine/controls/bpmcontrol.h @@ -23,7 +23,7 @@ class BpmControl : public EngineControl { Q_OBJECT public: - BpmControl(QString group, UserSettingsPointer pConfig); + BpmControl(const QString& group, UserSettingsPointer pConfig); ~BpmControl() override; double getBpm() const; diff --git a/src/engine/controls/clockcontrol.cpp b/src/engine/controls/clockcontrol.cpp index 2a374aa1b4..f48660bb4c 100644 --- a/src/engine/controls/clockcontrol.cpp +++ b/src/engine/controls/clockcontrol.cpp @@ -6,7 +6,7 @@ #include "preferences/usersettings.h" #include "track/track.h" -ClockControl::ClockControl(QString group, UserSettingsPointer pConfig) +ClockControl::ClockControl(const QString& group, UserSettingsPointer pConfig) : EngineControl(group, pConfig) { m_pCOBeatActive = new ControlObject(ConfigKey(group, "beat_active")); m_pCOBeatActive->set(0.0); diff --git a/src/engine/controls/clockcontrol.h b/src/engine/controls/clockcontrol.h index 719a13bd5d..5076a5cd9b 100644 --- a/src/engine/controls/clockcontrol.h +++ b/src/engine/controls/clockcontrol.h @@ -12,8 +12,8 @@ class ControlObject; class ClockControl: public EngineControl { Q_OBJECT public: - ClockControl(QString group, - UserSettingsPointer pConfig); + ClockControl(const QString& group, + UserSettingsPointer pConfig); ~ClockControl() override; diff --git a/src/engine/controls/cuecontrol.cpp b/src/engine/controls/cuecontrol.cpp index ab53d49e46..22a1ef74f9 100644 --- a/src/engine/controls/cuecontrol.cpp +++ b/src/engine/controls/cuecontrol.cpp @@ -46,7 +46,7 @@ inline mixxx::RgbColor::optional_t doubleToRgbColor(double value) { } // namespace -CueControl::CueControl(QString group, +CueControl::CueControl(const QString& group, UserSettingsPointer pConfig) : EngineControl(group, pConfig), m_pConfig(pConfig), @@ -316,7 +316,7 @@ void CueControl::createControls() { } } -void CueControl::attachCue(CuePointer pCue, HotcueControl* pControl) { +void CueControl::attachCue(const CuePointer& pCue, HotcueControl* pControl) { VERIFY_OR_DEBUG_ASSERT(pControl) { return; } @@ -1825,7 +1825,7 @@ ConfigKey HotcueControl::keyForControl(int hotcue, const char* name) { return key; } -HotcueControl::HotcueControl(QString group, int i) +HotcueControl::HotcueControl(const QString& group, int i) : m_group(group), m_iHotcueNumber(i), m_pCue(NULL), @@ -1960,7 +1960,7 @@ double HotcueControl::getPosition() const { return m_hotcuePosition->get(); } -void HotcueControl::setCue(CuePointer pCue) { +void HotcueControl::setCue(const CuePointer& pCue) { setPosition(pCue->getPosition()); setColor(pCue->getColor()); // set pCue only if all other data is in place diff --git a/src/engine/controls/cuecontrol.h b/src/engine/controls/cuecontrol.h index ee17926cf3..e954b82cda 100644 --- a/src/engine/controls/cuecontrol.h +++ b/src/engine/controls/cuecontrol.h @@ -43,13 +43,13 @@ inline SeekOnLoadMode seekOnLoadModeFromDouble(double value) { class HotcueControl : public QObject { Q_OBJECT public: - HotcueControl(QString group, int hotcueNumber); + HotcueControl(const QString& group, int hotcueNumber); ~HotcueControl() override; inline int getHotcueNumber() { return m_iHotcueNumber; } inline CuePointer getCue() { return m_pCue; } double getPosition() const; - void setCue(CuePointer pCue); + void setCue(const CuePointer& pCue); void resetCue(); void setPosition(double position); void setColor(mixxx::RgbColor::optional_t newColor); @@ -120,8 +120,8 @@ class HotcueControl : public QObject { class CueControl : public EngineControl { Q_OBJECT public: - CueControl(QString group, - UserSettingsPointer pConfig); + CueControl(const QString& group, + UserSettingsPointer pConfig); ~CueControl() override; void hintReader(HintVector* pHintList) override; @@ -188,7 +188,7 @@ class CueControl : public EngineControl { // These methods are not thread safe, only call them when the lock is held. void createControls(); - void attachCue(CuePointer pCue, HotcueControl* pControl); + void attachCue(const CuePointer& pCue, HotcueControl* pControl); void detachCue(HotcueControl* pControl); void loadCuesFromTrack(); double quantizeCuePoint(double position); diff --git a/src/engine/controls/enginecontrol.cpp b/src/engine/controls/enginecontrol.cpp index a5d0a0555f..22eaa2ab01 100644 --- a/src/engine/controls/enginecontrol.cpp +++ b/src/engine/controls/enginecontrol.cpp @@ -7,8 +7,8 @@ #include "engine/sync/enginesync.h" #include "mixer/playermanager.h" -EngineControl::EngineControl(QString group, - UserSettingsPointer pConfig) +EngineControl::EngineControl(const QString& group, + UserSettingsPointer pConfig) : m_group(group), m_pConfig(pConfig), m_pEngineMaster(nullptr), diff --git a/src/engine/controls/enginecontrol.h b/src/engine/controls/enginecontrol.h index d8c4de38b1..e4e00f8b35 100644 --- a/src/engine/controls/enginecontrol.h +++ b/src/engine/controls/enginecontrol.h @@ -38,8 +38,8 @@ const int kNoTrigger = -1; class EngineControl : public QObject { Q_OBJECT public: - EngineControl(QString group, - UserSettingsPointer pConfig); + EngineControl(const QString& group, + UserSettingsPointer pConfig); ~EngineControl() override; // Called by EngineBuffer::process every latency period. See the above diff --git a/src/engine/controls/keycontrol.cpp b/src/engine/controls/keycontrol.cpp index cc32cbcfac..8fac74c1fd 100644 --- a/src/engine/controls/keycontrol.cpp +++ b/src/engine/controls/keycontrol.cpp @@ -14,8 +14,8 @@ static const double kLockCurrentKey = 1; static const double kKeepUnlockedKey = 1; -KeyControl::KeyControl(QString group, - UserSettingsPointer pConfig) +KeyControl::KeyControl(const QString& group, + UserSettingsPointer pConfig) : EngineControl(group, pConfig) { m_pitchRateInfo.pitchRatio = 1.0; m_pitchRateInfo.tempoRatio = 1.0; diff --git a/src/engine/controls/keycontrol.h b/src/engine/controls/keycontrol.h index 622ae59f96..7835ce3033 100644 --- a/src/engine/controls/keycontrol.h +++ b/src/engine/controls/keycontrol.h @@ -26,7 +26,7 @@ class KeyControl : public EngineControl { bool keylock; }; - KeyControl(QString group, UserSettingsPointer pConfig); + KeyControl(const QString& group, UserSettingsPointer pConfig); ~KeyControl() override; // Returns a struct, with the results of the last pitch and tempo calculations diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp index 0f3619d0e3..6888b821b3 100644 --- a/src/engine/controls/loopingcontrol.cpp +++ b/src/engine/controls/loopingcontrol.cpp @@ -21,7 +21,7 @@ double LoopingControl::s_dBeatSizes[] = { 0.03125, 0.0625, 0.125, 0.25, 0.5, // Used to generate the beatloop_%SIZE, beatjump_%SIZE, and loop_move_%SIZE CO // ConfigKeys. -ConfigKey keyForControl(QString group, QString ctrlName, double num) { +ConfigKey keyForControl(const QString& group, const QString& ctrlName, double num) { ConfigKey key; key.group = group; key.item = ctrlName.arg(num); @@ -37,8 +37,8 @@ QList LoopingControl::getBeatSizes() { return result; } -LoopingControl::LoopingControl(QString group, - UserSettingsPointer pConfig) +LoopingControl::LoopingControl(const QString& group, + UserSettingsPointer pConfig) : EngineControl(group, pConfig), m_bLoopingEnabled(false), m_bLoopRollActive(false), @@ -1305,7 +1305,7 @@ double LoopingControl::seekInsideAdjustedLoop( } } -BeatJumpControl::BeatJumpControl(QString group, double size) +BeatJumpControl::BeatJumpControl(const QString& group, double size) : m_dBeatJumpSize(size) { m_pJumpForward = new ControlPushButton( keyForControl(group, "beatjump_%1_forward", size)); @@ -1336,7 +1336,7 @@ void BeatJumpControl::slotJumpForward(double pressed) { } } -LoopMoveControl::LoopMoveControl(QString group, double size) +LoopMoveControl::LoopMoveControl(const QString& group, double size) : m_dLoopMoveSize(size) { m_pMoveForward = new ControlPushButton( keyForControl(group, "loop_move_%1_forward", size)); @@ -1367,7 +1367,7 @@ void LoopMoveControl::slotMoveForward(double v) { } } -BeatLoopingControl::BeatLoopingControl(QString group, double size) +BeatLoopingControl::BeatLoopingControl(const QString& group, double size) : m_dBeatLoopSize(size), m_bActive(false) { // This is the original beatloop control which is now deprecated. Its value diff --git a/src/engine/controls/loopingcontrol.h b/src/engine/controls/loopingcontrol.h index 3faaea34ea..45b20bc052 100644 --- a/src/engine/controls/loopingcontrol.h +++ b/src/engine/controls/loopingcontrol.h @@ -29,7 +29,7 @@ class LoopingControl : public EngineControl { public: static QList getBeatSizes(); - LoopingControl(QString group, UserSettingsPointer pConfig); + LoopingControl(const QString& group, UserSettingsPointer pConfig); ~LoopingControl() override; // process() updates the internal state of the LoopingControl to reflect the @@ -179,7 +179,7 @@ class LoopingControl : public EngineControl { class LoopMoveControl : public QObject { Q_OBJECT public: - LoopMoveControl(QString group, double size); + LoopMoveControl(const QString& group, double size); virtual ~LoopMoveControl(); signals: @@ -200,7 +200,7 @@ class LoopMoveControl : public QObject { class BeatJumpControl : public QObject { Q_OBJECT public: - BeatJumpControl(QString group, double size); + BeatJumpControl(const QString& group, double size); virtual ~BeatJumpControl(); signals: @@ -221,7 +221,7 @@ class BeatJumpControl : public QObject { class BeatLoopingControl : public QObject { Q_OBJECT public: - BeatLoopingControl(QString group, double size); + BeatLoopingControl(const QString& group, double size); virtual ~BeatLoopingControl(); void activate(); diff --git a/src/engine/controls/quantizecontrol.cpp b/src/engine/controls/quantizecontrol.cpp index e038e46b0a..28e70e274a 100644 --- a/src/engine/controls/quantizecontrol.cpp +++ b/src/engine/controls/quantizecontrol.cpp @@ -13,8 +13,8 @@ #include "track/track.h" #include "util/assert.h" -QuantizeControl::QuantizeControl(QString group, - UserSettingsPointer pConfig) +QuantizeControl::QuantizeControl(const QString& group, + UserSettingsPointer pConfig) : EngineControl(group, pConfig) { // Turn quantize OFF by default. See Bug #898213 m_pCOQuantizeEnabled = new ControlPushButton(ConfigKey(group, "quantize"), true); diff --git a/src/engine/controls/quantizecontrol.h b/src/engine/controls/quantizecontrol.h index b3bb56a627..03aae3fed5 100644 --- a/src/engine/controls/quantizecontrol.h +++ b/src/engine/controls/quantizecontrol.h @@ -14,7 +14,7 @@ class ControlPushButton; class QuantizeControl : public EngineControl { Q_OBJECT public: - QuantizeControl(QString group, UserSettingsPointer pConfig); + QuantizeControl(const QString& group, UserSettingsPointer pConfig); ~QuantizeControl() override; void setCurrentSample(const double dCurrentSample, diff --git a/src/engine/controls/ratecontrol.cpp b/src/engine/controls/ratecontrol.cpp index 221ac7bc58..99333b5b36 100644 --- a/src/engine/controls/ratecontrol.cpp +++ b/src/engine/controls/ratecontrol.cpp @@ -33,13 +33,13 @@ RateControl::RampMode RateControl::m_eRateRampMode; const double RateControl::kWheelMultiplier = 40.0; const double RateControl::kPausedJogMultiplier = 18.0; -RateControl::RateControl(QString group, - UserSettingsPointer pConfig) - : EngineControl(group, pConfig), - m_pBpmControl(NULL), - m_bTempStarted(false), - m_tempRateRatio(0.0), - m_dRateTempRampChange(0.0) { +RateControl::RateControl(const QString& group, + UserSettingsPointer pConfig) + : EngineControl(group, pConfig), + m_pBpmControl(NULL), + m_bTempStarted(false), + m_tempRateRatio(0.0), + m_dRateTempRampChange(0.0) { m_pScratchController = new PositionScratchController(group); // This is the resulting rate ratio that can be used for display or calculations. diff --git a/src/engine/controls/ratecontrol.h b/src/engine/controls/ratecontrol.h index 6740f3b241..6daa7296ce 100644 --- a/src/engine/controls/ratecontrol.h +++ b/src/engine/controls/ratecontrol.h @@ -26,147 +26,147 @@ class PositionScratchController; class RateControl : public EngineControl { Q_OBJECT public: - RateControl(QString group, UserSettingsPointer pConfig); - ~RateControl() override; - - // Enumerations which hold the state of the pitchbend buttons. - // These enumerations can be used like a bitmask. - enum class RampDirection { - None, // No buttons are held down - Down, // Down button is being held - Up, // Up button is being held - DownSmall, // DownSmall button is being held - UpSmall, // UpSmall button is being held - }; - - enum class RampMode { - Stepping = 0, // pitch takes a temporary step up/down a certain amount - Linear = 1 // pitch moves up/down in a progressively linear fashion - }; - - void setBpmControl(BpmControl* bpmcontrol); - - // Returns the current engine rate. "reportScratching" is used to tell - // the caller that the user is currently scratching, and this is used to - // disable keylock. - double calculateSpeed( - double baserate, - double speed, - bool paused, - int iSamplesPerBuffer, - bool* pReportScratching, - bool* pReportReverse); - - // Set rate change when temp rate button is pressed - static void setTemporaryRateChangeCoarseAmount(double v); - static double getTemporaryRateChangeCoarseAmount(); - // Set rate change when temp rate small button is pressed - static void setTemporaryRateChangeFineAmount(double v); - static double getTemporaryRateChangeFineAmount(); - // Set rate change when perm rate button is pressed - static void setPermanentRateChangeCoarseAmount(double v); - static double getPermanentRateChangeCoarseAmount(); - // Set rate change when perm rate small button is pressed - static void setPermanentRateChangeFineAmount(double v); - static double getPermanentRateChangeFineAmount(); - // Set Rate Ramp Mode - static void setRateRampMode(RampMode mode); - static RampMode getRateRampMode(); - // Set Rate Ramp Sensitivity - static void setRateRampSensitivity(int); - static int getRateRampSensitivity(); - void notifySeek(double dNewPlaypos) override; - bool isReverseButtonPressed(); - - public slots: - void slotRateRangeChanged(double); - void slotRateSliderChanged(double); - void slotRateRatioChanged(double); - void slotReverseRollActivate(double); - void slotControlRatePermDown(double); - void slotControlRatePermDownSmall(double); - void slotControlRatePermUp(double); - void slotControlRatePermUpSmall(double); - void slotControlFastForward(double); - void slotControlFastBack(double); - - private: - void processTempRate(const int bufferSamples); - double getJogFactor() const; - double getWheelFactor() const; - SyncMode getSyncMode() const; - - // Set rate change of the temporary pitch rate - void setRateTemp(double v); - // Add a value to the temporary pitch rate - void addRateTemp(double v); - // Subtract a value from the temporary pitch rate - void subRateTemp(double v); - // Reset the temporary pitch rate - void resetRateTemp(void); - // Get the 'Raw' Temp Rate - double getTempRate(void); - - // Values used when temp and perm rate buttons are pressed - static ControlValueAtomic m_dTemporaryRateChangeCoarse; - static ControlValueAtomic m_dTemporaryRateChangeFine; - static ControlValueAtomic m_dPermanentRateChangeCoarse; - static ControlValueAtomic m_dPermanentRateChangeFine; - - ControlPushButton* m_pButtonRateTempDown; - ControlPushButton* m_pButtonRateTempDownSmall; - ControlPushButton* m_pButtonRateTempUp; - ControlPushButton* m_pButtonRateTempUpSmall; - - ControlPushButton* m_pButtonRatePermDown; - ControlPushButton* m_pButtonRatePermDownSmall; - ControlPushButton* m_pButtonRatePermUp; - ControlPushButton* m_pButtonRatePermUpSmall; - - ControlObject* m_pRateRatio; - ControlObject* m_pRateDir; - ControlObject* m_pRateRange; - ControlPotmeter* m_pRateSlider; - ControlPotmeter* m_pRateSearch; - ControlPushButton* m_pReverseButton; - ControlPushButton* m_pReverseRollButton; - ControlObject* m_pBackButton; - ControlObject* m_pForwardButton; - - ControlTTRotary* m_pWheel; - ControlObject* m_pScratch2; - PositionScratchController* m_pScratchController; - - ControlPushButton* m_pScratch2Enable; - ControlObject* m_pJog; - ControlObject* m_pVCEnabled; - ControlObject* m_pVCScratching; - ControlObject* m_pVCMode; - ControlObject* m_pScratch2Scratching; - Rotary* m_pJogFilter; - - ControlObject* m_pSampleRate; - - // For Master Sync - BpmControl* m_pBpmControl; - - ControlProxy* m_pSyncMode; - ControlProxy* m_pSlipEnabled; - - // This is true if we've already started to ramp the rate - bool m_bTempStarted; - // Set the Temporary Rate Change Mode - static RampMode m_eRateRampMode; - // The Rate Temp Sensitivity, the higher it is the slower it gets - static int m_iRateRampSensitivity; - // Factor applied to the deprecated "wheel" rate value. - static const double kWheelMultiplier; - // Factor applied to jogwheels when the track is paused to speed up seeking. - static const double kPausedJogMultiplier; - // Temporary pitchrate, added to the permanent rate for calculateRate - double m_tempRateRatio; - // Speed for temporary rate change - double m_dRateTempRampChange; + RateControl(const QString& group, UserSettingsPointer pConfig); + ~RateControl() override; + + // Enumerations which hold the state of the pitchbend buttons. + // These enumerations can be used like a bitmask. + enum class RampDirection { + None, // No buttons are held down + Down, // Down button is being held + Up, // Up button is being held + DownSmall, // DownSmall button is being held + UpSmall, // UpSmall button is being held + }; + + enum class RampMode { + Stepping = 0, // pitch takes a temporary step up/down a certain amount + Linear = 1 // pitch moves up/down in a progressively linear fashion + }; + + void setBpmControl(BpmControl* bpmcontrol); + + // Returns the current engine rate. "reportScratching" is used to tell + // the caller that the user is currently scratching, and this is used to + // disable keylock. + double calculateSpeed( + double baserate, + double speed, + bool paused, + int iSamplesPerBuffer, + bool* pReportScratching, + bool* pReportReverse); + + // Set rate change when temp rate button is pressed + static void setTemporaryRateChangeCoarseAmount(double v); + static double getTemporaryRateChangeCoarseAmount(); + // Set rate change when temp rate small button is pressed + static void setTemporaryRateChangeFineAmount(double v); + static double getTemporaryRateChangeFineAmount(); + // Set rate change when perm rate button is pressed + static void setPermanentRateChangeCoarseAmount(double v); + static double getPermanentRateChangeCoarseAmount(); + // Set rate change when perm rate small button is pressed + static void setPermanentRateChangeFineAmount(double v); + static double getPermanentRateChangeFineAmount(); + // Set Rate Ramp Mode + static void setRateRampMode(RampMode mode); + static RampMode getRateRampMode(); + // Set Rate Ramp Sensitivity + static void setRateRampSensitivity(int); + static int getRateRampSensitivity(); + void notifySeek(double dNewPlaypos) override; + bool isReverseButtonPressed(); + +public slots: + void slotRateRangeChanged(double); + void slotRateSliderChanged(double); + void slotRateRatioChanged(double); + void slotReverseRollActivate(double); + void slotControlRatePermDown(double); + void slotControlRatePermDownSmall(double); + void slotControlRatePermUp(double); + void slotControlRatePermUpSmall(double); + void slotControlFastForward(double); + void slotControlFastBack(double); + +private: + void processTempRate(const int bufferSamples); + double getJogFactor() const; + double getWheelFactor() const; + SyncMode getSyncMode() const; + + // Set rate change of the temporary pitch rate + void setRateTemp(double v); + // Add a value to the temporary pitch rate + void addRateTemp(double v); + // Subtract a value from the temporary pitch rate + void subRateTemp(double v); + // Reset the temporary pitch rate + void resetRateTemp(void); + // Get the 'Raw' Temp Rate + double getTempRate(void); + + // Values used when temp and perm rate buttons are pressed + static ControlValueAtomic m_dTemporaryRateChangeCoarse; + static ControlValueAtomic m_dTemporaryRateChangeFine; + static ControlValueAtomic m_dPermanentRateChangeCoarse; + static ControlValueAtomic m_dPermanentRateChangeFine; + + ControlPushButton* m_pButtonRateTempDown; + ControlPushButton* m_pButtonRateTempDownSmall; + ControlPushButton* m_pButtonRateTempUp; + ControlPushButton* m_pButtonRateTempUpSmall; + + ControlPushButton* m_pButtonRatePermDown; + ControlPushButton* m_pButtonRatePermDownSmall; + ControlPushButton* m_pButtonRatePermUp; + ControlPushButton* m_pButtonRatePermUpSmall; + + ControlObject* m_pRateRatio; + ControlObject* m_pRateDir; + ControlObject* m_pRateRange; + ControlPotmeter* m_pRateSlider; + ControlPotmeter* m_pRateSearch; + ControlPushButton* m_pReverseButton; + ControlPushButton* m_pReverseRollButton; + ControlObject* m_pBackButton; + ControlObject* m_pForwardButton; + + ControlTTRotary* m_pWheel; + ControlObject* m_pScratch2; + PositionScratchController* m_pScratchController