Skip to content

Commit

Permalink
Adding tempo locking/unlocking controls
Browse files Browse the repository at this point in the history
std:make_unique instead of new

fix crash when channel/trackpointer is empty

renaming the variables changing "tempo" for "bpm"

"Toggle lock" instead of "lock"/"unlock"

forgot to save the file lol

Update src/engine/controls/bpmcontrol.cpp

Co-authored-by: ronso0 <ronso0@mixxx.org>

fixing the description

unnecessary comment

more explicit command
  • Loading branch information
FrankwaP committed Apr 9, 2024
1 parent 9f68007 commit faf5ed8
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 faf5ed8

Please sign in to comment.