Skip to content

Commit

Permalink
Rename BpmTapControl to TapControl
Browse files Browse the repository at this point in the history
  • Loading branch information
cr7pt0gr4ph7 committed Nov 1, 2024
1 parent dcc83b1 commit 0bad7da
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -30,7 +30,7 @@ mixxx::Bpm averageBpmRoundedWithinRange(double averageLength, double rateRatio)
}
} // namespace

BpmTapControl::BpmTapControl(const QString& group,
TapControl::TapControl(const QString& group,

Check failure on line 33 in src/engine/controls/tapcontrol.cpp

View workflow job for this annotation

GitHub Actions / coverage

no declaration matches ‘TapControl::TapControl(const QString&, UserSettingsPointer)’
UserSettingsPointer pConfig)
: EngineControl(group, pConfig),
m_bpmTapFilter(this, kBpmTapFilterLength, kBpmTapMaxInterval),
Expand All @@ -40,35 +40,35 @@ 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)
m_pTempoTap = std::make_unique<ControlPushButton>(ConfigKey(group, "tempo_tap"));
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:

Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#pragma once

#include <gtest/gtest_prod.h>

Expand All @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions src/engine/enginebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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);

Check failure on line 214 in src/engine/enginebuffer.cpp

View workflow job for this annotation

GitHub Actions / clazy

unknown type name 'BpmTapControl'

Check failure on line 214 in src/engine/enginebuffer.cpp

View workflow job for this annotation

GitHub Actions / clang-tidy

unknown type name 'BpmTapControl' [clang-diagnostic-error]

Check failure on line 214 in src/engine/enginebuffer.cpp

View workflow job for this annotation

GitHub Actions / coverage

expected type-specifier before ‘BpmTapControl’
addControl(m_pTapControl);

// Create the BPM Controller
m_pBpmControl = new BpmControl(group, pConfig);
Expand Down
4 changes: 2 additions & 2 deletions src/engine/enginebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0bad7da

Please sign in to comment.