From 0bad7daf7ffd01d6dbf5d83229be788f47188a76 Mon Sep 17 00:00:00 2001 From: Lukas Waslowski Date: Fri, 1 Nov 2024 18:51:34 +0000 Subject: [PATCH] Rename BpmTapControl to TapControl --- CMakeLists.txt | 2 +- .../{bpm/bpmtapcontrol.cpp => tapcontrol.cpp} | 30 ++++++++----------- .../{bpm/bpmtapcontrol.h => tapcontrol.h} | 6 ++-- src/engine/enginebuffer.cpp | 10 +++---- src/engine/enginebuffer.h | 4 +-- 5 files changed, 23 insertions(+), 29 deletions(-) rename src/engine/controls/{bpm/bpmtapcontrol.cpp => tapcontrol.cpp} (80%) rename src/engine/controls/{bpm/bpmtapcontrol.h => tapcontrol.h} (79%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c27c2bd3be6..2ea3fa61d9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -851,7 +851,6 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL src/engine/channels/enginechannel.cpp src/engine/channels/enginedeck.cpp src/engine/channels/enginemicrophone.cpp - src/engine/controls/bpm/bpmtapcontrol.cpp src/engine/controls/bpmcontrol.cpp src/engine/controls/clockcontrol.cpp src/engine/controls/cuecontrol.cpp @@ -860,6 +859,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL src/engine/controls/loopingcontrol.cpp src/engine/controls/quantizecontrol.cpp src/engine/controls/ratecontrol.cpp + src/engine/controls/tapcontrol.cpp src/engine/effects/engineeffect.cpp src/engine/effects/engineeffectchain.cpp src/engine/effects/engineeffectsdelay.cpp diff --git a/src/engine/controls/bpm/bpmtapcontrol.cpp b/src/engine/controls/tapcontrol.cpp similarity index 80% rename from src/engine/controls/bpm/bpmtapcontrol.cpp rename to src/engine/controls/tapcontrol.cpp index c9d239e9b6f..3dc0b301a19 100644 --- a/src/engine/controls/bpm/bpmtapcontrol.cpp +++ b/src/engine/controls/tapcontrol.cpp @@ -1,15 +1,15 @@ -#include "engine/controls/bpm/bpmtapcontrol.h" +#include "engine/controls/tapcontrol.h" #include "control/controlpushbutton.h" #include "engine/enginebuffer.h" -#include "moc_bpmtapcontrol.cpp" +#include "moc_tapcontrol.cpp" #include "track/beatutils.h" #include "track/track.h" #include "util/duration.h" #include "util/logger.h" namespace { -const mixxx::Logger kLogger("BpmTapControl"); +const mixxx::Logger kLogger("TapControl"); // Maximum allowed interval between beats (calculated from kBpmTapMin). constexpr double kBpmTapMin = 30.0; @@ -30,7 +30,7 @@ mixxx::Bpm averageBpmRoundedWithinRange(double averageLength, double rateRatio) } } // namespace -BpmTapControl::BpmTapControl(const QString& group, +TapControl::TapControl(const QString& group, UserSettingsPointer pConfig) : EngineControl(group, pConfig), m_bpmTapFilter(this, kBpmTapFilterLength, kBpmTapMaxInterval), @@ -40,12 +40,12 @@ BpmTapControl::BpmTapControl(const QString& group, connect(m_pBpmTap.get(), &ControlObject::valueChanged, this, - &BpmTapControl::slotBpmTap, + &TapControl::slotBpmTap, Qt::DirectConnection); connect(&m_bpmTapFilter, &TapFilter::tapped, this, - &BpmTapControl::slotBpmTapFilter, + &TapControl::slotBpmTapFilter, Qt::DirectConnection); // Tap the tempo (playback speed) @@ -53,22 +53,22 @@ BpmTapControl::BpmTapControl(const QString& group, connect(m_pTempoTap.get(), &ControlObject::valueChanged, this, - &BpmTapControl::slotTempoTap, + &TapControl::slotTempoTap, Qt::DirectConnection); connect(&m_tempoTapFilter, &TapFilter::tapped, this, - &BpmTapControl::slotTempoTapFilter, + &TapControl::slotTempoTapFilter, Qt::DirectConnection); } -void BpmTapControl::slotBpmTap(double v) { +void TapControl::slotBpmTap(double v) { if (v > 0) { m_bpmTapFilter.tap(); } } -void BpmTapControl::slotBpmTapFilter(double averageLength, int numSamples) { +void TapControl::slotBpmTapFilter(double averageLength, int numSamples) { // averageLength is the average interval in milliseconds tapped over // numSamples samples. Have to convert to BPM now: @@ -109,13 +109,13 @@ void BpmTapControl::slotBpmTapFilter(double averageLength, int numSamples) { pTrack->trySetBeats(*newBeats); } -void BpmTapControl::slotTempoTap(double v) { +void TapControl::slotTempoTap(double v) { if (v > 0) { m_tempoTapFilter.tap(); } } -void BpmTapControl::slotTempoTapFilter(double averageLength, int numSamples) { +void TapControl::slotTempoTapFilter(double averageLength, int numSamples) { // averageLength is the average interval in milliseconds tapped over // numSamples samples. Have to convert to BPM now: if (averageLength <= 0 || numSamples < 4) { @@ -128,9 +128,5 @@ void BpmTapControl::slotTempoTapFilter(double averageLength, int numSamples) { } auto averageBpm = averageBpmRoundedWithinRange(averageLength, 1.0); - m_pEngineBpm->set(averageBpm.value()); - // NOTE(ronso0) When setting the control, m_pEngineBpm->valueChanged() - // is not emitted (with Qt6) (it is when setting via a ControlProxy), - // so call the slot directly. - slotUpdateRateSlider(0.0 /* value is actually ignored */); + getEngineBuffer()->setPlaybackSpeedFromBpm(averageBpm); } diff --git a/src/engine/controls/bpm/bpmtapcontrol.h b/src/engine/controls/tapcontrol.h similarity index 79% rename from src/engine/controls/bpm/bpmtapcontrol.h rename to src/engine/controls/tapcontrol.h index bcf873f8d4d..4aa07296b8b 100644 --- a/src/engine/controls/bpm/bpmtapcontrol.h +++ b/src/engine/controls/tapcontrol.h @@ -1,4 +1,5 @@ #pragma once +#pragma once #include @@ -12,10 +13,7 @@ class ControlPushButton; -/// BpmTapControl handles the bpm_tap and tempo_tap buttons. It is related to, -/// but separate from, BeatGridControl and BpmControl because its functionality -/// is pretty much self-contained. -class BpmTapControl : public EngineControl { +class TapControl : public EngineControl { Q_OBJECT public: diff --git a/src/engine/enginebuffer.cpp b/src/engine/enginebuffer.cpp index 764c2b67460..a2870aca15e 100644 --- a/src/engine/enginebuffer.cpp +++ b/src/engine/enginebuffer.cpp @@ -10,7 +10,6 @@ #include "engine/bufferscalers/enginebufferscalest.h" #include "engine/cachingreader/cachingreader.h" #include "engine/channels/enginechannel.h" -#include "engine/controls/bpm/bpmtapcontrol.h" #include "engine/controls/bpmcontrol.h" #include "engine/controls/clockcontrol.h" #include "engine/controls/cuecontrol.h" @@ -19,6 +18,7 @@ #include "engine/controls/loopingcontrol.h" #include "engine/controls/quantizecontrol.h" #include "engine/controls/ratecontrol.h" +#include "engine/controls/tapcontrol.h" #include "engine/enginemixer.h" #include "engine/readaheadmanager.h" #include "engine/sync/enginesync.h" @@ -66,7 +66,7 @@ EngineBuffer::EngineBuffer(const QString& group, m_pSyncControl(nullptr), m_pVinylControlControl(nullptr), m_pRateControl(nullptr), - m_pBpmTapControl(nullptr), + m_pTapControl(nullptr), m_pBpmControl(nullptr), m_pKeyControl(nullptr), m_pReadAheadManager(nullptr), @@ -210,9 +210,9 @@ EngineBuffer::EngineBuffer(const QString& group, // Looping Control needs Rate Control for Reverse Button m_pLoopingControl->setRateControl(m_pRateControl); - // Create the BPM Tap Controller - m_pBpmTapControl = new BpmTapControl(group, pConfig); - addControl(m_pBpmTapControl); + // Create the BPM & Tempo Tap Controller + m_pTapControl = new BpmTapControl(group, pConfig); + addControl(m_pTapControl); // Create the BPM Controller m_pBpmControl = new BpmControl(group, pConfig); diff --git a/src/engine/enginebuffer.h b/src/engine/enginebuffer.h index fecf1131b99..aab3e582b6e 100644 --- a/src/engine/enginebuffer.h +++ b/src/engine/enginebuffer.h @@ -31,10 +31,10 @@ class EngineChannel; class EngineControl; class BpmControl; -class BpmTapControl; class KeyControl; class RateControl; class SyncControl; +class TapControl; class VinylControlControl; class LoopingControl; class ClockControl; @@ -322,7 +322,7 @@ class EngineBuffer : public EngineObject { SyncControl* m_pSyncControl; VinylControlControl* m_pVinylControlControl; RateControl* m_pRateControl; - BpmTapControl* m_pBpmTapControl; + TapControl* m_pTapControl; BpmControl* m_pBpmControl; KeyControl* m_pKeyControl; ClockControl* m_pClockControl;