diff options
author | Owen Williams <owilliams@mixxx.org> | 2021-04-03 13:42:31 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-03 13:42:31 -0400 |
commit | f9bf0aa075cc859651b12e8d38b1ccf3fa837d43 (patch) | |
tree | 148ac7a63c04ebc11e3e8af4f65b889dc6185c83 | |
parent | 8ff946c223281932ef9a017e6c6590a9ad161ada (diff) | |
parent | d36c24b9a896203c9d0ca77184764b24cf7b2bd2 (diff) |
Merge pull request #3762 from daschuer/internalBaseBpm
Fix double jump when changing internal clock bpm
-rw-r--r-- | src/engine/sync/internalclock.cpp | 6 | ||||
-rw-r--r-- | src/engine/sync/internalclock.h | 4 | ||||
-rw-r--r-- | src/test/enginesynctest.cpp | 3 |
3 files changed, 10 insertions, 3 deletions
diff --git a/src/engine/sync/internalclock.cpp b/src/engine/sync/internalclock.cpp index d12eebfdf4..a0b15a9a8c 100644 --- a/src/engine/sync/internalclock.cpp +++ b/src/engine/sync/internalclock.cpp @@ -78,6 +78,9 @@ void InternalClock::slotSyncMasterEnabledChangeRequest(double state) { m_mode = SYNC_MASTER_EXPLICIT; return; } + if (mode == SYNC_NONE) { + m_dBaseBpm = m_dOldBpm; + } m_pEngineSync->requestSyncMode(this, SYNC_MASTER_EXPLICIT); } else { // Turning off master goes back to follower mode. @@ -138,7 +141,7 @@ void InternalClock::setMasterParams(double beatDistance, double baseBpm, double if (kLogger.traceEnabled()) { kLogger.trace() << "InternalClock::setMasterParams" << beatDistance << baseBpm << bpm; } - if (bpm == 0) { + if (bpm <= 0.0 || baseBpm <= 0.0) { return; } m_dBaseBpm = baseBpm; @@ -147,7 +150,6 @@ void InternalClock::setMasterParams(double beatDistance, double baseBpm, double } void InternalClock::slotBpmChanged(double bpm) { - m_dBaseBpm = bpm; updateBeatLength(m_iOldSampleRate, bpm); if (!isSynchronized()) { return; diff --git a/src/engine/sync/internalclock.h b/src/engine/sync/internalclock.h index ab05889579..735bdd8536 100644 --- a/src/engine/sync/internalclock.h +++ b/src/engine/sync/internalclock.h @@ -73,6 +73,10 @@ class InternalClock : public QObject, public Clock, public Syncable { int m_iOldSampleRate; double m_dOldBpm; + + // This is the BPM value at unity adopted when sync is enabled. + // It is used to relate the followers and must not change when + // the bpm is adjusted to avoid sudden double/half rate changes. double m_dBaseBpm; // The internal clock rate is stored in terms of samples per beat. diff --git a/src/test/enginesynctest.cpp b/src/test/enginesynctest.cpp index 78615e418d..a1ace0478c 100644 --- a/src/test/enginesynctest.cpp +++ b/src/test/enginesynctest.cpp @@ -337,10 +337,11 @@ TEST_F(EngineSyncTest, InternalMasterSetFollowerSliderMoves) { // If internal is master, and we turn on a follower, the slider should move. auto pButtonMasterSyncInternal = std::make_unique<ControlProxy>( m_sInternalClockGroup, "sync_master"); - pButtonMasterSyncInternal->slotSet(1); auto pMasterSyncSlider = std::make_unique<ControlProxy>(m_sInternalClockGroup, "bpm"); + pMasterSyncSlider->set(100.0); + pButtonMasterSyncInternal->slotSet(1); // Set the file bpm of channel 1 to 80 bpm. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 80, 0.0); |