Skip to content

Commit

Permalink
Merge pull request mixxxdj#13041 from FrankwaP/tempo_locking_controls
Browse files Browse the repository at this point in the history
Tempo locking controls
  • Loading branch information
ronso0 authored Apr 10, 2024
2 parents b4727f8 + faf5ed8 commit ada244c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/controllers/controlpickermenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
21 changes: 21 additions & 0 deletions src/engine/controls/bpmcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ BpmControl::BpmControl(const QString& group,
this, &BpmControl::slotTapFilter,
Qt::DirectConnection);

m_pToggleBpmLock = std::make_unique<ControlPushButton>(
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);
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/engine/controls/bpmcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -145,6 +146,8 @@ class BpmControl : public EngineControl {
ControlPushButton* m_pTranslateBeatsLater;
ControlEncoder* m_pTranslateBeatsMove;

std::unique_ptr<ControlPushButton> m_pToggleBpmLock;

// The current effective BPM of the engine
ControlLinPotmeter* m_pEngineBpm;

Expand Down

0 comments on commit ada244c

Please sign in to comment.