diff --git a/src/controllers/controlpickermenu.cpp b/src/controllers/controlpickermenu.cpp index c3a1c9b0666..42fbc0b8096 100644 --- a/src/controllers/controlpickermenu.cpp +++ b/src/controllers/controlpickermenu.cpp @@ -272,6 +272,10 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent) tr("Adjust Beatgrid - Match Alignment"), tr("Adjust beatgrid to match another playing deck."), pBpmMenu); + addDeckAndSamplerControl("bpm_toggle_lock", + tr("Toggle the BPM/beatgrid lock"), + tr("Toggle the BPM/beatgrid lock"), + pBpmMenu); pBpmMenu->addSeparator(); addDeckAndSamplerControl("quantize", tr("Quantize Mode"), tr("Toggle quantize mode"), pBpmMenu); diff --git a/src/engine/controls/bpmcontrol.cpp b/src/engine/controls/bpmcontrol.cpp index be5016938ee..52bef4ca3ba 100644 --- a/src/engine/controls/bpmcontrol.cpp +++ b/src/engine/controls/bpmcontrol.cpp @@ -130,6 +130,15 @@ BpmControl::BpmControl(const QString& group, this, &BpmControl::slotTapFilter, Qt::DirectConnection); + m_pToggleBpmLock = std::make_unique( + ConfigKey(group, "bpm_toggle_lock"), false); + m_pToggleBpmLock->setKbdRepeatable(true); + connect(m_pToggleBpmLock.get(), + &ControlObject::valueChanged, + this, + &BpmControl::slotToggleBpmLock, + Qt::DirectConnection); + // Measures distance from last beat in percentage: 0.5 = half-beat away. m_pThisBeatDistance = new ControlProxy(group, "beat_distance", this); m_pSyncMode = new ControlProxy(group, "sync_mode", this); @@ -1021,6 +1030,18 @@ void BpmControl::slotBeatsTranslateMatchAlignment(double v) { } } +void BpmControl::slotToggleBpmLock(double v) { + if (v <= 0) { + return; + } + const TrackPointer pTrack = getEngineBuffer()->getLoadedTrack(); + if (!pTrack) { + return; + } + bool locked = pTrack->isBpmLocked(); + pTrack->setBpmLocked(!locked); +} + mixxx::Bpm BpmControl::updateLocalBpm() { mixxx::Bpm prevLocalBpm = mixxx::Bpm(m_pLocalBpm->get()); mixxx::Bpm localBpm; diff --git a/src/engine/controls/bpmcontrol.h b/src/engine/controls/bpmcontrol.h index e08a3164088..af174cf9d27 100644 --- a/src/engine/controls/bpmcontrol.h +++ b/src/engine/controls/bpmcontrol.h @@ -108,6 +108,7 @@ class BpmControl : public EngineControl { void slotUpdateEngineBpm(double v = 0.0); void slotBeatsTranslate(double); void slotBeatsTranslateMatchAlignment(double); + void slotToggleBpmLock(double); private: SyncMode getSyncMode() const { @@ -145,6 +146,8 @@ class BpmControl : public EngineControl { ControlPushButton* m_pTranslateBeatsLater; ControlEncoder* m_pTranslateBeatsMove; + std::unique_ptr m_pToggleBpmLock; + // The current effective BPM of the engine ControlLinPotmeter* m_pEngineBpm;