Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track/BPM: add bpmlock control #13199

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/engine/controls/bpmcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ BpmControl::BpmControl(const QString& group,
this, &BpmControl::slotTapFilter,
Qt::DirectConnection);

m_pToggleBpmLock = std::make_unique<ControlPushButton>(
ConfigKey(group, "bpm_toggle_lock"), false);
connect(m_pToggleBpmLock.get(),
&ControlObject::valueChanged,
m_pBpmLock = std::make_unique<ControlPushButton>(
ConfigKey(group, "bpmlock"), false);
m_pBpmLock->setButtonMode(ControlPushButton::TOGGLE);
m_pBpmLock->connectValueChangeRequest(
this,
&BpmControl::slotToggleBpmLock,
Qt::DirectConnection);
Expand Down Expand Up @@ -983,6 +983,10 @@ void BpmControl::trackBeatsUpdated(mixxx::BeatsPointer pBeats) {
resetSyncAdjustment();
}

void BpmControl::trackBpmLockChanged(bool locked) {
m_pBpmLock->setAndConfirm(locked);
}

void BpmControl::notifySeek(mixxx::audio::FramePos position) {
updateBeatDistance(position);
}
Expand Down Expand Up @@ -1030,15 +1034,14 @@ void BpmControl::slotBeatsTranslateMatchAlignment(double v) {
}

void BpmControl::slotToggleBpmLock(double v) {
if (v <= 0) {
return;
}
Q_UNUSED(v);
const TrackPointer pTrack = getEngineBuffer()->getLoadedTrack();
if (!pTrack) {
return;
}
bool locked = pTrack->isBpmLocked();
pTrack->setBpmLocked(!locked);
// The pushbutton is updated in trackBpmLockChanged() via bpmLockChanged() signal.
}

mixxx::Bpm BpmControl::updateLocalBpm() {
Expand Down
3 changes: 2 additions & 1 deletion src/engine/controls/bpmcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class BpmControl : public EngineControl {
double getRateRatio() const;
void trackLoaded(TrackPointer pNewTrack) override;
void trackBeatsUpdated(mixxx::BeatsPointer pBeats) override;
void trackBpmLockChanged(bool locked);
void notifySeek(mixxx::audio::FramePos position) override;

private slots:
Expand Down Expand Up @@ -146,7 +147,7 @@ class BpmControl : public EngineControl {
ControlPushButton* m_pTranslateBeatsLater;
ControlEncoder* m_pTranslateBeatsMove;

std::unique_ptr<ControlPushButton> m_pToggleBpmLock;
std::unique_ptr<ControlPushButton> m_pBpmLock;

// The current effective BPM of the engine
ControlLinPotmeter* m_pEngineBpm;
Expand Down
10 changes: 8 additions & 2 deletions src/engine/enginebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,18 @@ void EngineBuffer::notifyTrackLoaded(
}

if (pNewTrack) {
connect(
pNewTrack.get(),
connect(pNewTrack.get(),
&Track::beatsUpdated,
this,
&EngineBuffer::slotUpdatedTrackBeats,
Qt::DirectConnection);
connect(pNewTrack.get(),
&Track::bpmLockChanged,
m_pBpmControl,
&BpmControl::trackBpmLockChanged,
Qt::DirectConnection);
bool bpmLocked = pNewTrack.get()->isBpmLocked();
m_pBpmControl->trackBpmLockChanged(bpmLocked);
}

// Inform BaseTrackPlayer via a queued connection
Expand Down
1 change: 1 addition & 0 deletions src/track/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,7 @@ void Track::setBpmLocked(bool bpmLocked) {
auto locked = lockMutex(&m_qMutex);
if (compareAndSet(m_record.ptrBpmLocked(), bpmLocked)) {
markDirtyAndUnlock(&locked);
emit bpmLockChanged(bpmLocked);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/track/track.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ class Track : public QObject {
void trackTotalChanged(const QString&);
void commentChanged(const QString&);
void bpmChanged();
void bpmLockChanged(bool locked);
void keyChanged();
void timesPlayedChanged();
void durationChanged();
Expand Down