diff --git a/res/controllers/American Audio VMS4.midi.xml b/res/controllers/American Audio VMS4.midi.xml index c1593bdb471..750b47533a9 100644 --- a/res/controllers/American Audio VMS4.midi.xml +++ b/res/controllers/American Audio VMS4.midi.xml @@ -3,7 +3,7 @@ American Audio VMS4/4.1 Anders Gunnarsson & Sean M. Pappalardo - 2-deck control/4-deck mixer preset for Mixxx 2.1. + 2-deck control/4-deck mixer preset for Mixxx 2.1. Assumes "Post EQ" mode. (See Wiki for full setup instructions.) american_audio_vms4 @@ -295,13 +295,13 @@ Assumes "Post EQ" mode. (See Wiki for full setup instructions.) [Channel1] - sync_master + sync_leader 0x91 0x0D [Channel1] - sync_master + sync_leader 0x81 0x0D @@ -1000,13 +1000,13 @@ Assumes "Post EQ" mode. (See Wiki for full setup instructions.) [Channel2] - sync_master + sync_leader 0x91 0x2F [Channel2] - sync_master + sync_leader 0x81 0x2F @@ -1615,7 +1615,7 @@ Assumes "Post EQ" mode. (See Wiki for full setup instructions.) - + [Channel3] @@ -1671,7 +1671,7 @@ Assumes "Post EQ" mode. (See Wiki for full setup instructions.) - + [Channel4] @@ -1727,7 +1727,7 @@ Assumes "Post EQ" mode. (See Wiki for full setup instructions.) - + diff --git a/res/controllers/Hercules DJ Control MP3 e2-scripts.js b/res/controllers/Hercules DJ Control MP3 e2-scripts.js index a019e21604d..745d5bbabe3 100644 --- a/res/controllers/Hercules DJ Control MP3 e2-scripts.js +++ b/res/controllers/Hercules DJ Control MP3 e2-scripts.js @@ -731,7 +731,7 @@ HerculesMP3e2.jogWheel = function(midino, control, value, status, group) { // drive master tempo led connected to sync_mode HerculesMP3e2.syncmode = function(value, group, control) { - // Following code was used for sync_master control. + // Following code was used for sync_leader control. // Deactivated for now due to https://bugs.launchpad.net/mixxx/+bug/1456801 // currently (2015-05-20) explicit master mode is not supported. // Switched to sync_enabled (binary) control @@ -1004,4 +1004,4 @@ HerculesMP3e2.filterMid = function(midino, control, value, status, group) { HerculesMP3e2.filterLow = function(midino, control, value, status, group) { HerculesMP3e2.filterKnob(group, "parameter1", value); -}; \ No newline at end of file +}; diff --git a/res/controllers/Hercules DJControl Starlight.midi.xml b/res/controllers/Hercules DJControl Starlight.midi.xml index a33e8e83259..78b8cd0a5ca 100644 --- a/res/controllers/Hercules DJControl Starlight.midi.xml +++ b/res/controllers/Hercules DJControl Starlight.midi.xml @@ -202,7 +202,7 @@ // Sync [Channel1] - sync_master + sync_leader SHIFT + Sync: Sync Master 0x94 0x05 @@ -266,7 +266,7 @@ // Sync [Channel2] - sync_master + sync_leader SHIFT + Sync: Sync Master 0x95 0x05 @@ -1082,7 +1082,7 @@ [Channel1] - sync_master + sync_leader SYNC LED Deck A(SHIFT mode) 0.5 1 @@ -1130,7 +1130,7 @@ [Channel2] - sync_master + sync_leader SYNC LED Deck B(SHIFT mode) 0.5 1 diff --git a/res/controllers/Hercules_DJControl_Inpulse_200.midi.xml b/res/controllers/Hercules_DJControl_Inpulse_200.midi.xml index d9d36d6b143..79ac80305f8 100644 --- a/res/controllers/Hercules_DJControl_Inpulse_200.midi.xml +++ b/res/controllers/Hercules_DJControl_Inpulse_200.midi.xml @@ -283,7 +283,7 @@ [Channel1] - sync_master + sync_leader SHIFT + Sync: Sync Master 0x94 0x05 @@ -349,7 +349,7 @@ [Channel2] - sync_master + sync_leader SHIFT + Sync: Sync Master 0x95 0x05 @@ -1181,7 +1181,7 @@ [Channel1] - sync_master + sync_leader SYNC LED Deck A(SHIFT mode) 0.5 1 @@ -1225,7 +1225,7 @@ [Channel2] - sync_master + sync_leader SYNC LED Deck B(SHIFT mode) 0.5 1 diff --git a/res/controllers/Hercules_DJControl_Inpulse_300.midi.xml b/res/controllers/Hercules_DJControl_Inpulse_300.midi.xml index 840582ea61b..ed31dcfb0fe 100644 --- a/res/controllers/Hercules_DJControl_Inpulse_300.midi.xml +++ b/res/controllers/Hercules_DJControl_Inpulse_300.midi.xml @@ -364,7 +364,7 @@ [Channel1] - sync_master + sync_leader SHIFT + Sync: Sync Master 0x94 0x05 @@ -443,7 +443,7 @@ [Channel2] - sync_master + sync_leader SHIFT + Sync: Sync Master 0x95 0x05 @@ -1693,7 +1693,7 @@ [Channel1] - sync_master + sync_leader SYNC LED Deck A(SHIFT mode) 0.5 1 @@ -1759,7 +1759,7 @@ [Channel2] - sync_master + sync_leader SYNC LED Deck B(SHIFT mode) 0.5 1 diff --git a/res/controllers/Hercules_DJControl_Jogvision.midi.xml b/res/controllers/Hercules_DJControl_Jogvision.midi.xml index d7723cd3b5a..1f7aa166a8d 100644 --- a/res/controllers/Hercules_DJControl_Jogvision.midi.xml +++ b/res/controllers/Hercules_DJControl_Jogvision.midi.xml @@ -110,7 +110,7 @@ [Channel1] - sync_master + sync_leader SHIFT + Sync: Sync Master 0x90 0x35 @@ -594,7 +594,7 @@ [Channel2] - sync_master + sync_leader SHIFT + Sync: Sync Master 0x91 0x35 @@ -1473,7 +1473,7 @@ [Channel1] - sync_master + sync_leader SYNC LED Deck A(SHIFT mode) 0.5 1 @@ -1550,7 +1550,7 @@ [Channel2] - sync_master + sync_leader SYNC LED Deck A(SHIFT mode) 0.5 1 diff --git a/res/controllers/Novation-Launchpad MK2-scripts.js b/res/controllers/Novation-Launchpad MK2-scripts.js index bcfc1eff159..a201965e3d4 100644 --- a/res/controllers/Novation-Launchpad MK2-scripts.js +++ b/res/controllers/Novation-Launchpad MK2-scripts.js @@ -2202,9 +2202,9 @@ var NovationLaunchpadMK2 = (function () { name: 'sync_enabled', type: 'binary' }, - sync_master: { + sync_leader: { group: "[".concat(type).concat(i, "]"), - name: 'sync_master', + name: 'sync_leader', type: 'binary' }, sync_mode: { @@ -6765,9 +6765,9 @@ var NovationLaunchpadMK2 = (function () { } }, function () { if (bindings.syncMode.getValue() === 2) { - deck.sync_master.setValue(0); + deck.sync_leader.setValue(0); } else { - deck.sync_master.setValue(1); + deck.sync_leader.setValue(1); } }); } diff --git a/res/controllers/Novation-Launchpad-scripts.js b/res/controllers/Novation-Launchpad-scripts.js index 6817fd5d074..16ef464ef68 100644 --- a/res/controllers/Novation-Launchpad-scripts.js +++ b/res/controllers/Novation-Launchpad-scripts.js @@ -2202,9 +2202,9 @@ var NovationLaunchpad = (function () { name: 'sync_enabled', type: 'binary' }, - sync_master: { + sync_leader: { group: "[".concat(type).concat(i, "]"), - name: 'sync_master', + name: 'sync_leader', type: 'binary' }, sync_mode: { @@ -6765,9 +6765,9 @@ var NovationLaunchpad = (function () { } }, function () { if (bindings.syncMode.getValue() === 2) { - deck.sync_master.setValue(0); + deck.sync_leader.setValue(0); } else { - deck.sync_master.setValue(1); + deck.sync_leader.setValue(1); } }); } diff --git a/res/controllers/Roland_DJ-505-scripts.js b/res/controllers/Roland_DJ-505-scripts.js index c1ed44d10e9..f08f568d32b 100644 --- a/res/controllers/Roland_DJ-505-scripts.js +++ b/res/controllers/Roland_DJ-505-scripts.js @@ -629,8 +629,8 @@ DJ505.Deck = function(deckNumbers, offset) { // If already explicit leader, reset explicit state // (setting it to 0 may still make it implicit leader and // immediately resetting it to 1). - var value = (engine.getValue(this.group, "sync_master") === 2) ? 0 : 2; - engine.setValue(this.group, "sync_master", value); + var value = (engine.getValue(this.group, "sync_leader") === 2) ? 0 : 2; + engine.setValue(this.group, "sync_leader", value); } else { engine.setValue(this.group, "sync_enabled", 1); } diff --git a/res/controllers/Traktor-Kontrol-S4-MK2-hid-scripts.js b/res/controllers/Traktor-Kontrol-S4-MK2-hid-scripts.js index 1a92241b694..cf3109867d5 100644 --- a/res/controllers/Traktor-Kontrol-S4-MK2-hid-scripts.js +++ b/res/controllers/Traktor-Kontrol-S4-MK2-hid-scripts.js @@ -380,7 +380,7 @@ TraktorS4MK2.registerOutputPackets = function() { Output1.addOutput("[Master]", "!usblight", 0x2A, "B"); Output1.addOutput("[Master]", "!quantize", 0x31, "B"); - Output1.addOutput("[InternalClock]", "sync_master", 0x30, "B"); + Output1.addOutput("[InternalClock]", "sync_leader", 0x30, "B"); Output1.addOutput("[Recording]", "status", 0x34, "B"); this.controller.registerOutputPacket(Output1); @@ -550,7 +550,7 @@ TraktorS4MK2.registerOutputPackets = function() { TraktorS4MK2.linkChannelOutput("[EffectRack1_EffectUnit2_Effect3]", "enabled", TraktorS4MK2.outputChannelCallback); TraktorS4MK2.linkChannelOutput("[PreviewDeck1]", "play_indicator", TraktorS4MK2.outputChannelCallback); - TraktorS4MK2.linkChannelOutput("[InternalClock]", "sync_master", TraktorS4MK2.outputChannelCallback); + TraktorS4MK2.linkChannelOutput("[InternalClock]", "sync_leader", TraktorS4MK2.outputChannelCallback); if (TraktorS4MK2.RemixSlotButtonAction === "SAMPLES") { TraktorS4MK2.linkChannelOutput("[Sampler1]", "play_indicator", TraktorS4MK2.outputChannelCallback); @@ -723,7 +723,7 @@ TraktorS4MK2.init = function(id) { TraktorS4MK2.controller.setOutput("[Master]", "!usblight", 0x7F, true); - TraktorS4MK2.outputChannelCallback(engine.getValue("[InternalClock]", "sync_master"), "[InternalClock]", "sync_master"); + TraktorS4MK2.outputChannelCallback(engine.getValue("[InternalClock]", "sync_leader"), "[InternalClock]", "sync_leader"); TraktorS4MK2.outputChannelCallback(engine.getValue("[Recording]", "status"), "[Recording]", "status"); TraktorS4MK2.controller.setOutput("deck1", "!on_air", engine.getValue("[Recording]", "status")*0x7F); TraktorS4MK2.controller.setOutput("deck2", "!on_air", engine.getValue("[Recording]", "status")*0x7F); diff --git a/res/skins/LateNight/decks/rate_controls.xml b/res/skins/LateNight/decks/rate_controls.xml index 1f81ad23f12..4a67fc600b8 100644 --- a/res/skins/LateNight/decks/rate_controls.xml +++ b/res/skins/LateNight/decks/rate_controls.xml @@ -80,10 +80,10 @@ 48f,22f sync ,sync_enabled - ,sync_master + ,sync_leader - sync_master + sync_leader SyncLeader 48f,22f 3 @@ -103,7 +103,7 @@ skin://buttons/btn__sync_active.svg - ,sync_master + ,sync_leader LeftButton diff --git a/src/controllers/controlpickermenu.cpp b/src/controllers/controlpickermenu.cpp index 1d99b08a0c1..8bc5d6fb6e9 100644 --- a/src/controllers/controlpickermenu.cpp +++ b/src/controllers/controlpickermenu.cpp @@ -224,24 +224,44 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent) tr("One-time beat sync (phase only)"), syncMenu); syncMenu->addSeparator(); - addControl("[InternalClock]", "sync_master", tr("Internal Sync Master"), - tr("Toggle Internal Sync Master"), syncMenu); - addControl("[InternalClock]", "bpm", tr("Internal Master BPM"), - tr("Internal Master BPM"), syncMenu); - addControl("[InternalClock]", "bpm_up", tr("Internal Master BPM +1"), - tr("Increase internal master BPM by 1"), syncMenu); - - addControl("[InternalClock]", "bpm_down", tr("Internal Master BPM -1"), - tr("Decrease internal master BPM by 1"), syncMenu); - - addControl("[InternalClock]", "bpm_up_small", tr("Internal Master BPM +0.1"), - tr("Increase internal master BPM by 0.1"), syncMenu); - addControl("[InternalClock]", "bpm_down_small", tr("Internal Master BPM -0.1"), - tr("Decrease internal master BPM by 0.1"), syncMenu); + addControl("[InternalClock]", + "sync_leader", + tr("Internal Sync Leader"), + tr("Toggle Internal Sync Leader"), + syncMenu); + addControl("[InternalClock]", + "bpm", + tr("Internal Leader BPM"), + tr("Internal Leader BPM"), + syncMenu); + addControl("[InternalClock]", + "bpm_up", + tr("Internal Leader BPM +1"), + tr("Increase internal Leader BPM by 1"), + syncMenu); + + addControl("[InternalClock]", + "bpm_down", + tr("Internal Leader BPM -1"), + tr("Decrease internal Leader BPM by 1"), + syncMenu); + + addControl("[InternalClock]", + "bpm_up_small", + tr("Internal Leader BPM +0.1"), + tr("Increase internal Leader BPM by 0.1"), + syncMenu); + addControl("[InternalClock]", + "bpm_down_small", + tr("Internal Leader BPM -0.1"), + tr("Decrease internal Leader BPM by 0.1"), + syncMenu); syncMenu->addSeparator(); - addDeckAndSamplerControl("sync_master", tr("Sync Master"), tr("Toggle sync master"), syncMenu); - addDeckAndSamplerControl("sync_mode", tr("Sync Mode"), - tr("Sync mode 3-state toggle (OFF, FOLLOWER, MASTER)"), syncMenu); + addDeckAndSamplerControl("sync_leader", + tr("Sync Leader"), + tr("Sync mode 3-state toggle / indicator (Off, Soft Leader, " + "Explicit Leader)"), + syncMenu); // Speed QMenu* speedMenu = addSubmenu(tr("Speed")); diff --git a/src/engine/controls/bpmcontrol.cpp b/src/engine/controls/bpmcontrol.cpp index 2a3a76a045f..05aafdb4049 100644 --- a/src/engine/controls/bpmcontrol.cpp +++ b/src/engine/controls/bpmcontrol.cpp @@ -302,7 +302,7 @@ void BpmControl::slotControlBeatSync(double value) { } bool BpmControl::syncTempo() { - if (getSyncMode() == SYNC_MASTER_EXPLICIT) { + if (getSyncMode() == SyncMode::LeaderExplicit) { return false; } EngineBuffer* pOtherEngineBuffer = pickSyncTarget(); @@ -419,7 +419,7 @@ double BpmControl::calcSyncedRate(double userTweak) { rate = m_dSyncInstantaneousBpm / m_pLocalBpm->get(); } - // If we are not quantized, or there are no beats, or we're master, + // If we are not quantized, or there are no beats, or we're leader, // or we're in reverse, just return the rate as-is. if (!m_pQuantize->toBool() || !m_pBeats || m_pReverseButton->toBool()) { m_resetSyncAdjustment = true; @@ -458,10 +458,10 @@ double BpmControl::calcSyncAdjustment(bool userTweakingSync) { m_dLastSyncAdjustment = 1.0; } - // Either shortest distance is directly to the master or backwards. + // Either shortest distance is directly to the leader or backwards. // TODO(rryan): This is kind of backwards because we are measuring distance - // from master to my percentage. All of the control code below is based on + // from leader to my percentage. All of the control code below is based on // this point of reference so I left it this way but I think we should think // about things in terms of "my percentage-offset setpoint" that the control // loop should aim to maintain. @@ -478,7 +478,7 @@ double BpmControl::calcSyncAdjustment(bool userTweakingSync) { if (kLogger.traceEnabled()) { kLogger.trace() << m_group << "****************"; - kLogger.trace() << "master beat distance:" << syncTargetBeatDistance; + kLogger.trace() << "target beat distance:" << syncTargetBeatDistance; kLogger.trace() << "my beat distance:" << thisBeatDistance; kLogger.trace() << "user offset distance:" << curUserOffset; kLogger.trace() << "error :" << error; @@ -1063,7 +1063,7 @@ void BpmControl::slotBeatsTranslateMatchAlignment(double v) { const mixxx::BeatsPointer pBeats = pTrack->getBeats(); if (pBeats) { // Must reset the user offset *before* calling getPhaseOffset(), - // otherwise it will always return 0 if master sync is active. + // otherwise it will always return 0 if sync lock is active. m_dUserOffset.setValue(0.0); double sampleOffset = getPhaseOffset(getSampleOfTrack().current); diff --git a/src/engine/controls/bpmcontrol.h b/src/engine/controls/bpmcontrol.h index d178683e0bd..248a6ddc07a 100644 --- a/src/engine/controls/bpmcontrol.h +++ b/src/engine/controls/bpmcontrol.h @@ -30,7 +30,7 @@ class BpmControl : public EngineControl { return m_pLocalBpm ? mixxx::Bpm(m_pLocalBpm->get()) : mixxx::Bpm(); } - // When in master sync mode, ratecontrol calls calcSyncedRate to figure out + // When in sync lock mode, ratecontrol calls calcSyncedRate to figure out // how fast the track should play back. The returned rate is usually just // the correct pitch to match bpms. The usertweak argument represents // how much the user is nudging the pitch to get two tracks into sync, and @@ -176,5 +176,5 @@ class BpmControl : public EngineControl { mixxx::BeatsPointer m_pBeats; FRIEND_TEST(EngineSyncTest, UserTweakPreservedInSeek); - FRIEND_TEST(EngineSyncTest, FollowerUserTweakPreservedInMasterChange); + FRIEND_TEST(EngineSyncTest, FollowerUserTweakPreservedInLeaderChange); }; diff --git a/src/engine/controls/ratecontrol.cpp b/src/engine/controls/ratecontrol.cpp index 2e27cf2d057..b84f7759a95 100644 --- a/src/engine/controls/ratecontrol.cpp +++ b/src/engine/controls/ratecontrol.cpp @@ -57,7 +57,7 @@ RateControl::RateControl(const QString& group, this, &RateControl::slotRateRangeChanged, Qt::DirectConnection); - // Allow rate slider to go out of bounds so that master sync rate + // Allow rate slider to go out of bounds so that sync lock rate // adjustments are not capped. m_pRateSlider = new ControlPotmeter( ConfigKey(group, "rate"), -1.0, 1.0, true); @@ -461,11 +461,11 @@ double RateControl::calculateSpeed(double baserate, double speed, bool paused, rate = m_pScratchController->getRate(); *pReportScratching = true; } else { - // If master sync is on, respond to it -- but vinyl and scratch mode always override. + // If sync lock is on, respond to it -- but vinyl and scratch mode always override. if (toSynchronized(getSyncMode()) && !paused && !bVinylControlEnabled && !useScratch2Value) { if (m_pBpmControl == nullptr) { - qDebug() << "ERROR: calculateRate m_pBpmControl is null during master sync"; + qDebug() << "ERROR: calculateRate m_pBpmControl is null during sync lock"; return 1.0; } diff --git a/src/engine/controls/ratecontrol.h b/src/engine/controls/ratecontrol.h index 54accae3e03..efd2e7fce1e 100644 --- a/src/engine/controls/ratecontrol.h +++ b/src/engine/controls/ratecontrol.h @@ -143,7 +143,7 @@ public slots: ControlObject* m_pSampleRate; - // For Master Sync + // For Sync Lock BpmControl* m_pBpmControl; ControlProxy* m_pSyncMode; diff --git a/src/engine/enginebuffer.cpp b/src/engine/enginebuffer.cpp index 94629768aff..408f0094153 100644 --- a/src/engine/enginebuffer.cpp +++ b/src/engine/enginebuffer.cpp @@ -88,7 +88,7 @@ EngineBuffer::EngineBuffer(const QString& group, m_bScalerOverride(false), m_iSeekPhaseQueued(0), m_iEnableSyncQueued(SYNC_REQUEST_NONE), - m_iSyncModeQueued(SYNC_INVALID), + m_iSyncModeQueued(static_cast(SyncMode::Invalid)), m_iTrackLoading(0), m_bPlayAfterLoading(false), m_pCrossfadeBuffer(SampleUtil::alloc(MAX_BUFFER_LEN)), @@ -404,9 +404,9 @@ void EngineBuffer::requestEnableSync(bool enabled) { // If we're not playing, the queued event won't get processed so do it now. if (m_playButton->get() == 0.0) { if (enabled) { - m_pEngineSync->requestSyncMode(m_pSyncControl, SYNC_FOLLOWER); + m_pEngineSync->requestSyncMode(m_pSyncControl, SyncMode::Follower); } else { - m_pEngineSync->requestSyncMode(m_pSyncControl, SYNC_NONE); + m_pEngineSync->requestSyncMode(m_pSyncControl, SyncMode::None); } return; } @@ -437,7 +437,7 @@ void EngineBuffer::requestSyncMode(SyncMode mode) { if (m_playButton->get() == 0.0) { m_pEngineSync->requestSyncMode(m_pSyncControl, mode); } else { - m_iSyncModeQueued = mode; + m_iSyncModeQueued = static_cast(mode); } } @@ -1168,7 +1168,7 @@ void EngineBuffer::process(CSAMPLE* pOutput, const int iBufferSize) { } #endif - if (isMaster(m_pSyncControl->getSyncMode())) { + if (isLeader(m_pSyncControl->getSyncMode())) { // Report our speed to SyncControl immediately instead of waiting // for postProcess so we can broadcast this update to followers. m_pSyncControl->reportPlayerSpeed(m_speed_old, m_scratching_old); @@ -1206,22 +1206,23 @@ void EngineBuffer::processSyncRequests() { static_cast( m_iEnableSyncQueued.fetchAndStoreRelease(SYNC_REQUEST_NONE)); SyncMode mode_request = - static_cast(m_iSyncModeQueued.fetchAndStoreRelease(SYNC_INVALID)); + static_cast(m_iSyncModeQueued.fetchAndStoreRelease( + static_cast(SyncMode::Invalid))); switch (enable_request) { case SYNC_REQUEST_ENABLE: - m_pEngineSync->requestSyncMode(m_pSyncControl, SYNC_FOLLOWER); + m_pEngineSync->requestSyncMode(m_pSyncControl, SyncMode::Follower); break; case SYNC_REQUEST_DISABLE: - m_pEngineSync->requestSyncMode(m_pSyncControl, SYNC_NONE); + m_pEngineSync->requestSyncMode(m_pSyncControl, SyncMode::None); break; case SYNC_REQUEST_ENABLEDISABLE: - m_pEngineSync->requestSyncMode(m_pSyncControl, SYNC_FOLLOWER); - m_pEngineSync->requestSyncMode(m_pSyncControl, SYNC_NONE); + m_pEngineSync->requestSyncMode(m_pSyncControl, SyncMode::Follower); + m_pEngineSync->requestSyncMode(m_pSyncControl, SyncMode::None); break; case SYNC_REQUEST_NONE: break; } - if (mode_request != SYNC_INVALID) { + if (mode_request != SyncMode::Invalid) { m_pEngineSync->requestSyncMode(m_pSyncControl, static_cast(mode_request)); } @@ -1321,10 +1322,10 @@ void EngineBuffer::postProcess(const int iBufferSize) { m_pSyncControl->setLocalBpm(localBpmValue); m_pSyncControl->updateAudible(); SyncMode mode = m_pSyncControl->getSyncMode(); - if (isMaster(mode)) { + if (isLeader(mode)) { m_pEngineSync->notifyBeatDistanceChanged(m_pSyncControl, beatDistance); } else if (isFollower(mode)) { - // Report our speed to SyncControl. If we are master, we already did this. + // Report our speed to SyncControl. If we are leader, we already did this. m_pSyncControl->reportPlayerSpeed(m_speed_old, m_scratching_old); m_pSyncControl->updateTargetBeatDistance(); } diff --git a/src/engine/enginebuffer.h b/src/engine/enginebuffer.h index 0d9d8868f65..75f66a0b369 100644 --- a/src/engine/enginebuffer.h +++ b/src/engine/enginebuffer.h @@ -260,7 +260,7 @@ class EngineBuffer : public EngineObject { FRIEND_TEST(EngineSyncTest, HalfDoubleThenPlay); FRIEND_TEST(EngineSyncTest, UserTweakBeatDistance); FRIEND_TEST(EngineSyncTest, UserTweakPreservedInSeek); - FRIEND_TEST(EngineSyncTest, FollowerUserTweakPreservedInMasterChange); + FRIEND_TEST(EngineSyncTest, FollowerUserTweakPreservedInLeaderChange); FRIEND_TEST(EngineSyncTest, BeatMapQuantizePlay); FRIEND_TEST(EngineBufferTest, ScalerNoTransport); EngineSync* m_pEngineSync; diff --git a/src/engine/enginemaster.cpp b/src/engine/enginemaster.cpp index fc6260bddd7..34cb9d22e86 100644 --- a/src/engine/enginemaster.cpp +++ b/src/engine/enginemaster.cpp @@ -270,7 +270,7 @@ const CSAMPLE* EngineMaster::getSidechainBuffer() const { } void EngineMaster::processChannels(int iBufferSize) { - // Update internal master sync rate. + // Update internal sync lock rate. m_pMasterSync->onCallbackStart(m_iSampleRate, m_iBufferSize); m_activeBusChannels[EngineChannel::LEFT].clear(); @@ -281,7 +281,7 @@ void EngineMaster::processChannels(int iBufferSize) { m_activeChannels.clear(); //ScopedTimer timer("EngineMaster::processChannels"); - EngineChannel* pMasterChannel = m_pMasterSync->getMaster(); + EngineChannel* pMasterChannel = m_pMasterSync->getLeader(); // Reserve the first place for the master channel which // should be processed first m_activeChannels.append(NULL); @@ -367,7 +367,7 @@ void EngineMaster::processChannels(int iBufferSize) { } } - // Do internal master sync post-processing before the other + // Do internal sync lock post-processing before the other // channels. // Note, because we call this on the internal clock first, // it will have an up-to-date beatDistance, whereas the other diff --git a/src/engine/enginemaster.h b/src/engine/enginemaster.h index eed8ee0fa45..f85af0b11c1 100644 --- a/src/engine/enginemaster.h +++ b/src/engine/enginemaster.h @@ -87,7 +87,7 @@ class EngineMaster : public QObject, public AudioSource { } } - // Provide access to the master sync so enginebuffers can know what their rate controller is. + // Provide access to the sync lock so enginebuffers can know what their rate controller is. EngineSync* getEngineSync() const{ return m_pMasterSync; } @@ -254,7 +254,7 @@ class EngineMaster : public QObject, public AudioSource { ControlObject* m_pBoothEnabled; private: - // Processes active channels. The master sync channel (if any) is processed + // Processes active channels. The sync lock channel (if any) is processed // first and all others are processed after. Populates m_activeChannels, // m_activeBusChannels, m_activeHeadphoneChannels, and // m_activeTalkoverChannels with each channel that is active for the diff --git a/src/engine/sync/clock.h b/src/engine/sync/clock.h index 9814bf1d441..a0e8731fe51 100644 --- a/src/engine/sync/clock.h +++ b/src/engine/sync/clock.h @@ -5,8 +5,8 @@ class Clock { virtual ~Clock() = default; virtual double getBeatDistance() const = 0; - virtual void updateMasterBeatDistance(double beatDistance) = 0; + virtual void updateLeaderBeatDistance(double beatDistance) = 0; virtual double getBpm() const = 0; - virtual void updateMasterBpm(double bpm) = 0; + virtual void updateLeaderBpm(double bpm) = 0; }; diff --git a/src/engine/sync/enginesync.cpp b/src/engine/sync/enginesync.cpp index 3b7c83eb2cc..7b8faf9b9c6 100644 --- a/src/engine/sync/enginesync.cpp +++ b/src/engine/sync/enginesync.cpp @@ -17,9 +17,9 @@ const QString kInternalClockGroup = QStringLiteral("[InternalClock]"); EngineSync::EngineSync(UserSettingsPointer pConfig) : m_pConfig(pConfig), m_pInternalClock(new InternalClock(kInternalClockGroup, this)), - m_pMasterSyncable(nullptr) { + m_pLeaderSyncable(nullptr) { qRegisterMetaType("SyncMode"); - m_pInternalClock->updateMasterBpm(124.0); + m_pInternalClock->updateLeaderBpm(124.0); } EngineSync::~EngineSync() { @@ -41,32 +41,32 @@ void EngineSync::requestSyncMode(Syncable* pSyncable, SyncMode mode) { // the pSyncable's new mode (it may not be the one they requested), // and activating the appropriate modes in it as well as possibly other // decks that need to change as a result. - Syncable* oldMaster = m_pMasterSyncable; + Syncable* oldLeader = m_pLeaderSyncable; switch (mode) { - case SYNC_MASTER_EXPLICIT: - case SYNC_MASTER_SOFT: { + case SyncMode::LeaderExplicit: + case SyncMode::LeaderSoft: { if (pSyncable->getBaseBpm() > 0) { - activateMaster(pSyncable, mode); + activateLeader(pSyncable, mode); } else { - // Because we don't have a valid bpm, we can't be the master + // Because we don't have a valid bpm, we can't be the leader // (or else everyone would try to be syncing to zero bpm). // Override and make us a follower instead. activateFollower(pSyncable); } break; } - case SYNC_FOLLOWER: { + case SyncMode::Follower: { // A request for follower mode may be converted into an enabling of soft - // master mode. + // leader mode. activateFollower(pSyncable); - Syncable* newMaster = pickMaster(pSyncable); - if (newMaster && newMaster != m_pMasterSyncable) { - // if the master has changed, activate it (this updates m_pMasterSyncable) - activateMaster(newMaster, SYNC_MASTER_SOFT); + Syncable* newLeader = pickLeader(pSyncable); + if (newLeader && newLeader != m_pLeaderSyncable) { + // if the leader has changed, activate it (this updates m_pLeaderSyncable) + activateLeader(newLeader, SyncMode::LeaderSoft); } break; } - case SYNC_NONE: { + case SyncMode::None: { if (pSyncable != m_pInternalClock) { deactivateSync(pSyncable); } @@ -82,26 +82,27 @@ void EngineSync::requestSyncMode(Syncable* pSyncable, SyncMode mode) { pOnlyPlayer->notifyUniquePlaying(); } - // Second, figure out what Syncable should be used to initialize the master - // parameters, if any. Usually this is the new master. (Note, that pointer might be null!) - Syncable* pParamsSyncable = m_pMasterSyncable; - // But If we are newly soft master, we need to match to some other deck. - if (pSyncable == m_pMasterSyncable && pSyncable != oldMaster && mode != SYNC_MASTER_EXPLICIT) { + // Second, figure out what Syncable should be used to initialize the leader + // parameters, if any. Usually this is the new leader. (Note, that pointer might be null!) + Syncable* pParamsSyncable = m_pLeaderSyncable; + // But If we are newly soft leader, we need to match to some other deck. + if (pSyncable == m_pLeaderSyncable && pSyncable != oldLeader && + mode != SyncMode::LeaderExplicit) { pParamsSyncable = findBpmMatchTarget(pSyncable); if (!pParamsSyncable) { // We weren't able to find anything to match to, so set ourselves as the - // target. That way we'll use our own params when we updateMasterBpm below. + // target. That way we'll use our own params when we updateLeaderParams below. pParamsSyncable = pSyncable; } } - // Now that all of the decks have their assignments, reinit master params if needed. + // Now that all of the decks have their assignments, reinit leader params if needed. if (pParamsSyncable) { if (kLogger.traceEnabled()) { kLogger.trace() - << "EngineSync::requestSyncMode setting master params from " + << "EngineSync::requestSyncMode setting leader params from " << pParamsSyncable->getGroup(); } - reinitMasterParams(pParamsSyncable); + reinitLeaderParams(pParamsSyncable); pSyncable->updateInstantaneousBpm(pParamsSyncable->getBpm()); if (pParamsSyncable != pSyncable) { pSyncable->requestSync(); @@ -120,47 +121,48 @@ void EngineSync::activateFollower(Syncable* pSyncable) { << pSyncable->getGroup(); } - if (m_pMasterSyncable == pSyncable) { - m_pMasterSyncable = nullptr; + if (m_pLeaderSyncable == pSyncable) { + m_pLeaderSyncable = nullptr; } - pSyncable->setSyncMode(SYNC_FOLLOWER); + pSyncable->setSyncMode(SyncMode::Follower); } -void EngineSync::activateMaster(Syncable* pSyncable, SyncMode masterType) { +void EngineSync::activateLeader(Syncable* pSyncable, SyncMode leaderType) { VERIFY_OR_DEBUG_ASSERT(pSyncable) { - qWarning() << "WARNING: Logic Error: Called activateMaster on a nullptr Syncable."; + qWarning() << "WARNING: Logic Error: Called activateLeader on a nullptr Syncable."; return; } - VERIFY_OR_DEBUG_ASSERT(masterType == SYNC_MASTER_SOFT || masterType == SYNC_MASTER_EXPLICIT) { - qWarning() << "WARNING: Logic Error: Called activateMaster with non-master mode"; + VERIFY_OR_DEBUG_ASSERT(leaderType == SyncMode::LeaderSoft || + leaderType == SyncMode::LeaderExplicit) { + qWarning() << "WARNING: Logic Error: Called activateLeader with non-leader mode"; } if (kLogger.traceEnabled()) { - kLogger.trace() << "EngineSync::activateMaster: " + kLogger.trace() << "EngineSync::activateLeader: " << pSyncable->getGroup() << "type: " - << masterType; + << leaderType; } - if (m_pMasterSyncable == pSyncable) { - // Already master, update the master type. - if (m_pMasterSyncable->getSyncMode() != masterType) { - m_pMasterSyncable->setSyncMode(masterType); + if (m_pLeaderSyncable == pSyncable) { + // Already leader, update the leader type. + if (m_pLeaderSyncable->getSyncMode() != leaderType) { + m_pLeaderSyncable->setSyncMode(leaderType); } // nothing else to do return; } - // If a different channel is already master, disable it. - Syncable* pOldChannelMaster = m_pMasterSyncable; - m_pMasterSyncable = nullptr; - if (pOldChannelMaster) { - pOldChannelMaster->setSyncMode(SYNC_FOLLOWER); + // If a different channel is already leader, disable it. + Syncable* pOldChannelLeader = m_pLeaderSyncable; + m_pLeaderSyncable = nullptr; + if (pOldChannelLeader) { + pOldChannelLeader->setSyncMode(SyncMode::Follower); } - m_pMasterSyncable = pSyncable; - pSyncable->setSyncMode(masterType); + m_pLeaderSyncable = pSyncable; + pSyncable->setSyncMode(leaderType); - if (m_pMasterSyncable != m_pInternalClock) { + if (m_pLeaderSyncable != m_pInternalClock) { // the internal clock gets activated and its values are overwritten with this // new deck. activateFollower(m_pInternalClock); @@ -174,38 +176,38 @@ void EngineSync::deactivateSync(Syncable* pSyncable) { if (kLogger.traceEnabled()) { kLogger.trace() << "EngineSync::deactivateSync" << pSyncable->getGroup(); } - bool wasMaster = isSyncMaster(pSyncable); - if (wasMaster) { - m_pMasterSyncable = nullptr; + bool wasLeader = isSyncLeader(pSyncable); + if (wasLeader) { + m_pLeaderSyncable = nullptr; } // Notifications happen after-the-fact. - pSyncable->setSyncMode(SYNC_NONE); + pSyncable->setSyncMode(SyncMode::None); bool bSyncDeckExists = syncDeckExists(); if (pSyncable != m_pInternalClock && !bSyncDeckExists) { // Deactivate the internal clock if there are no more sync decks left. - m_pMasterSyncable = nullptr; - m_pInternalClock->setSyncMode(SYNC_NONE); + m_pLeaderSyncable = nullptr; + m_pInternalClock->setSyncMode(SyncMode::None); return; } - if (wasMaster) { - Syncable* newMaster = pickMaster(nullptr); - if (newMaster != nullptr) { - activateMaster(newMaster, SYNC_MASTER_SOFT); + if (wasLeader) { + Syncable* newLeader = pickLeader(nullptr); + if (newLeader != nullptr) { + activateLeader(newLeader, SyncMode::LeaderSoft); } } } -Syncable* EngineSync::pickMaster(Syncable* enabling_syncable) { +Syncable* EngineSync::pickLeader(Syncable* enabling_syncable) { if (kLogger.traceEnabled()) { - kLogger.trace() << "EngineSync::pickMaster"; + kLogger.trace() << "EngineSync::pickLeader"; } - if (m_pMasterSyncable && - m_pMasterSyncable->getSyncMode() == SYNC_MASTER_EXPLICIT && - m_pMasterSyncable->getBaseBpm() != 0.0) { - return m_pMasterSyncable; + if (m_pLeaderSyncable && + m_pLeaderSyncable->getSyncMode() == SyncMode::LeaderExplicit && + m_pLeaderSyncable->getBaseBpm() != 0.0) { + return m_pLeaderSyncable; } // First preference: some other sync deck that is not playing. @@ -252,10 +254,10 @@ Syncable* EngineSync::pickMaster(Syncable* enabling_syncable) { const SyncLockAlgorithm picker = static_cast( m_pConfig->getValue(ConfigKey("[BPM]", "sync_lock_algorithm"), - PREFER_IMPLICIT_MASTER)); + PREFER_IMPLICIT_LEADER)); switch (picker) { - case PREFER_IMPLICIT_MASTER: - // Always pick a deck for a new master. + case PREFER_IMPLICIT_LEADER: + // Always pick a deck for a new leader. if (playing_deck_count == 1) { return first_playing_deck; } else if (playing_deck_count > 1) { @@ -300,7 +302,7 @@ Syncable* EngineSync::findBpmMatchTarget(Syncable* requester) { if (pOtherSyncable == requester) { continue; } - // Skip non-master decks, like preview decks. + // Skip non-leader decks, like preview decks. if (!pOtherSyncable->getChannel()->isMasterEnabled()) { continue; } @@ -357,19 +359,19 @@ void EngineSync::notifyPlayingAudible(Syncable* pSyncable, bool playingAudible) return; } - // similar to enablesync -- we pick a new master and maybe reinit. - Syncable* newMaster = pickMaster(pSyncable); + // similar to enablesync -- we pick a new leader and maybe reinit. + Syncable* newLeader = pickLeader(pSyncable); - if (newMaster != nullptr && newMaster != m_pMasterSyncable) { - activateMaster(newMaster, SYNC_MASTER_SOFT); - reinitMasterParams(newMaster); + if (newLeader != nullptr && newLeader != m_pLeaderSyncable) { + activateLeader(newLeader, SyncMode::LeaderSoft); + reinitLeaderParams(newLeader); } else { Syncable* pOnlyPlayer = getUniquePlayingSyncedDeck(); if (pOnlyPlayer) { - // Even if we didn't change master, if there is only one player (us), then we should + // Even if we didn't change leader, if there is only one player (us), then we should // update the beat distance. pOnlyPlayer->notifyUniquePlaying(); - updateMasterBeatDistance(pOnlyPlayer, pOnlyPlayer->getBeatDistance()); + updateLeaderBeatDistance(pOnlyPlayer, pOnlyPlayer->getBeatDistance()); } } @@ -387,8 +389,8 @@ void EngineSync::notifyBaseBpmChanged(Syncable* pSyncable, double bpm) { kLogger.trace() << "EngineSync::notifyBaseBpmChanged" << pSyncable->getGroup() << bpm; } - if (isSyncMaster(pSyncable)) { - updateMasterBpm(pSyncable, bpm); + if (isSyncLeader(pSyncable)) { + updateLeaderBpm(pSyncable, bpm); } } @@ -397,7 +399,7 @@ void EngineSync::notifyRateChanged(Syncable* pSyncable, double bpm) { kLogger.trace() << "EngineSync::notifyRateChanged" << pSyncable->getGroup() << bpm; } - updateMasterBpm(pSyncable, bpm); + updateLeaderBpm(pSyncable, bpm); } void EngineSync::requestBpmUpdate(Syncable* pSyncable, double bpm) { @@ -408,20 +410,20 @@ void EngineSync::requestBpmUpdate(Syncable* pSyncable, double bpm) { double mbaseBpm = 0.0; double mbpm = 0.0; double beatDistance = 0.0; - if (m_pMasterSyncable) { - mbaseBpm = m_pMasterSyncable->getBaseBpm(); - mbpm = m_pMasterSyncable->getBpm(); - beatDistance = m_pMasterSyncable->getBeatDistance(); + if (m_pLeaderSyncable) { + mbaseBpm = m_pLeaderSyncable->getBaseBpm(); + mbpm = m_pLeaderSyncable->getBpm(); + beatDistance = m_pLeaderSyncable->getBeatDistance(); } if (mbaseBpm != 0.0) { - // update from current master - pSyncable->updateMasterBeatDistance(beatDistance); - pSyncable->updateMasterBpm(mbpm); + // update from current leader + pSyncable->updateLeaderBeatDistance(beatDistance); + pSyncable->updateLeaderBpm(mbpm); } else { - // There is no master, adopt this bpm as master value - pSyncable->updateMasterBeatDistance(0.0); - pSyncable->updateMasterBpm(bpm); + // There is no leader, adopt this bpm as leader value + pSyncable->updateLeaderBeatDistance(0.0); + pSyncable->updateLeaderBpm(bpm); } } @@ -433,9 +435,9 @@ void EngineSync::notifyInstantaneousBpmChanged(Syncable* pSyncable, double bpm) return; } - // Do not update the master rate slider because instantaneous changes are + // Do not update the leader rate slider because instantaneous changes are // not user visible. - updateMasterInstantaneousBpm(pSyncable, bpm); + updateLeaderInstantaneousBpm(pSyncable, bpm); } void EngineSync::notifyBeatDistanceChanged(Syncable* pSyncable, double beatDistance) { @@ -447,15 +449,15 @@ void EngineSync::notifyBeatDistanceChanged(Syncable* pSyncable, double beatDista return; } - updateMasterBeatDistance(pSyncable, beatDistance); + updateLeaderBeatDistance(pSyncable, beatDistance); } Syncable* EngineSync::pickNonSyncSyncTarget(EngineChannel* pDontPick) const { - // First choice: the sync master, if it's a deck - if (m_pMasterSyncable && - m_pMasterSyncable->getChannel() && - m_pMasterSyncable->getChannel() != pDontPick) { - return m_pMasterSyncable; + // First choice: the sync leader, if it's a deck + if (m_pLeaderSyncable && + m_pLeaderSyncable->getChannel() && + m_pLeaderSyncable->getChannel() != pDontPick) { + return m_pLeaderSyncable; } Syncable* pFirstPlayingDeck = nullptr; @@ -467,13 +469,13 @@ Syncable* EngineSync::pickNonSyncSyncTarget(EngineChannel* pDontPick) const { continue; } - // Only consider channels that have a track loaded, are in the master + // Only consider channels that have a track loaded, are in the leader // mix, and are primary decks. if (pChannel->isActive() && pChannel->isMasterEnabled() && pChannel->isPrimaryDeck()) { EngineBuffer* pBuffer = pChannel->getEngineBuffer(); if (pBuffer && pBuffer->getBpm().isValid()) { if (pBuffer->getSpeed() != 0.0) { - if (pSyncable->getSyncMode() != SYNC_NONE) { + if (pSyncable->getSyncMode() != SyncMode::None) { // Second choice: first playing sync deck return pSyncable; } @@ -531,8 +533,8 @@ void EngineSync::onCallbackEnd(int sampleRate, int bufferSize) { m_pInternalClock->onCallbackEnd(sampleRate, bufferSize); } -EngineChannel* EngineSync::getMaster() const { - return m_pMasterSyncable ? m_pMasterSyncable->getChannel() : nullptr; +EngineChannel* EngineSync::getLeader() const { + return m_pLeaderSyncable ? m_pLeaderSyncable->getChannel() : nullptr; } Syncable* EngineSync::getSyncableForGroup(const QString& group) { @@ -553,42 +555,42 @@ bool EngineSync::syncDeckExists() const { return false; } -double EngineSync::masterBpm() const { - if (m_pMasterSyncable) { - return m_pMasterSyncable->getBpm(); +double EngineSync::leaderBpm() const { + if (m_pLeaderSyncable) { + return m_pLeaderSyncable->getBpm(); } return m_pInternalClock->getBpm(); } -double EngineSync::masterBeatDistance() const { - if (m_pMasterSyncable) { - return m_pMasterSyncable->getBeatDistance(); +double EngineSync::leaderBeatDistance() const { + if (m_pLeaderSyncable) { + return m_pLeaderSyncable->getBeatDistance(); } return m_pInternalClock->getBeatDistance(); } -double EngineSync::masterBaseBpm() const { - if (m_pMasterSyncable) { - return m_pMasterSyncable->getBaseBpm(); +double EngineSync::leaderBaseBpm() const { + if (m_pLeaderSyncable) { + return m_pLeaderSyncable->getBaseBpm(); } return m_pInternalClock->getBaseBpm(); } -void EngineSync::updateMasterBpm(Syncable* pSource, double bpm) { - //qDebug() << "EngineSync::updateMasterBpm" << pSource << bpm; +void EngineSync::updateLeaderBpm(Syncable* pSource, double bpm) { + //qDebug() << "EngineSync::updateLeaderBpm" << pSource << bpm; if (pSource != m_pInternalClock) { - m_pInternalClock->updateMasterBpm(bpm); + m_pInternalClock->updateLeaderBpm(bpm); } foreach (Syncable* pSyncable, m_syncables) { if (pSyncable == pSource || !pSyncable->isSynchronized()) { continue; } - pSyncable->updateMasterBpm(bpm); + pSyncable->updateLeaderBpm(bpm); } } -void EngineSync::updateMasterInstantaneousBpm(Syncable* pSource, double bpm) { +void EngineSync::updateLeaderInstantaneousBpm(Syncable* pSource, double bpm) { if (pSource != m_pInternalClock) { m_pInternalClock->updateInstantaneousBpm(bpm); } @@ -601,35 +603,35 @@ void EngineSync::updateMasterInstantaneousBpm(Syncable* pSource, double bpm) { } } -void EngineSync::updateMasterBeatDistance(Syncable* pSource, double beatDistance) { +void EngineSync::updateLeaderBeatDistance(Syncable* pSource, double beatDistance) { if (kLogger.traceEnabled()) { - kLogger.trace() << "EngineSync::setMasterBeatDistance" + kLogger.trace() << "EngineSync::updateLeaderBeatDistance" << (pSource ? pSource->getGroup() : "null") << beatDistance; } if (pSource != m_pInternalClock) { - m_pInternalClock->updateMasterBeatDistance(beatDistance); + m_pInternalClock->updateLeaderBeatDistance(beatDistance); } foreach (Syncable* pSyncable, m_syncables) { if (pSyncable == pSource || !pSyncable->isSynchronized()) { continue; } - pSyncable->updateMasterBeatDistance(beatDistance); + pSyncable->updateLeaderBeatDistance(beatDistance); } } -void EngineSync::reinitMasterParams(Syncable* pSource) { - // Important note! Because of the way sync works, the new master is usually not the same - // as the Syncable setting the master parameters (here, pSource). Notify the proper Syncable +void EngineSync::reinitLeaderParams(Syncable* pSource) { + // Important note! Because of the way sync works, the new leader is usually not the same + // as the Syncable setting the leader parameters (here, pSource). Notify the proper Syncable // so it can prepare itself. (This is a hack to undo half/double math so that we initialize // based on un-multiplied bpm values). - pSource->notifyMasterParamSource(); + pSource->notifyLeaderParamSource(); double beatDistance = pSource->getBeatDistance(); if (!pSource->isPlaying()) { // If the params source is not playing, but other syncables are, then we are a stopped - // explicit Master and we should not initialize the beat distance. Take it from the + // explicit Leader and we should not initialize the beat distance. Take it from the // internal clock instead, because that will be up to date with the playing deck(s). bool playingSyncables = false; for (Syncable* pSyncable : qAsConst(m_syncables)) { @@ -654,17 +656,17 @@ void EngineSync::reinitMasterParams(Syncable* pSource) { bpm = baseBpm; } if (kLogger.traceEnabled()) { - kLogger.trace() << "BaseSyncableListener::reinitMasterParams, source is" + kLogger.trace() << "BaseSyncableListener::reinitLeaderParams, source is" << pSource->getGroup() << beatDistance << baseBpm << bpm; } if (pSource != m_pInternalClock) { - m_pInternalClock->reinitMasterParams(beatDistance, baseBpm, bpm); + m_pInternalClock->reinitLeaderParams(beatDistance, baseBpm, bpm); } foreach (Syncable* pSyncable, m_syncables) { if (!pSyncable->isSynchronized()) { continue; } - pSyncable->reinitMasterParams(beatDistance, baseBpm, bpm); + pSyncable->reinitLeaderParams(beatDistance, baseBpm, bpm); } } diff --git a/src/engine/sync/enginesync.h b/src/engine/sync/enginesync.h index 0e3118010b2..22018ae7727 100644 --- a/src/engine/sync/enginesync.h +++ b/src/engine/sync/enginesync.h @@ -40,10 +40,10 @@ class EngineSync : public SyncableListener { void notifyPlayingAudible(Syncable* pSyncable, bool playingAudible) override; void notifyScratching(Syncable* pSyncable, bool scratching) override; - /// Used to pick a sync target for cases where master sync mode is not sufficient. + /// Used to pick a sync target for cases where Leader sync mode is not sufficient. /// Guaranteed to pick a Syncable that is a real deck and has an EngineBuffer, /// but can return nullptr if there are no choices. - /// First choice is master sync, if it's a real deck, + /// First choice is Leader sync, if it's a real deck, /// then it will fall back to the first playing syncable deck, /// then it will fall back to the first playing deck, /// then it will fall back to the first non-playing deck. @@ -56,83 +56,83 @@ class EngineSync : public SyncableListener { bool otherSyncedPlaying(const QString& group); void addSyncableDeck(Syncable* pSyncable); - EngineChannel* getMaster() const; + EngineChannel* getLeader() const; void onCallbackStart(int sampleRate, int bufferSize); void onCallbackEnd(int sampleRate, int bufferSize); private: - /// Iterate over decks, and based on sync and play status, pick a new master. + /// Iterate over decks, and based on sync and play status, pick a new Leader. /// if enabling_syncable is not null, we treat it as if it were enabled because we may /// be in the process of enabling it. - Syncable* pickMaster(Syncable* enabling_syncable); + Syncable* pickLeader(Syncable* enabling_syncable); - /// Find a deck to match against, used in the case where there is no sync master. + /// Find a deck to match against, used in the case where there is no sync Leader. /// Looks first for a playing deck, and falls back to the first non-playing deck. /// If the requester is playing, don't match against a non-playing deck because /// that would be strange behavior for the user. /// Returns nullptr if none can be found. Syncable* findBpmMatchTarget(Syncable* requester); - /// Activate a specific syncable as master. - void activateMaster(Syncable* pSyncable, bool explicitMaster); + /// Activate a specific syncable as Leader. + void activateLeader(Syncable* pSyncable, bool explicitLeader); /// Activate a specific channel as Follower. Sets the syncable's bpm and - /// beatDistance to match the master. + /// beatDistance to match the Leader. void activateFollower(Syncable* pSyncable); - // Activate a specific syncable as master, with the appropriate submode. - void activateMaster(Syncable* pSyncable, SyncMode masterType); + // Activate a specific syncable as Leader, with the appropriate submode. + void activateLeader(Syncable* pSyncable, SyncMode leaderType); /// Unsets all sync state on a Syncable. void deactivateSync(Syncable* pSyncable); - /// This utility method returns true if it finds a deck not in SYNC_NONE mode. + /// This utility method returns true if it finds a deck not in SyncMode::None. bool syncDeckExists() const; - /// Return the current BPM of the master Syncable. If no master syncable is + /// Return the current BPM of the Leader Syncable. If no Leader syncable is /// set then returns the BPM of the internal clock. - double masterBpm() const; + double leaderBpm() const; - /// Returns the current beat distance of the master Syncable. If no master + /// Returns the current beat distance of the Leader Syncable. If no Leader /// Syncable is set, then returns the beat distance of the internal clock. - double masterBeatDistance() const; + double leaderBeatDistance() const; - /// Returns the overall average BPM of the master Syncable if it were playing + /// Returns the overall average BPM of the Leader Syncable if it were playing /// at 1.0 rate. This is used to calculate half/double multipliers and whether - /// the master has a bpm at all. - double masterBaseBpm() const; + /// the Leader has a bpm at all. + double leaderBaseBpm() const; /// Set the BPM on every sync-enabled Syncable except pSource. - void updateMasterBpm(Syncable* pSource, double bpm); + void updateLeaderBpm(Syncable* pSource, double bpm); - /// Set the master instantaneous BPM on every sync-enabled Syncable except + /// Set the Leader instantaneous BPM on every sync-enabled Syncable except /// pSource. - void updateMasterInstantaneousBpm(Syncable* pSource, double bpm); + void updateLeaderInstantaneousBpm(Syncable* pSource, double bpm); - /// Set the master beat distance on every sync-enabled Syncable except + /// Set the Leader beat distance on every sync-enabled Syncable except /// pSource. - void updateMasterBeatDistance(Syncable* pSource, double beatDistance); + void updateLeaderBeatDistance(Syncable* pSource, double beatDistance); - /// Initialize the master parameters using the provided syncable as the source. + /// Initialize the leader parameters using the provided syncable as the source. /// This should only be called for "major" updates, like a new track or change in - /// master. Should not be called on every buffer callback. - void reinitMasterParams(Syncable* pSource); + /// leader. Should not be called on every buffer callback. + void reinitLeaderParams(Syncable* pSource); /// Iff there is a single playing syncable in sync mode, return it. - /// This is used to initialize master params. + /// This is used to initialize leader params. Syncable* getUniquePlayingSyncedDeck() const; /// Only for testing. Do not use. Syncable* getSyncableForGroup(const QString& group); /// Only for testing. Do not use. - Syncable* getMasterSyncable() override { - return m_pMasterSyncable; + Syncable* getLeaderSyncable() override { + return m_pLeaderSyncable; } - bool isSyncMaster(Syncable* pSyncable) { - if (isMaster(pSyncable->getSyncMode())) { - DEBUG_ASSERT(m_pMasterSyncable == pSyncable); + bool isSyncLeader(Syncable* pSyncable) { + if (isLeader(pSyncable->getSyncMode())) { + DEBUG_ASSERT(m_pLeaderSyncable == pSyncable); return true; } return false; @@ -143,14 +143,14 @@ class EngineSync : public SyncableListener { // If this code makes it to release we will all be very sad. enum SyncLockAlgorithm { // New behavior, which should work if beatgrids are reliable. - PREFER_IMPLICIT_MASTER, + PREFER_IMPLICIT_LEADER, // Old 2.3 behavior, which works around some issues with bad beatgrid detection, mostly // for auto DJ mode. PREFER_LOCK_BPM }; - FRIEND_TEST(EngineSyncTest, EnableOneDeckInitsMaster); - FRIEND_TEST(EngineSyncTest, EnableOneDeckInitializesMaster); + FRIEND_TEST(EngineSyncTest, EnableOneDeckInitsLeader); + FRIEND_TEST(EngineSyncTest, EnableOneDeckInitializesLeader); FRIEND_TEST(EngineSyncTest, SyncToNonSyncDeck); FRIEND_TEST(EngineSyncTest, SetFileBpmUpdatesLocalBpm); FRIEND_TEST(EngineSyncTest, BpmAdjustFactor); @@ -161,7 +161,7 @@ class EngineSync : public SyncableListener { /// The InternalClock syncable. InternalClock* m_pInternalClock; /// The current Syncable that is the leader. - Syncable* m_pMasterSyncable; + Syncable* m_pLeaderSyncable; /// The list of all Syncables registered via addSyncableDeck. QList m_syncables; }; diff --git a/src/engine/sync/internalclock.cpp b/src/engine/sync/internalclock.cpp index 4beec9733fb..a2d37f1adcd 100644 --- a/src/engine/sync/internalclock.cpp +++ b/src/engine/sync/internalclock.cpp @@ -17,14 +17,14 @@ const mixxx::Logger kLogger("InternalClock"); InternalClock::InternalClock(const QString& group, SyncableListener* pEngineSync) : m_group(group), m_pEngineSync(pEngineSync), - m_mode(SYNC_NONE), + m_mode(SyncMode::None), m_iOldSampleRate(44100), m_dOldBpm(124.0), m_dBaseBpm(124.0), m_dBeatLength(m_iOldSampleRate * 60.0 / m_dOldBpm), m_dClockPosition(0) { // Pick a wide range (1 to 200) and allow out of bounds sets. This lets you - // map a soft-takeover MIDI knob to the master BPM. This also creates bpm_up + // map a soft-takeover MIDI knob to the leader BPM. This also creates bpm_up // and bpm_down controls. // bpm_up / bpm_down steps by 1 // bpm_up_small / bpm_down_small steps by 0.1 @@ -42,12 +42,14 @@ InternalClock::InternalClock(const QString& group, SyncableListener* pEngineSync this, &InternalClock::slotBeatDistanceChanged, Qt::DirectConnection); - m_pSyncMasterEnabled.reset( - new ControlPushButton(ConfigKey(m_group, "sync_master"))); - m_pSyncMasterEnabled->setButtonMode(ControlPushButton::TOGGLE); - m_pSyncMasterEnabled->setStates(3); - m_pSyncMasterEnabled->connectValueChangeRequest( - this, &InternalClock::slotSyncMasterEnabledChangeRequest, Qt::DirectConnection); + m_pSyncLeaderEnabled.reset( + new ControlPushButton(ConfigKey(m_group, "sync_leader"))); + m_pSyncLeaderEnabled->setButtonMode(ControlPushButton::TOGGLE); + m_pSyncLeaderEnabled->setStates(3); + m_pSyncLeaderEnabled->connectValueChangeRequest( + this, &InternalClock::slotSyncLeaderEnabledChangeRequest, Qt::DirectConnection); + ControlDoublePrivate::insertAlias(ConfigKey(m_group, "sync_master"), + ConfigKey(m_group, "sync_leader")); } InternalClock::~InternalClock() { @@ -57,7 +59,7 @@ void InternalClock::setSyncMode(SyncMode mode) { // Syncable has absolutely no say in the matter. This is what EngineSync // requires. Bypass confirmation by using setAndConfirm. m_mode = mode; - m_pSyncMasterEnabled->setAndConfirm(SyncModeToMasterLight(mode)); + m_pSyncLeaderEnabled->setAndConfirm(static_cast(SyncModeToLeaderLight(mode))); } void InternalClock::notifyUniquePlaying() { @@ -68,30 +70,30 @@ void InternalClock::requestSync() { // TODO(owilliams): This should probably be how we reset the internal beat distance. } -void InternalClock::slotSyncMasterEnabledChangeRequest(double state) { +void InternalClock::slotSyncLeaderEnabledChangeRequest(double state) { SyncMode mode = m_mode; //Note: internal clock is always sync enabled if (state > 0.0) { - if (mode == SYNC_MASTER_EXPLICIT) { - // Already master. + if (mode == SyncMode::LeaderExplicit) { + // Already leader. return; } - if (mode == SYNC_MASTER_SOFT) { - // user request: make master explicit - m_mode = SYNC_MASTER_EXPLICIT; + if (mode == SyncMode::LeaderSoft) { + // user request: make leader explicit + m_mode = SyncMode::LeaderExplicit; return; } - if (mode == SYNC_NONE) { + if (mode == SyncMode::None) { m_dBaseBpm = m_dOldBpm; } - m_pEngineSync->requestSyncMode(this, SYNC_MASTER_EXPLICIT); + m_pEngineSync->requestSyncMode(this, SyncMode::LeaderExplicit); } else { - // Turning off master goes back to follower mode. - if (mode == SYNC_FOLLOWER) { - // Already not master. + // Turning off leader goes back to follower mode. + if (mode == SyncMode::Follower) { + // Already not leader. return; } - m_pEngineSync->requestSyncMode(this, SYNC_FOLLOWER); + m_pEngineSync->requestSyncMode(this, SyncMode::Follower); } } @@ -103,9 +105,9 @@ double InternalClock::getBeatDistance() const { return m_dClockPosition / m_dBeatLength; } -void InternalClock::updateMasterBeatDistance(double beatDistance) { +void InternalClock::updateLeaderBeatDistance(double beatDistance) { if (kLogger.traceEnabled()) { - kLogger.trace() << "InternalClock::setMasterBeatDistance" << beatDistance; + kLogger.trace() << "InternalClock::updateLeaderBeatDistance" << beatDistance; } m_dClockPosition = beatDistance * m_dBeatLength; m_pClockBeatDistance->set(beatDistance); @@ -121,7 +123,7 @@ double InternalClock::getBpm() const { return m_pClockBpm->get(); } -void InternalClock::updateMasterBpm(double bpm) { +void InternalClock::updateLeaderBpm(double bpm) { if (kLogger.traceEnabled()) { kLogger.trace() << "InternalClock::setBpm" << bpm; } @@ -140,19 +142,19 @@ void InternalClock::updateInstantaneousBpm(double bpm) { Q_UNUSED(bpm); } -void InternalClock::notifyMasterParamSource() { +void InternalClock::notifyLeaderParamSource() { } -void InternalClock::reinitMasterParams(double beatDistance, double baseBpm, double bpm) { +void InternalClock::reinitLeaderParams(double beatDistance, double baseBpm, double bpm) { if (kLogger.traceEnabled()) { - kLogger.trace() << "InternalClock::reinitMasterParams" << beatDistance << baseBpm << bpm; + kLogger.trace() << "InternalClock::reinitLeaderParams" << beatDistance << baseBpm << bpm; } if (bpm <= 0.0 || baseBpm <= 0.0) { return; } m_dBaseBpm = baseBpm; - updateMasterBpm(bpm); - updateMasterBeatDistance(beatDistance); + updateLeaderBpm(bpm); + updateLeaderBeatDistance(beatDistance); } void InternalClock::slotBaseBpmChanged(double baseBpm) { @@ -168,7 +170,7 @@ void InternalClock::slotBeatDistanceChanged(double beatDistance) { if (beatDistance < 0.0 || beatDistance > 1.0) { return; } - updateMasterBeatDistance(beatDistance); + updateLeaderBeatDistance(beatDistance); } void InternalClock::updateBeatLength(int sampleRate, double bpm) { @@ -189,7 +191,7 @@ void InternalClock::updateBeatLength(int sampleRate, double bpm) { // that last term is 1 over bpm. if (qFuzzyCompare(bpm, 0)) { - qDebug() << "WARNING: Master bpm reported to be zero, internal clock guessing 124bpm"; + qDebug() << "WARNING: Leader bpm reported to be zero, internal clock guessing 124bpm"; m_dBeatLength = (sampleRate * 60.0) / 124.0; m_dOldBpm = 124.0; } else { @@ -204,7 +206,7 @@ void InternalClock::updateBeatLength(int sampleRate, double bpm) { m_iOldSampleRate = sampleRate; // Restore the old beat distance. - updateMasterBeatDistance(oldBeatDistance); + updateLeaderBeatDistance(oldBeatDistance); } void InternalClock::onCallbackStart(int sampleRate, int bufferSize) { diff --git a/src/engine/sync/internalclock.h b/src/engine/sync/internalclock.h index d27e3939fd0..d8253899d36 100644 --- a/src/engine/sync/internalclock.h +++ b/src/engine/sync/internalclock.h @@ -13,11 +13,11 @@ class ControlPushButton; class EngineSync; class EngineChannel; -/// Internal Clock is a Master Sync object that provides a source of constant +/// Internal Clock is a Sync Lock object that provides a source of constant /// tempo when needed. The EngineSync will decide when to make the Internal -/// Clock master. The Internal Clock should not be given any new sources of +/// Clock leader. The Internal Clock should not be given any new sources of /// bpm clock. If someone wants to write a Midi Clock source, it should be -/// a separate Syncable object that can become master. +/// a separate Syncable object that can become ledaer. class InternalClock : public QObject, public Clock, public Syncable { Q_OBJECT public: @@ -48,14 +48,14 @@ class InternalClock : public QObject, public Clock, public Syncable { } double getBeatDistance() const override; - void updateMasterBeatDistance(double beatDistance) override; + void updateLeaderBeatDistance(double beatDistance) override; double getBaseBpm() const override; - void updateMasterBpm(double bpm) override; - void notifyMasterParamSource() override; + void updateLeaderBpm(double bpm) override; + void notifyLeaderParamSource() override; double getBpm() const override; void updateInstantaneousBpm(double bpm) override; - void reinitMasterParams(double beatDistance, double baseBpm, double bpm) override; + void reinitLeaderParams(double beatDistance, double baseBpm, double bpm) override; void onCallbackStart(int sampleRate, int bufferSize); void onCallbackEnd(int sampleRate, int bufferSize); @@ -63,7 +63,7 @@ class InternalClock : public QObject, public Clock, public Syncable { private slots: void slotBaseBpmChanged(double baseBpm); void slotBeatDistanceChanged(double beatDistance); - void slotSyncMasterEnabledChangeRequest(double state); + void slotSyncLeaderEnabledChangeRequest(double state); private: void updateBeatLength(int sampleRate, double bpm); @@ -72,7 +72,7 @@ class InternalClock : public QObject, public Clock, public Syncable { SyncableListener* m_pEngineSync; QScopedPointer m_pClockBpm; QScopedPointer m_pClockBeatDistance; - QScopedPointer m_pSyncMasterEnabled; + QScopedPointer m_pSyncLeaderEnabled; SyncMode m_mode; int m_iOldSampleRate; diff --git a/src/engine/sync/syncable.h b/src/engine/sync/syncable.h index f96b0153690..65d43d3135d 100644 --- a/src/engine/sync/syncable.h +++ b/src/engine/sync/syncable.h @@ -1,70 +1,88 @@ #pragma once +#include #include class EngineChannel; -enum SyncMode { - SYNC_INVALID = -1, - SYNC_NONE = 0, - SYNC_FOLLOWER = 1, - // SYNC_MASTER_SOFT is a master that Mixxx has chosen automatically. - // depending on how decks stop and start, it may reassign soft master at will. - SYNC_MASTER_SOFT = 2, - // SYNC_MASTER_EXPLICIT represents an explicit request that the synacable be - // master. Mixxx will only remove a SYNC_MASTER_SOFT if the track is stopped or +enum class SyncMode { + Invalid = -1, + None = 0, + Follower = 1, + // LeaderSoft is a leader that Mixxx has chosen automatically. + // depending on how decks stop and start, it may reassign soft leader at will. + LeaderSoft = 2, + // LeaderExplicit represents an explicit request that the syncable be + // leader. Mixxx will only remove a LeaderSoft if the track is stopped or // ejected. - SYNC_MASTER_EXPLICIT = 3, - SYNC_NUM_MODES + LeaderExplicit = 3, + NumModes }; +inline QDebug operator<<(QDebug debug, const SyncMode& mode) { + switch (mode) { + case SyncMode::Invalid: + return debug << "SyncMode::Invalid"; + case SyncMode::None: + return debug << "SyncMode::None"; + case SyncMode::Follower: + return debug << "SyncMode::Follower"; + case SyncMode::LeaderSoft: + return debug << "SyncMode::LeaderSoft"; + case SyncMode::LeaderExplicit: + return debug << "SyncMode::LeaderExplicit"; + case SyncMode::NumModes: + return debug << "SyncMode::NumModes"; + } + return debug << "SyncMode::Invalid (not in switch/case)"; +} inline SyncMode syncModeFromDouble(double value) { // msvs does not allow to cast from double to an enum SyncMode mode = static_cast(int(value)); - if (mode >= SYNC_NUM_MODES || mode < 0) { - return SYNC_NONE; + if (mode >= SyncMode::NumModes || mode == SyncMode::Invalid) { + return SyncMode::None; } return mode; } inline bool toSynchronized(SyncMode mode) { - return mode > SYNC_NONE; + return mode > SyncMode::None; } inline bool isFollower(SyncMode mode) { - return (mode == SYNC_FOLLOWER); + return (mode == SyncMode::Follower); } -inline bool isMaster(SyncMode mode) { - return (mode == SYNC_MASTER_SOFT || mode == SYNC_MASTER_EXPLICIT); +inline bool isLeader(SyncMode mode) { + return (mode == SyncMode::LeaderSoft || mode == SyncMode::LeaderExplicit); } -enum SyncMasterLight { - MASTER_INVALID = -1, - MASTER_OFF = 0, - MASTER_SOFT = 1, - MASTER_EXPLICIT = 2, +enum class SyncLeaderLight { + Invalid = -1, + Off = 0, + Soft = 1, + Explicit = 2, }; -inline SyncMasterLight SyncModeToMasterLight(SyncMode mode) { +inline SyncLeaderLight SyncModeToLeaderLight(SyncMode mode) { switch (mode) { - case SYNC_INVALID: - case SYNC_NONE: - case SYNC_FOLLOWER: - return MASTER_OFF; - case SYNC_MASTER_SOFT: - return MASTER_SOFT; - case SYNC_MASTER_EXPLICIT: - return MASTER_EXPLICIT; + case SyncMode::Invalid: + case SyncMode::None: + case SyncMode::Follower: + return SyncLeaderLight::Off; + case SyncMode::LeaderSoft: + return SyncLeaderLight::Soft; + case SyncMode::LeaderExplicit: + return SyncLeaderLight::Explicit; break; - case SYNC_NUM_MODES: + case SyncMode::NumModes: break; } - return MASTER_INVALID; + return SyncLeaderLight::Invalid; } /// Syncable is an abstract base class for any object that wants to participate -/// in Master Sync. +/// in Sync Lock. class Syncable { public: virtual ~Syncable() = default; @@ -103,27 +121,27 @@ class Syncable { virtual double getBaseBpm() const = 0; // The following functions are used to tell syncables about the state of the - // current Sync Master. + // current Sync Leader. // Must never result in a call to // SyncableListener::notifyBeatDistanceChanged or signal loops could occur. - virtual void updateMasterBeatDistance(double beatDistance) = 0; + virtual void updateLeaderBeatDistance(double beatDistance) = 0; // Update the current playback speed (not including scratch values) - // of the current master. + // of the current leader. // Must never result in a call to SyncableListener::notifyBpmChanged or // signal loops could occur. - virtual void updateMasterBpm(double bpm) = 0; + virtual void updateLeaderBpm(double bpm) = 0; - // Tells a Syncable that it's going to be used as a source for master + // Tells a Syncable that it's going to be used as a source for leader // params. This is a gross hack so that the SyncControl can undo its // half/double adjustment so bpms are initialized correctly. - virtual void notifyMasterParamSource() = 0; + virtual void notifyLeaderParamSource() = 0; - // Perform a reset of Master parameters. This function also triggers recalculation + // Perform a reset of Leader parameters. This function also triggers recalculation // of half-double multiplier. - virtual void reinitMasterParams(double beatDistance, double baseBpm, double bpm) = 0; + virtual void reinitLeaderParams(double beatDistance, double baseBpm, double bpm) = 0; - // Update the playback speed of the master, including scratch values. + // Update the playback speed of the leader, including scratch values. // Must never result in a call to // SyncableListener::notifyInstantaneousBpmChanged or signal loops could // occur. @@ -141,7 +159,7 @@ class SyncableListener { // Syncable::notifySyncModeChanged. virtual void requestSyncMode(Syncable* pSyncable, SyncMode mode) = 0; - // A Syncable must never call notifyBpmChanged in response to a setMasterBpm() + // A Syncable must never call notifyBpmChanged in response to a updateLeaderBpm() // call. virtual void notifyBaseBpmChanged(Syncable* pSyncable, double bpm) = 0; virtual void notifyRateChanged(Syncable* pSyncable, double bpm) = 0; @@ -162,5 +180,5 @@ class SyncableListener { virtual void notifyPlayingAudible(Syncable* pSyncable, bool playingAudible) = 0; - virtual Syncable* getMasterSyncable() = 0; + virtual Syncable* getLeaderSyncable() = 0; }; diff --git a/src/engine/sync/synccontrol.cpp b/src/engine/sync/synccontrol.cpp index 5762a03dd79..9b863b4cb6c 100644 --- a/src/engine/sync/synccontrol.cpp +++ b/src/engine/sync/synccontrol.cpp @@ -33,14 +33,14 @@ SyncControl::SyncControl(const QString& group, m_pBpmControl(nullptr), m_pRateControl(nullptr), m_bOldScratching(false), - m_masterBpmAdjustFactor(kBpmUnity), + m_leaderBpmAdjustFactor(kBpmUnity), m_unmultipliedTargetBeatDistance(0.0), m_pBpm(nullptr), m_pLocalBpm(nullptr), m_pRateRatio(nullptr), m_pVCEnabled(nullptr), m_pSyncPhaseButton(nullptr) { - // Play button. We only listen to this to disable master if the deck is + // Play button. We only listen to this to disable leader if the deck is // stopped. m_pPlayButton = new ControlProxy(group, "play", this); m_pPlayButton->connectValueChanged(this, &SyncControl::slotControlPlay, @@ -48,16 +48,18 @@ SyncControl::SyncControl(const QString& group, m_pSyncMode.reset(new ControlPushButton(ConfigKey(group, "sync_mode"))); m_pSyncMode->setButtonMode(ControlPushButton::TOGGLE); - m_pSyncMode->setStates(SYNC_NUM_MODES); + m_pSyncMode->setStates(static_cast(SyncMode::NumModes)); m_pSyncMode->connectValueChangeRequest( this, &SyncControl::slotSyncModeChangeRequest, Qt::DirectConnection); - m_pSyncMasterEnabled.reset( - new ControlPushButton(ConfigKey(group, "sync_master"))); - m_pSyncMasterEnabled->setButtonMode(ControlPushButton::TOGGLE); - m_pSyncMasterEnabled->setStates(3); - m_pSyncMasterEnabled->connectValueChangeRequest( - this, &SyncControl::slotSyncMasterEnabledChangeRequest, Qt::DirectConnection); + m_pSyncLeaderEnabled.reset( + new ControlPushButton(ConfigKey(group, "sync_leader"))); + m_pSyncLeaderEnabled->setButtonMode(ControlPushButton::TOGGLE); + m_pSyncLeaderEnabled->setStates(3); + m_pSyncLeaderEnabled->connectValueChangeRequest( + this, &SyncControl::slotSyncLeaderEnabledChangeRequest, Qt::DirectConnection); + ControlDoublePrivate::insertAlias(ConfigKey(group, "sync_master"), + ConfigKey(group, "sync_leader")); m_pSyncEnabled.reset( new ControlPushButton(ConfigKey(group, "sync_enabled"))); @@ -125,16 +127,16 @@ void SyncControl::setSyncMode(SyncMode mode) { } // SyncControl has absolutely no say in the matter. This is what EngineSync // requires. Bypass confirmation by using setAndConfirm. - m_pSyncMode->setAndConfirm(mode); - m_pSyncEnabled->setAndConfirm(mode != SYNC_NONE); - m_pSyncMasterEnabled->setAndConfirm(SyncModeToMasterLight(mode)); - if (mode == SYNC_FOLLOWER) { + m_pSyncMode->setAndConfirm(static_cast(mode)); + m_pSyncEnabled->setAndConfirm(mode != SyncMode::None); + m_pSyncLeaderEnabled->setAndConfirm(static_cast(SyncModeToLeaderLight(mode))); + if (mode == SyncMode::Follower) { if (m_pVCEnabled && m_pVCEnabled->toBool()) { // If follower mode is enabled, disable vinyl control. m_pVCEnabled->set(0.0); } } - if (mode != SYNC_NONE && m_pPassthroughEnabled->toBool()) { + if (mode != SyncMode::None && m_pPassthroughEnabled->toBool()) { // If any sync mode is enabled and passthrough was on somehow, disable passthrough. // This is very unlikely to happen so this deserves a warning. qWarning() << "Notified of sync mode change when passthrough was " @@ -142,8 +144,8 @@ void SyncControl::setSyncMode(SyncMode mode) { "must disable passthrough"; m_pPassthroughEnabled->set(0.0); } - if (mode == SYNC_NONE) { - m_masterBpmAdjustFactor = kBpmUnity; + if (mode == SyncMode::None) { + m_leaderBpmAdjustFactor = kBpmUnity; } } @@ -177,18 +179,18 @@ bool SyncControl::isAudible() const { double SyncControl::adjustSyncBeatDistance(double beatDistance) const { // Similar to adjusting the target beat distance, when we report our beat - // distance we need to adjust it by the master bpm adjustment factor. If - // we've been doubling the master bpm, we need to divide it in half. If - // we've been halving the master bpm, we need to double it. Both operations + // distance we need to adjust it by the leader bpm adjustment factor. If + // we've been doubling the leader bpm, we need to divide it in half. If + // we've been halving the leader bpm, we need to double it. Both operations // also need to account for if the longer beat is past its halfway point. // // This is the inverse of the updateTargetBeatDistance function below. - if (m_masterBpmAdjustFactor == kBpmDouble) { + if (m_leaderBpmAdjustFactor == kBpmDouble) { beatDistance /= kBpmDouble; if (m_unmultipliedTargetBeatDistance >= 0.5) { beatDistance += 0.5; } - } else if (m_masterBpmAdjustFactor == kBpmHalve) { + } else if (m_leaderBpmAdjustFactor == kBpmHalve) { if (beatDistance >= 0.5) { beatDistance -= 0.5; } @@ -203,12 +205,12 @@ double SyncControl::getBeatDistance() const { } double SyncControl::getBaseBpm() const { - return m_pLocalBpm->get() / m_masterBpmAdjustFactor; + return m_pLocalBpm->get() / m_leaderBpmAdjustFactor; } -void SyncControl::updateMasterBeatDistance(double beatDistance) { +void SyncControl::updateLeaderBeatDistance(double beatDistance) { if (kLogger.traceEnabled()) { - kLogger.trace() << getGroup() << "SyncControl::setMasterBeatDistance" + kLogger.trace() << getGroup() << "SyncControl::updateLeaderBeatDistance" << beatDistance; } // Set the BpmControl target beat distance to beatDistance, adjusted by @@ -219,13 +221,13 @@ void SyncControl::updateMasterBeatDistance(double beatDistance) { updateTargetBeatDistance(); } -void SyncControl::updateMasterBpm(double bpm) { +void SyncControl::updateLeaderBpm(double bpm) { if (kLogger.traceEnabled()) { - kLogger.trace() << getGroup() << "SyncControl::setMasterBpm" << bpm; + kLogger.trace() << getGroup() << "SyncControl::updateLeaderBpm" << bpm; } VERIFY_OR_DEBUG_ASSERT(isSynchronized()) { - qWarning() << "WARNING: Logic Error: setBpm called on SYNC_NONE syncable."; + qWarning() << "WARNING: Logic Error: setBpm called on SyncMode::None syncable."; return; } @@ -236,23 +238,23 @@ void SyncControl::updateMasterBpm(double bpm) { double localBpm = m_pLocalBpm->get(); if (localBpm > 0.0) { - m_pRateRatio->set(bpm * m_masterBpmAdjustFactor / localBpm); + m_pRateRatio->set(bpm * m_leaderBpmAdjustFactor / localBpm); } } -void SyncControl::notifyMasterParamSource() { - m_masterBpmAdjustFactor = kBpmUnity; +void SyncControl::notifyLeaderParamSource() { + m_leaderBpmAdjustFactor = kBpmUnity; } -void SyncControl::reinitMasterParams( +void SyncControl::reinitLeaderParams( double beatDistance, double baseBpm, double bpm) { if (kLogger.traceEnabled()) { - kLogger.trace() << "SyncControl::setMasterParams" << getGroup() + kLogger.trace() << "SyncControl::reinitLeaderParams" << getGroup() << beatDistance << baseBpm << bpm; } - m_masterBpmAdjustFactor = determineBpmMultiplier(fileBpm(), baseBpm); - updateMasterBpm(bpm); - updateMasterBeatDistance(beatDistance); + m_leaderBpmAdjustFactor = determineBpmMultiplier(fileBpm(), baseBpm); + updateLeaderBpm(bpm); + updateLeaderBeatDistance(beatDistance); } double SyncControl::determineBpmMultiplier(double myBpm, double targetBpm) const { @@ -277,7 +279,7 @@ void SyncControl::updateTargetBeatDistance() { kLogger.trace() << getGroup() << "SyncControl::updateTargetBeatDistance, unmult distance" - << targetDistance << m_masterBpmAdjustFactor; + << targetDistance << m_leaderBpmAdjustFactor; } // Determining the target distance is not as simple as x2 or /2. Since one @@ -285,12 +287,12 @@ void SyncControl::updateTargetBeatDistance() { // position of the longer beat is past its halfway point. e.g. 0.0 for the // long beat is 0.0 of the short beat, but 0.5 for the long beat is also // 0.0 for the short beat. - if (m_masterBpmAdjustFactor == kBpmDouble) { + if (m_leaderBpmAdjustFactor == kBpmDouble) { if (targetDistance >= 0.5) { targetDistance -= 0.5; } targetDistance *= kBpmDouble; - } else if (m_masterBpmAdjustFactor == kBpmHalve) { + } else if (m_leaderBpmAdjustFactor == kBpmHalve) { targetDistance *= kBpmHalve; // Our beat distance CO is still a buffer behind, so take the current value. if (m_pBpmControl->getBeatDistance(getSampleOfTrack().current) >= 0.5) { @@ -306,21 +308,21 @@ void SyncControl::updateTargetBeatDistance() { double SyncControl::getBpm() const { if (kLogger.traceEnabled()) { kLogger.trace() << getGroup() << "SyncControl::getBpm()" - << m_pBpm->get() << "/" << m_masterBpmAdjustFactor; + << m_pBpm->get() << "/" << m_leaderBpmAdjustFactor; } - return m_pBpm->get() / m_masterBpmAdjustFactor; + return m_pBpm->get() / m_leaderBpmAdjustFactor; } void SyncControl::updateInstantaneousBpm(double bpm) { // Adjust the incoming bpm by the multiplier. - m_pBpmControl->updateInstantaneousBpm(bpm * m_masterBpmAdjustFactor); + m_pBpmControl->updateInstantaneousBpm(bpm * m_leaderBpmAdjustFactor); } void SyncControl::reportTrackPosition(double fractionalPlaypos) { - // If we're close to the end, and master, disable master so we don't stop + // If we're close to the end, and leader, disable leader so we don't stop // the party. - if (isMaster(getSyncMode()) && fractionalPlaypos >= 1.0) { - m_pChannel->getEngineBuffer()->requestSyncMode(SYNC_FOLLOWER); + if (isLeader(getSyncMode()) && fractionalPlaypos >= 1.0) { + m_pChannel->getEngineBuffer()->requestSyncMode(SyncMode::Follower); } } @@ -346,23 +348,23 @@ void SyncControl::trackBeatsUpdated(mixxx::BeatsPointer pBeats) { } m_pBeats = pBeats; - m_masterBpmAdjustFactor = kBpmUnity; + m_leaderBpmAdjustFactor = kBpmUnity; SyncMode syncMode = getSyncMode(); - if (isMaster(syncMode)) { + if (isLeader(syncMode)) { if (!m_pBeats) { // If the track was ejected or suddenly has no beats, we can no longer - // be master. - m_pChannel->getEngineBuffer()->requestSyncMode(SYNC_FOLLOWER); + // be leader. + m_pChannel->getEngineBuffer()->requestSyncMode(SyncMode::Follower); } else { - // We are remaining master, so notify the engine with our update. + // We are remaining leader, so notify the engine with our update. m_pBpmControl->updateLocalBpm(); m_pEngineSync->notifyBaseBpmChanged(this, getBaseBpm()); } } else if (isFollower(syncMode)) { // If we were a follower, requesting sync mode refreshes - // the soft master -- if we went from having no bpm to having - // a bpm, we might need to become master. + // the soft leader -- if we went from having no bpm to having + // a bpm, we might need to become leader. m_pChannel->getEngineBuffer()->requestSyncMode(syncMode); m_pBpmControl->updateLocalBpm(); } @@ -376,16 +378,16 @@ void SyncControl::slotControlPlay(double play) { } void SyncControl::slotVinylControlChanged(double enabled) { - if (enabled != 0 && getSyncMode() == SYNC_FOLLOWER) { + if (enabled != 0 && getSyncMode() == SyncMode::Follower) { // If vinyl control was enabled and we're a follower, disable sync mode. - m_pChannel->getEngineBuffer()->requestSyncMode(SYNC_NONE); + m_pChannel->getEngineBuffer()->requestSyncMode(SyncMode::None); } } void SyncControl::slotPassthroughChanged(double enabled) { if (enabled != 0 && isSynchronized()) { // If passthrough was enabled and sync was on, disable it. - m_pChannel->getEngineBuffer()->requestSyncMode(SYNC_NONE); + m_pChannel->getEngineBuffer()->requestSyncMode(SyncMode::None); } } @@ -394,16 +396,16 @@ void SyncControl::slotSyncModeChangeRequest(double state) { kLogger.trace() << getGroup() << "SyncControl::slotSyncModeChangeRequest"; } SyncMode mode = syncModeFromDouble(state); - if (m_pPassthroughEnabled->toBool() && mode != SYNC_NONE) { + if (m_pPassthroughEnabled->toBool() && mode != SyncMode::None) { qDebug() << "Disallowing enabling of sync mode when passthrough active"; } else { m_pChannel->getEngineBuffer()->requestSyncMode(mode); } } -void SyncControl::slotSyncMasterEnabledChangeRequest(double state) { +void SyncControl::slotSyncLeaderEnabledChangeRequest(double state) { if (kLogger.traceEnabled()) { - kLogger.trace() << "SyncControl::slotSyncMasterEnabledChangeRequest" << getGroup(); + kLogger.trace() << "SyncControl::slotSyncLeaderEnabledChangeRequest" << getGroup(); } SyncMode mode = getSyncMode(); if (state > 0.0) { @@ -411,15 +413,15 @@ void SyncControl::slotSyncMasterEnabledChangeRequest(double state) { qDebug() << "Disallowing enabling of sync mode when passthrough active"; return; } - m_pChannel->getEngineBuffer()->requestSyncMode(SYNC_MASTER_EXPLICIT); + m_pChannel->getEngineBuffer()->requestSyncMode(SyncMode::LeaderExplicit); } else { - // Turning off master goes back to follower mode. + // Turning off leader goes back to follower mode. switch (mode) { - case SYNC_MASTER_EXPLICIT: - m_pChannel->getEngineBuffer()->requestSyncMode(SYNC_MASTER_SOFT); + case SyncMode::LeaderExplicit: + m_pChannel->getEngineBuffer()->requestSyncMode(SyncMode::LeaderSoft); break; - case SYNC_MASTER_SOFT: - m_pChannel->getEngineBuffer()->requestSyncMode(SYNC_FOLLOWER); + case SyncMode::LeaderSoft: + m_pChannel->getEngineBuffer()->requestSyncMode(SyncMode::Follower); break; default: return; @@ -449,23 +451,23 @@ void SyncControl::setLocalBpm(double local_bpm) { m_prevLocalBpm.setValue(local_bpm); SyncMode syncMode = getSyncMode(); - if (syncMode <= SYNC_NONE) { + if (syncMode <= SyncMode::None) { return; } double bpm = local_bpm * m_pRateRatio->get(); if (isFollower(syncMode)) { - // In this case we need an update from the current master to adjust - // the rate that we continue with the master BPM. If there is no - // master bpm, our bpm value is adopted and the m_masterBpmAdjustFactor + // In this case we need an update from the current leader to adjust + // the rate that we continue with the leader BPM. If there is no + // leader bpm, our bpm value is adopted and the m_leaderBpmAdjustFactor // is reset to 1; m_pEngineSync->requestBpmUpdate(this, bpm); } else { - DEBUG_ASSERT(isMaster(syncMode)); - // We might have adopted an adjust factor when becoming master. + DEBUG_ASSERT(isLeader(syncMode)); + // We might have adopted an adjust factor when becoming leader. // Keep it when reporting our bpm. - m_pEngineSync->notifyBaseBpmChanged(this, bpm / m_masterBpmAdjustFactor); + m_pEngineSync->notifyBaseBpmChanged(this, bpm / m_leaderBpmAdjustFactor); } } @@ -487,9 +489,9 @@ void SyncControl::slotRateChanged() { kLogger.trace() << getGroup() << "SyncControl::slotRateChanged" << m_pRateRatio->get() << bpm; } if (bpm > 0 && isSynchronized()) { - // When reporting our bpm, remove the multiplier so the masters all + // When reporting our bpm, remove the multiplier so the leaders all // think the followers have the same bpm. - m_pEngineSync->notifyRateChanged(this, bpm / m_masterBpmAdjustFactor); + m_pEngineSync->notifyRateChanged(this, bpm / m_leaderBpmAdjustFactor); } } @@ -500,9 +502,9 @@ void SyncControl::reportPlayerSpeed(double speed, bool scratching) { // No need to disable sync mode while scratching, the engine won't // get confused. } - // When reporting our speed, remove the multiplier so the masters all + // When reporting our speed, remove the multiplier so the leaders all // think the followers have the same bpm. - double instantaneous_bpm = m_pLocalBpm->get() * speed / m_masterBpmAdjustFactor; + double instantaneous_bpm = m_pLocalBpm->get() * speed / m_leaderBpmAdjustFactor; m_pEngineSync->notifyInstantaneousBpmChanged(this, instantaneous_bpm); } diff --git a/src/engine/sync/synccontrol.h b/src/engine/sync/synccontrol.h index 1654a0208b1..d0856f6c166 100644 --- a/src/engine/sync/synccontrol.h +++ b/src/engine/sync/synccontrol.h @@ -13,7 +13,7 @@ class ControlObject; class ControlProxy; class ControlPushButton; -/// SyncControl is the Master Sync object for playback decks. +/// SyncControl is the Sync Lock object for playback decks. class SyncControl : public EngineControl, public Syncable { Q_OBJECT public: @@ -47,12 +47,12 @@ class SyncControl : public EngineControl, public Syncable { // Must never result in a call to // SyncableListener::notifyBeatDistanceChanged or signal loops could occur. - void updateMasterBeatDistance(double beatDistance) override; + void updateLeaderBeatDistance(double beatDistance) override; // Must never result in a call to // SyncableListener::notifyBpmChanged or signal loops could occur. - void updateMasterBpm(double bpm) override; - void notifyMasterParamSource() override; - void reinitMasterParams(double beatDistance, double baseBpm, double bpm) override; + void updateLeaderBpm(double bpm) override; + void notifyLeaderParamSource() override; + void reinitLeaderParams(double beatDistance, double baseBpm, double bpm) override; // Must never result in a call to // SyncableListener::notifyInstantaneousBpmChanged or signal loops could @@ -83,13 +83,13 @@ class SyncControl : public EngineControl, public Syncable { // Change request handlers for sync properties. void slotSyncModeChangeRequest(double state); void slotSyncEnabledChangeRequest(double enabled); - void slotSyncMasterEnabledChangeRequest(double state); + void slotSyncLeaderEnabledChangeRequest(double state); private: FRIEND_TEST(SyncControlTest, TestDetermineBpmMultiplier); // Sometimes it's best to match bpms based on half or double the target // bpm. e.g. 70 matches better with 140/2. This function returns the - // best factor for multiplying the master bpm to get a bpm this syncable + // best factor for multiplying the leader bpm to get a bpm this syncable // should match against. double determineBpmMultiplier(double myBpm, double targetBpm) const; double fileBpm() const; @@ -97,7 +97,7 @@ class SyncControl : public EngineControl, public Syncable { QString m_sGroup; // The only reason we have this pointer is an optimzation so that the // EngineSync can ask us what our EngineChannel is. EngineMaster in turn - // asks EngineSync what EngineChannel is the "master" channel. + // asks EngineSync what EngineChannel is the "leader" channel. EngineChannel* m_pChannel; SyncableListener* m_pEngineSync; BpmControl* m_pBpmControl; @@ -105,12 +105,12 @@ class SyncControl : public EngineControl, public Syncable { bool m_bOldScratching; // When syncing, sometimes it's better to match half or double the - // master bpm. + // leader bpm. FRIEND_TEST(EngineSyncTest, HalfDoubleBpmTest); FRIEND_TEST(EngineSyncTest, HalfDoubleThenPlay); - // The amount we should multiply the master BPM by to find a good sync match. + // The amount we should multiply the leader BPM by to find a good sync match. // Sometimes this is 2 or 0.5. - double m_masterBpmAdjustFactor; + double m_leaderBpmAdjustFactor; // It is handy to store the raw reported target beat distance in case the // multiplier changes and we need to recalculate the target distance. double m_unmultipliedTargetBeatDistance; @@ -118,7 +118,7 @@ class SyncControl : public EngineControl, public Syncable { QAtomicInt m_audible; QScopedPointer m_pSyncMode; - QScopedPointer m_pSyncMasterEnabled; + QScopedPointer m_pSyncLeaderEnabled; QScopedPointer m_pSyncEnabled; QScopedPointer m_pBeatDistance; diff --git a/src/mixer/basetrackplayer.cpp b/src/mixer/basetrackplayer.cpp index 63313d16e21..c9f0aff6fee 100644 --- a/src/mixer/basetrackplayer.cpp +++ b/src/mixer/basetrackplayer.cpp @@ -493,7 +493,7 @@ void BaseTrackPlayerImpl::slotTrackLoaded(TrackPointer pNewTrack, int reset = m_pConfig->getValue( ConfigKey("[Controls]", "SpeedAutoReset"), RESET_PITCH); if (reset == RESET_SPEED || reset == RESET_PITCH_AND_SPEED) { - // Avoid resetting speed if master sync is enabled and other decks with sync enabled + // Avoid resetting speed if sync lock is enabled and other decks with sync enabled // are playing, as this would change the speed of already playing decks. if (!m_pEngineMaster->getEngineSync()->otherSyncedPlaying(getGroup())) { m_pRateRatio->set(1.0); diff --git a/src/skin/legacy/tooltips.cpp b/src/skin/legacy/tooltips.cpp index 3540c5a43fb..eb83cf461aa 100644 --- a/src/skin/legacy/tooltips.cpp +++ b/src/skin/legacy/tooltips.cpp @@ -538,7 +538,7 @@ void Tooltips::addStandardTooltips() { // Ghetto-Sync (TM) add("beatsync_beatsync_tempo") << tr("Old Synchronize") - << tr("(This skin should be updated to use Master Sync!)") + << tr("(This skin should be updated to use Sync Lock!)") << QString("%1: %2").arg(leftClick, tr("Syncs the tempo (BPM) and phase to that of the other track, " "if BPM is detected on both.")) << QString("%1: %2").arg(rightClick, tr("Syncs the tempo (BPM) to that of the other track, " @@ -549,8 +549,8 @@ void Tooltips::addStandardTooltips() { // Awesome-Sync (TM) add("sync_enabled") - << tr("Enable Master Sync") - << tr("Tap to sync the tempo to other playing tracks or the master clock.") + << tr("Enable Sync Lock") + << tr("Tap to sync the tempo to other playing tracks or the sync leader.") << tr("Hold for at least a second to enable sync lock for this deck.") << tr("Decks with sync locked will all play at the same tempo, and decks that also have " "quantize enabled will always have their beats lined up."); @@ -562,9 +562,9 @@ void Tooltips::addStandardTooltips() { "from the other track. Requires a detected key on both involved decks.")) << QString("%1: %2").arg(rightClick, tr("Resets the key to the original track key.")); - add("sync_master") - << tr("Enable Sync Clock Master") - << tr("When enabled, this device will serve as the master clock for all other decks."); + add("sync_leader") + << tr("Enable Sync Leader") + << tr("When enabled, this device will serve as the sync leader for all other decks."); add("rate") << tr("Speed Control") diff --git a/src/test/co_dumps/co_dump_inital.csv b/src/test/co_dumps/co_dump_inital.csv index 119d94e8dc6..8f897b65b98 100644 --- a/src/test/co_dumps/co_dump_inital.csv +++ b/src/test/co_dumps/co_dump_inital.csv @@ -97,7 +97,7 @@ [EqualizerRack1_[Channel3]_Effect1],parameter1_type,2 [Sampler1],hotcue_17_gotoandplay,0 [PreviewDeck1],beatloop_32_activate,0 -[Channel1],sync_master,0 +[Channel1],sync_leader,0 [EffectRack1_EffectUnit4_Effect3],parameter1_link_type,0 [QuickEffectRack1_[Channel3]_Effect1],parameter6_toggle,0 [EffectRack1_EffectUnit3_Effect4],parameter3_minus_toggle,0 @@ -109,7 +109,7 @@ [QuickEffectRack1_[Channel1]_Effect1],parameter13_down,0 [Sampler2],hotcue_17_gotoandplay,0 [EffectRack1_EffectUnit3_Effect3],parameter14_set_minus_one,0 -[Channel2],sync_master,0 +[Channel2],sync_leader,0 [EffectRack1_EffectUnit4_Effect4],parameter1_link_type,0 [EffectRack1_EffectUnit3_Effect1],parameter5_minus_toggle,0 [EqualizerRack1_[Master]_Effect1],button_parameter10_loaded,0 @@ -170,7 +170,7 @@ [Sampler3],VuMeterL_up,0 [QuickEffectRack1_[Channel4]_Effect1],parameter3_set_zero,0 [Sampler3],hotcue_27_gotoandplay,0 -[Channel3],sync_master,0 +[Channel3],sync_leader,0 [QuickEffectRack1_[Channel3]_Effect1],parameter3_toggle,0 [EffectRack1_EffectUnit3_Effect2],parameter6_minus_toggle,0 [EqualizerRack1_[Channel3]_Effect1],parameter14_down,0 @@ -187,7 +187,7 @@ [Master],headGain_set_one,0 [Sampler4],hotcue_27_gotoandplay,0 [EffectRack1_EffectUnit4_Effect2],num_parameters,0 -[Channel4],sync_master,0 +[Channel4],sync_leader,0 [EffectRack1_EffectUnit3_Effect3],parameter9_minus_toggle,0 [EffectRack1_EffectUnit2_Effect2],parameter3_type,0 [Sampler4],hotcue_16_gotoandstop,0 @@ -343,7 +343,7 @@ [EffectRack1_EffectUnit3_Effect3],parameter6_minus_toggle,0 [EqualizerRack1_[Channel2]],mix_down,0 [EffectRack1_EffectUnit2_Effect2],button_parameter9_type,0 -[PreviewDeck1],sync_master,0 +[PreviewDeck1],sync_leader,0 [EffectRack1_EffectUnit4_Effect4],button_parameter11_type,0 [EqualizerRack1_[Channel4]_Effect1],button_parameter4_type,0 [PreviewDeck1],bpm_minus_toggle,0 @@ -9711,7 +9711,7 @@ [Microphone2],PeakIndicator_toggle,0 [EffectRack1_EffectUnit1_Effect2],parameter14_link_inverse,0 [EffectRack1_EffectUnit3_Effect3],button_parameter8_type,0 -[Sampler3],sync_master,0 +[Sampler3],sync_leader,0 [EqualizerRack1_[Master]_Effect1],button_parameter1,0 [QuickEffectRack1_[Channel1]_Effect1],parameter12_set_default,0 [Sampler1],rate_temp_down,0 @@ -9722,7 +9722,7 @@ [EffectRack1_EffectUnit3_Effect4],button_parameter8_type,0 [QuickEffectRack1_[Channel2]_Effect1],button_parameter9_type,0 [EqualizerRack1_[Channel3]],super1_set_minus_one,0 -[Sampler4],sync_master,0 +[Sampler4],sync_leader,0 [EffectRack1_EffectUnit4_Effect1],button_parameter5_type,0 [EqualizerRack1_[Channel4]_Effect1],button_parameter15,0 [PreviewDeck1],hotcue_23_gotoandplay,0 @@ -9737,7 +9737,7 @@ [Microphone4],PeakIndicator_toggle,0 [EffectRack1_EffectUnit3_Effect4],parameter14_link_inverse,0 [Sampler4],talkover,0 -[Sampler1],sync_master,0 +[Sampler1],sync_leader,0 [Channel4],beatloop_4_enabled,0 [EffectRack1_EffectUnit4_Effect2],button_parameter5_type,0 [QuickEffectRack1_[Channel1]_Effect1],parameter9,0 @@ -9759,7 +9759,7 @@ [PreviewDeck1],hotcue_20_activate_preview,0 [QuickEffectRack1_[Channel1]_Effect1],parameter2,0.707107 [EffectRack1_EffectUnit4_Effect4],parameter1_link_inverse,0 -[Sampler2],sync_master,0 +[Sampler2],sync_leader,0 [Channel3],beatloop_4_enabled,0 [EffectRack1_EffectUnit2_Effect3],parameter8_set_minus_one,0 [QuickEffectRack1_[Channel3]_Effect1],parameter1_down_small,0 @@ -9909,7 +9909,7 @@ [Channel3],hotcue_31_goto,0 [Playlist],LoadSelectedIntoFirstStopped,0 [Channel2],hotcue_1_activate_preview,0 -[InternalClock],sync_master,0 +[InternalClock],sync_leader,0 [EffectRack1_EffectUnit4_Effect1],parameter11_down_small,0 [Sampler3],rateSearch_set_minus_one,0 [EqualizerRack1_[Channel1]_Effect1],parameter11_up,0 diff --git a/src/test/enginesynctest.cpp b/src/test/enginesynctest.cpp index 0a9d2423a3b..b026c377d10 100644 --- a/src/test/enginesynctest.cpp +++ b/src/test/enginesynctest.cpp @@ -20,50 +20,50 @@ constexpr double kMaxFloatingPointErrorHighPrecision = 0.0000000000000005; constexpr double kMaxBeatDistanceEpsilon = 1e-9; } // namespace -/// Tests for Master Sync. +/// Tests for Sync Lock. /// The following manual tests should probably be performed: -/// * Quantize mode nudges tracks in sync, whether internal or deck master. +/// * Quantize mode nudges tracks in sync, whether internal or deck leader. /// * Flinging tracks with the waveform should work. /// * vinyl?? class EngineSyncTest : public MockedEngineBackendTest { public: - QString getMasterGroup() { - Syncable* pMasterSyncable = m_pEngineSync->getMasterSyncable(); - if (pMasterSyncable) { - return pMasterSyncable->getGroup(); + QString getLeaderGroup() { + Syncable* pLeaderSyncable = m_pEngineSync->getLeaderSyncable(); + if (pLeaderSyncable) { + return pLeaderSyncable->getGroup(); } return QString(); } - bool isExplicitMaster(const QString& group) { - return isMaster(group, SYNC_MASTER_EXPLICIT); + bool isExplicitLeader(const QString& group) { + return isLeader(group, SyncMode::LeaderExplicit); } - bool isSoftMaster(const QString& group) { - return isMaster(group, SYNC_MASTER_SOFT); + bool isSoftLeader(const QString& group) { + return isLeader(group, SyncMode::LeaderSoft); } bool isFollower(const QString& group) { if (group == m_sInternalClockGroup) { return !ControlObject::getControl(ConfigKey(m_sInternalClockGroup, - "sync_master")) + "sync_leader")) ->toBool(); } if (auto mode = ControlObject::getControl(ConfigKey(group, "sync_mode")) ->get(); - mode != SYNC_FOLLOWER) { - qWarning() << "expected mode SYNC_FOLLOWER, got" << mode; + static_cast(mode) != SyncMode::Follower) { + qWarning() << "expected mode Follower, got" << mode; return false; } if (!ControlObject::getControl(ConfigKey(group, "sync_enabled"))->toBool()) { qWarning() << "sync_enabled should be on, isn't"; return false; } - if (double master = ControlObject::getControl( - ConfigKey(group, "sync_master")) + if (double leader = ControlObject::getControl( + ConfigKey(group, "sync_leader")) ->get(); - master != 0.0) { - qWarning() << "sync_master should be 0.0, is" << master; + leader != 0.0) { + qWarning() << "sync_leader should be 0.0, is" << leader; return false; } return true; @@ -73,115 +73,115 @@ class EngineSyncTest : public MockedEngineBackendTest { if (group == m_sInternalClockGroup) { EXPECT_EQ(0, ControlObject::getControl( - ConfigKey(m_sInternalClockGroup, "sync_master")) + ConfigKey(m_sInternalClockGroup, "sync_leader")) ->get()); } else { - EXPECT_EQ(SYNC_NONE, - ControlObject::getControl(ConfigKey(group, "sync_mode")) - ->get()); + EXPECT_EQ(SyncMode::None, + static_cast(ControlObject::getControl(ConfigKey(group, "sync_mode")) + ->get())); EXPECT_EQ(0, ControlObject::getControl(ConfigKey(group, "sync_enabled")) ->get()); EXPECT_EQ(0, - ControlObject::getControl(ConfigKey(group, "sync_master")) + ControlObject::getControl(ConfigKey(group, "sync_leader")) ->get()); } } - void assertNoMaster() { - EXPECT_EQ(NULL, m_pEngineSync->getMaster()); - EXPECT_EQ(NULL, m_pEngineSync->getMasterSyncable()); + void assertNoLeader() { + EXPECT_EQ(NULL, m_pEngineSync->getLeader()); + EXPECT_EQ(NULL, m_pEngineSync->getLeaderSyncable()); } private: - bool isMaster(const QString& group, SyncMode masterType) { + bool isLeader(const QString& group, SyncMode leaderType) { if (group == m_sInternalClockGroup) { - double master = ControlObject::getControl(ConfigKey(m_sInternalClockGroup, - "sync_master")) + double leader = ControlObject::getControl(ConfigKey(m_sInternalClockGroup, + "sync_leader")) ->get(); - if (masterType == SYNC_MASTER_SOFT && master != 1.0) { - qWarning() << "internal clock sync_master should be 1.0, is" << master; + if (leaderType == SyncMode::LeaderSoft && leader != 1.0) { + qWarning() << "internal clock sync_leader should be 1.0, is" << leader; return false; - } else if (masterType == SYNC_MASTER_EXPLICIT && master != 2.0) { - qWarning() << "internal clock sync_master should be 2.0, is" << master; + } else if (leaderType == SyncMode::LeaderExplicit && leader != 2.0) { + qWarning() << "internal clock sync_leader should be 2.0, is" << leader; return false; } - if (m_pEngineSync->getMaster()) { - qWarning() << "no current master"; + if (m_pEngineSync->getLeader()) { + qWarning() << "no current leader"; return false; } - if (m_sInternalClockGroup != getMasterGroup()) { - qWarning() << "internal clock is not master, it's" << getMasterGroup(); + if (m_sInternalClockGroup != getLeaderGroup()) { + qWarning() << "internal clock is not leader, it's" << getLeaderGroup(); return false; } return true; } if (group == m_sGroup1) { - if (m_pEngineSync->getMaster() != m_pChannel1) { - qWarning() << "master pointer should be channel 1, is " - << (m_pEngineSync->getMaster() - ? m_pEngineSync->getMaster() + if (m_pEngineSync->getLeader() != m_pChannel1) { + qWarning() << "leader pointer should be channel 1, is " + << (m_pEngineSync->getLeader() + ? m_pEngineSync->getLeader() ->getGroup() : "null"); return false; } } else if (group == m_sGroup2) { - if (m_pEngineSync->getMaster() != m_pChannel2) { - qWarning() << "master pointer should be channel 2, is " - << (m_pEngineSync->getMaster() - ? m_pEngineSync->getMaster() + if (m_pEngineSync->getLeader() != m_pChannel2) { + qWarning() << "leader pointer should be channel 2, is " + << (m_pEngineSync->getLeader() + ? m_pEngineSync->getLeader() ->getGroup() : "null"); return false; } } else if (group == m_sGroup3) { - if (m_pEngineSync->getMaster() != m_pChannel3) { - qWarning() << "master pointer should be channel 3, is " - << (m_pEngineSync->getMaster() - ? m_pEngineSync->getMaster() + if (m_pEngineSync->getLeader() != m_pChannel3) { + qWarning() << "leader pointer should be channel 3, is " + << (m_pEngineSync->getLeader() + ? m_pEngineSync->getLeader() ->getGroup() : "null"); return false; } } - if (getMasterGroup() != group) { - qWarning() << "master group should be" << group << ", is" << getMasterGroup(); + if (getLeaderGroup() != group) { + qWarning() << "leader group should be" << group << ", is" << getLeaderGroup(); return false; } if (auto mode = ControlObject::getControl(ConfigKey(group, "sync_mode")) ->get(); - mode != masterType) { - qWarning() << "mode should be" << masterType << ", is" << mode; + static_cast(mode) != leaderType) { + qWarning() << "mode should be" << leaderType << ", is" << mode; return false; } if (!ControlObject::getControl(ConfigKey(group, "sync_enabled"))->toBool()) { qWarning() << "sync_enabled should be true, isn't"; return false; } - switch (masterType) { - case SYNC_MASTER_SOFT: { - if (double master = ControlObject::getControl( - ConfigKey(group, "sync_master")) + switch (leaderType) { + case SyncMode::LeaderSoft: { + if (double leader = ControlObject::getControl( + ConfigKey(group, "sync_leader")) ->get(); - master != 1.0) { - qWarning() << "master should be 1.0, is" << master; + leader != 1.0) { + qWarning() << "leader should be 1.0, is" << leader; return false; } break; } - case SYNC_MASTER_EXPLICIT: { - if (double master = ControlObject::getControl( - ConfigKey(group, "sync_master")) + case SyncMode::LeaderExplicit: { + if (double leader = ControlObject::getControl( + ConfigKey(group, "sync_leader")) ->get(); - master != 2.0) { - qWarning() << "master should be 2.0, is" << master; + leader != 2.0) { + qWarning() << "leader should be 2.0, is" << leader; return false; } break; } default: - qWarning() << "bad master type specified"; + qWarning() << "bad leader type specified"; return false; } return true; @@ -194,46 +194,46 @@ TEST_F(EngineSyncTest, ControlObjectsExist) { NULL); } -TEST_F(EngineSyncTest, SetMasterSuccess) { - // If we set the first channel to master, EngineSync should get that message. +TEST_F(EngineSyncTest, SetLeaderSuccess) { + // If we set the first channel to leader, EngineSync should get that message. - auto pButtonMasterSync1 = + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); - pButtonMasterSync1->slotSet(SYNC_MASTER_EXPLICIT); + pButtonLeaderSync1->slotSet(static_cast(SyncMode::LeaderExplicit)); ProcessBuffer(); - // No tracks are playing and we have no beats, SYNC_MASTER_EXPLICIT state is in stand-by + // No tracks are playing and we have no beats, LeaderExplicit state is in stand-by EXPECT_DOUBLE_EQ( 0.0, ControlObject::getControl(ConfigKey(m_sGroup1, "bpm"))->get()); - // The master sync should now be internal clock, with group 1 waiting for play. + // The sync lock should now be internal clock, with group 1 waiting for play. EXPECT_TRUE(isFollower(m_sInternalClockGroup)); EXPECT_TRUE(isFollower(m_sGroup1)); - auto pButtonMasterSync2 = + auto pButtonLeaderSync2 = std::make_unique(m_sGroup2, "sync_mode"); - pButtonMasterSync2->set(SYNC_FOLLOWER); + pButtonLeaderSync2->set(static_cast(SyncMode::Follower)); ProcessBuffer(); EXPECT_TRUE(isFollower(m_sGroup2)); - // Now set channel 2 to be master. - pButtonMasterSync2->set(SYNC_MASTER_EXPLICIT); + // Now set channel 2 to be leader. + pButtonLeaderSync2->set(static_cast(SyncMode::LeaderExplicit)); ProcessBuffer(); - // Now channel 2 should be waiting master, and channel 1 should be a follower. + // Now channel 2 should be waiting leader, and channel 1 should be a follower. EXPECT_TRUE(isFollower(m_sGroup2)); EXPECT_TRUE(isFollower(m_sGroup1)); // Now back again. - pButtonMasterSync1->set(SYNC_MASTER_EXPLICIT); + pButtonLeaderSync1->set(static_cast(SyncMode::LeaderExplicit)); ProcessBuffer(); - // Now channel 1 should be waiting master, and channel 2 should be a follower. + // Now channel 1 should be waiting leader, and channel 2 should be a follower. EXPECT_TRUE(isFollower(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); // Now set channel 1 to follower, now all are followers, waiting for a tempo to adopt. - pButtonMasterSync1->slotSet(SYNC_FOLLOWER); + pButtonLeaderSync1->slotSet(static_cast(SyncMode::Follower)); ProcessBuffer(); EXPECT_TRUE(isFollower(m_sInternalClockGroup)); @@ -241,9 +241,9 @@ TEST_F(EngineSyncTest, SetMasterSuccess) { EXPECT_TRUE(isFollower(m_sGroup2)); } -TEST_F(EngineSyncTest, ExplicitMasterPersists) { - // If we set an explicit master, enabling sync or pressing play on other decks - // doesn't cause the master to move around. +TEST_F(EngineSyncTest, ExplicitLeaderPersists) { + // If we set an explicit leader, enabling sync or pressing play on other decks + // doesn't cause the leader to move around. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(120), mixxx::audio::kStartFramePos); m_pTrack1->trySetBeats(pBeats1); @@ -251,20 +251,20 @@ TEST_F(EngineSyncTest, ExplicitMasterPersists) { m_pTrack2->getSampleRate(), mixxx::Bpm(124), mixxx::audio::kStartFramePos); m_pTrack2->trySetBeats(pBeats2); - auto pButtonMasterSync1 = + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); ControlObject::getControl(ConfigKey(m_sGroup1, "play"))->set(1.0); - pButtonMasterSync1->slotSet(SYNC_MASTER_EXPLICIT); + pButtonLeaderSync1->slotSet(static_cast(SyncMode::LeaderExplicit)); ProcessBuffer(); - // The master sync should now be channel 1. - EXPECT_TRUE(isExplicitMaster(m_sGroup1)); + // The sync lock should now be channel 1. + EXPECT_TRUE(isExplicitLeader(m_sGroup1)); - auto pButtonMasterSync2 = + auto pButtonLeaderSync2 = std::make_unique(m_sGroup2, "sync_enabled"); ControlObject::getControl(ConfigKey(m_sGroup2, "play"))->set(1.0); - pButtonMasterSync2->set(1.0); + pButtonLeaderSync2->set(1.0); ProcessBuffer(); - EXPECT_TRUE(isExplicitMaster(m_sGroup1)); + EXPECT_TRUE(isExplicitLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); // Stop deck 2, and restart it, no change. @@ -272,12 +272,12 @@ TEST_F(EngineSyncTest, ExplicitMasterPersists) { ProcessBuffer(); ControlObject::getControl(ConfigKey(m_sGroup2, "play"))->set(1.0); ProcessBuffer(); - EXPECT_TRUE(isExplicitMaster(m_sGroup1)); + EXPECT_TRUE(isExplicitLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); } -TEST_F(EngineSyncTest, SetMasterWhilePlaying) { - // Make sure we don't get two master lights if we change masters while playing. +TEST_F(EngineSyncTest, SetLeaderWhilePlaying) { + // Make sure we don't get two leader lights if we change leaders while playing. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(120), mixxx::audio::kStartFramePos); m_pTrack1->trySetBeats(pBeats1); @@ -288,15 +288,15 @@ TEST_F(EngineSyncTest, SetMasterWhilePlaying) { m_pTrack3->getSampleRate(), mixxx::Bpm(128), mixxx::audio::kStartFramePos); m_pTrack3->trySetBeats(pBeats3); - auto pButtonMasterSync1 = + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); - pButtonMasterSync1->set(SYNC_MASTER_EXPLICIT); - auto pButtonMasterSync2 = + pButtonLeaderSync1->set(static_cast(SyncMode::LeaderExplicit)); + auto pButtonLeaderSync2 = std::make_unique(m_sGroup2, "sync_mode"); - pButtonMasterSync2->slotSet(SYNC_FOLLOWER); - auto pButtonMasterSync3 = + pButtonLeaderSync2->slotSet(static_cast(SyncMode::Follower)); + auto pButtonLeaderSync3 = std::make_unique(m_sGroup3, "sync_mode"); - pButtonMasterSync3->slotSet(SYNC_FOLLOWER); + pButtonLeaderSync3->slotSet(static_cast(SyncMode::Follower)); ControlObject::getControl(ConfigKey(m_sGroup1, "play"))->set(1.0); ControlObject::getControl(ConfigKey(m_sGroup2, "play"))->set(1.0); @@ -304,42 +304,42 @@ TEST_F(EngineSyncTest, SetMasterWhilePlaying) { ProcessBuffer(); - pButtonMasterSync3->slotSet(SYNC_MASTER_EXPLICIT); + pButtonLeaderSync3->slotSet(static_cast(SyncMode::LeaderExplicit)); ProcessBuffer(); EXPECT_TRUE(isFollower(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); - EXPECT_TRUE(isExplicitMaster(m_sGroup3)); + EXPECT_TRUE(isExplicitLeader(m_sGroup3)); } -TEST_F(EngineSyncTest, SetEnabledBecomesMaster) { - // If we set the first channel with a valid tempo to follower, it should be master. +TEST_F(EngineSyncTest, SetEnabledBecomesLeader) { + // If we set the first channel with a valid tempo to follower, it should be leader. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(80), mixxx::audio::kStartFramePos); m_pTrack1->trySetBeats(pBeats1); - auto pButtonMasterSync1 = + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); - pButtonMasterSync1->slotSet(SYNC_FOLLOWER); + pButtonLeaderSync1->slotSet(static_cast(SyncMode::Follower)); ProcessBuffer(); - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sInternalClockGroup)); } -TEST_F(EngineSyncTest, DisableInternalMasterWhilePlaying) { - auto pButtonMasterSync = std::make_unique( - m_sInternalClockGroup, "sync_master"); - pButtonMasterSync->slotSet(1.0); +TEST_F(EngineSyncTest, DisableInternalLeaderWhilePlaying) { + auto pButtonLeaderSync = std::make_unique( + m_sInternalClockGroup, "sync_leader"); + pButtonLeaderSync->slotSet(1.0); auto pButtonSyncMode1 = std::make_unique(m_sGroup1, "sync_mode"); - pButtonSyncMode1->slotSet(SYNC_FOLLOWER); + pButtonSyncMode1->slotSet(static_cast(SyncMode::Follower)); auto pButtonSyncMode2 = std::make_unique(m_sGroup2, "sync_mode"); - pButtonSyncMode2->slotSet(SYNC_FOLLOWER); + pButtonSyncMode2->slotSet(static_cast(SyncMode::Follower)); ProcessBuffer(); - // The master sync should now be Internal. - EXPECT_TRUE(isExplicitMaster(m_sInternalClockGroup)); + // The sync lock should now be Internal. + EXPECT_TRUE(isExplicitLeader(m_sInternalClockGroup)); // Make sure both decks are playing. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( @@ -352,70 +352,70 @@ TEST_F(EngineSyncTest, DisableInternalMasterWhilePlaying) { ControlObject::getControl(ConfigKey(m_sGroup2, "play"))->set(1.0); ProcessBuffer(); - // Now unset Internal master. - pButtonMasterSync->slotSet(0.0); + // Now unset Internal leader. + pButtonLeaderSync->slotSet(0.0); ProcessBuffer(); - // This is not allowed, Internal should still be master. + // This is not allowed, Internal should still be leader. EXPECT_TRUE(isFollower(m_sInternalClockGroup)); - EXPECT_EQ(0, pButtonMasterSync->get()); + EXPECT_EQ(0, pButtonLeaderSync->get()); } -TEST_F(EngineSyncTest, DisableSyncOnMaster) { - // Channel 1 follower, channel 2 master. +TEST_F(EngineSyncTest, DisableSyncOnLeader) { + // Channel 1 follower, channel 2 leader. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(130), mixxx::audio::kStartFramePos); m_pTrack1->trySetBeats(pBeats1); auto pButtonSyncMode1 = std::make_unique(m_sGroup1, "sync_mode"); - pButtonSyncMode1->slotSet(SYNC_FOLLOWER); + pButtonSyncMode1->slotSet(static_cast(SyncMode::Follower)); mixxx::BeatsPointer pBeats2 = BeatFactory::makeBeatGrid( m_pTrack2->getSampleRate(), mixxx::Bpm(130), mixxx::audio::kStartFramePos); m_pTrack2->trySetBeats(pBeats2); - // Set deck two to explicit master. - auto pButtonSyncMaster2 = - std::make_unique(m_sGroup2, "sync_master"); - pButtonSyncMaster2->slotSet(1.0); + // Set deck two to explicit leader. + auto pButtonSyncLeader2 = + std::make_unique(m_sGroup2, "sync_leader"); + pButtonSyncLeader2->slotSet(1.0); ProcessBuffer(); EXPECT_TRUE(isFollower(m_sGroup1)); - EXPECT_TRUE(isExplicitMaster(m_sGroup2)); + EXPECT_TRUE(isExplicitLeader(m_sGroup2)); - // Set deck 2 to playing, now it becomes explicit master. + // Set deck 2 to playing, now it becomes explicit leader. ControlObject::getControl(ConfigKey(m_sGroup2, "play"))->set(1.0); - // The request to become master is queued, so we have to process a buffer. + // The request to become leader is queued, so we have to process a buffer. ProcessBuffer(); EXPECT_TRUE(isFollower(m_sGroup1)); - EXPECT_TRUE(isExplicitMaster(m_sGroup2)); + EXPECT_TRUE(isExplicitLeader(m_sGroup2)); // Unset enabled on channel2, it should work. auto pButtonSyncEnabled2 = std::make_unique(m_sGroup2, "sync_enabled"); pButtonSyncEnabled2->slotSet(0.0); ProcessBuffer(); - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_EQ(0, ControlObject::getControl(ConfigKey(m_sGroup2, "sync_enabled"))->get()); - EXPECT_EQ(0, ControlObject::getControl(ConfigKey(m_sGroup2, "sync_master"))->get()); + EXPECT_EQ(0, ControlObject::getControl(ConfigKey(m_sGroup2, "sync_leader"))->get()); } -TEST_F(EngineSyncTest, InternalMasterSetFollowerSliderMoves) { - // If internal is master, and we turn on a follower, the slider should move. - auto pButtonMasterSyncInternal = std::make_unique( - m_sInternalClockGroup, "sync_master"); - auto pMasterSyncSlider = +TEST_F(EngineSyncTest, InternalLeaderSetFollowerSliderMoves) { + // If internal is leader, and we turn on a follower, the slider should move. + auto pButtonLeaderSyncInternal = std::make_unique( + m_sInternalClockGroup, "sync_leader"); + auto pLeaderSyncSlider = std::make_unique(m_sInternalClockGroup, "bpm"); - pMasterSyncSlider->set(100.0); - pButtonMasterSyncInternal->slotSet(1); + pLeaderSyncSlider->set(100.0); + pButtonLeaderSyncInternal->slotSet(1); // Set the file bpm of channel 1 to 80 bpm. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(80), mixxx::audio::kStartFramePos); m_pTrack1->trySetBeats(pBeats1); - auto pButtonMasterSync1 = + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); - pButtonMasterSync1->slotSet(SYNC_FOLLOWER); + pButtonLeaderSync1->slotSet(static_cast(SyncMode::Follower)); ProcessBuffer(); EXPECT_DOUBLE_EQ(getRateSliderValue(1.25), @@ -426,7 +426,7 @@ TEST_F(EngineSyncTest, InternalMasterSetFollowerSliderMoves) { TEST_F(EngineSyncTest, AnySyncDeckSliderStays) { // If there exists a sync deck, even if it's not playing, don't change the - // master BPM if a new deck enables sync. + // leader BPM if a new deck enables sync. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(80), mixxx::audio::kStartFramePos); @@ -455,9 +455,9 @@ TEST_F(EngineSyncTest, AnySyncDeckSliderStays) { TEST_F(EngineSyncTest, InternalClockFollowsFirstPlayingDeck) { // Same as above, except we use the midi lights to change state. - auto pButtonMasterSync1 = + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); - auto pButtonMasterSync2 = + auto pButtonLeaderSync2 = std::make_unique(m_sGroup2, "sync_mode"); auto pButtonSyncEnabled1 = std::make_unique(m_sGroup1, "sync_enabled"); @@ -481,8 +481,8 @@ TEST_F(EngineSyncTest, InternalClockFollowsFirstPlayingDeck) { pButtonSyncEnabled1->set(1.0); ProcessBuffer(); - // The master sync should now be deck 1. - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + // The sync lock should now be deck 1. + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_DOUBLE_EQ(130.0, ControlObject::get(ConfigKey(m_sInternalClockGroup, "bpm"))); @@ -490,8 +490,8 @@ TEST_F(EngineSyncTest, InternalClockFollowsFirstPlayingDeck) { pButtonSyncEnabled2->set(1); ProcessBuffer(); - // channel 1 still master while 2 is not playing - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + // channel 1 still leader while 2 is not playing + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sInternalClockGroup)); EXPECT_TRUE(isFollower(m_sGroup2)); @@ -503,17 +503,17 @@ TEST_F(EngineSyncTest, InternalClockFollowsFirstPlayingDeck) { ControlObject::set(ConfigKey(m_sGroup2, "rate"), getRateSliderValue(1.0)); ControlObject::set(ConfigKey(m_sGroup2, "play"), 1.0); ProcessBuffer(); - // Deck 1 still master + // Deck 1 still leader EXPECT_TRUE(isFollower(m_sInternalClockGroup)); - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); // Now disable sync on channel 1. pButtonSyncEnabled1->set(0); ProcessBuffer(); - // Master flips to deck 2 - EXPECT_TRUE(isSoftMaster(m_sGroup2)); + // Leader flips to deck 2 + EXPECT_TRUE(isSoftLeader(m_sGroup2)); EXPECT_TRUE(isFollower(m_sInternalClockGroup)); // Rate should now match channel 2. @@ -521,20 +521,20 @@ TEST_F(EngineSyncTest, InternalClockFollowsFirstPlayingDeck) { 130.0, ControlObject::get(ConfigKey(m_sInternalClockGroup, "bpm"))); } -TEST_F(EngineSyncTest, SetExplicitMasterByLights) { +TEST_F(EngineSyncTest, SetExplicitLeaderByLights) { // Same as above, except we use the midi lights to change state. - auto pButtonMasterSync1 = + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); - auto pButtonMasterSync2 = + auto pButtonLeaderSync2 = std::make_unique(m_sGroup2, "sync_mode"); auto pButtonSyncEnabled1 = std::make_unique(m_sGroup1, "sync_enabled"); auto pButtonSyncEnabled2 = std::make_unique(m_sGroup2, "sync_enabled"); - auto pButtonSyncMaster1 = - std::make_unique(m_sGroup1, "sync_master"); - auto pButtonSyncMaster2 = - std::make_unique(m_sGroup2, "sync_master"); + auto pButtonSyncLeader1 = + std::make_unique(m_sGroup1, "sync_leader"); + auto pButtonSyncLeader2 = + std::make_unique(m_sGroup2, "sync_leader"); // Set the file bpm of channel 1 to 160bpm. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( @@ -548,12 +548,12 @@ TEST_F(EngineSyncTest, SetExplicitMasterByLights) { ControlObject::set(ConfigKey(m_sGroup1, "play"), 1.0); ControlObject::set(ConfigKey(m_sGroup2, "play"), 1.0); - // Set channel 1 to be explicit master. - pButtonSyncMaster1->slotSet(1.0); + // Set channel 1 to be explicit leader. + pButtonSyncLeader1->slotSet(1.0); ProcessBuffer(); - // The master sync should now be channel 1. - EXPECT_TRUE(isExplicitMaster(m_sGroup1)); + // The sync lock should now be channel 1. + EXPECT_TRUE(isExplicitLeader(m_sGroup1)); // Set channel 2 to be follower. pButtonSyncEnabled2->slotSet(1); @@ -561,49 +561,49 @@ TEST_F(EngineSyncTest, SetExplicitMasterByLights) { EXPECT_TRUE(isFollower(m_sGroup2)); - // Now set channel 2 to be master. - pButtonSyncMaster2->slotSet(1); + // Now set channel 2 to be leader. + pButtonSyncLeader2->slotSet(1); ProcessBuffer(); - // Now channel 2 should be master, and channel 1 should be a follower. + // Now channel 2 should be leader, and channel 1 should be a follower. EXPECT_TRUE(isFollower(m_sGroup1)); - EXPECT_TRUE(isExplicitMaster(m_sGroup2)); + EXPECT_TRUE(isExplicitLeader(m_sGroup2)); // Now back again. - pButtonSyncMaster1->slotSet(1); + pButtonSyncLeader1->slotSet(1); ProcessBuffer(); - // Now channel 1 should be master, and channel 2 should be a follower. - EXPECT_TRUE(isExplicitMaster(m_sGroup1)); + // Now channel 1 should be leader, and channel 2 should be a follower. + EXPECT_TRUE(isExplicitLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); - // Now set channel 1 to not-master. The system will choose deck 2 as the next best - // option for soft master - pButtonSyncMaster1->slotSet(0); + // Now set channel 1 to not-leader. The system will choose deck 2 as the next best + // option for soft leader + pButtonSyncLeader1->slotSet(0); ProcessBuffer(); EXPECT_TRUE(isFollower(m_sInternalClockGroup)); - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); } -TEST_F(EngineSyncTest, SetExplicitMasterByLightsNoTracks) { +TEST_F(EngineSyncTest, SetExplicitLeaderByLightsNoTracks) { // Same as above, except we use the midi lights to change state. auto pButtonSyncEnabled2 = std::make_unique(m_sGroup2, "sync_enabled"); - auto pButtonSyncMaster1 = - std::make_unique(m_sGroup1, "sync_master"); + auto pButtonSyncLeader1 = + std::make_unique(m_sGroup1, "sync_leader"); - pButtonSyncMaster1->slotSet(1); + pButtonSyncLeader1->slotSet(1); // Set channel 2 to be follower. pButtonSyncEnabled2->slotSet(1); - // Without a track loaded, deck 1 can't be an explicit master. + // Without a track loaded, deck 1 can't be an explicit leader. EXPECT_TRUE(isFollower(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); - pButtonSyncMaster1->slotSet(0); + pButtonSyncLeader1->slotSet(0); EXPECT_TRUE(isFollower(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); @@ -611,12 +611,12 @@ TEST_F(EngineSyncTest, SetExplicitMasterByLightsNoTracks) { } TEST_F(EngineSyncTest, RateChangeTest) { - auto pButtonMasterSync1 = + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); - pButtonMasterSync1->set(SYNC_MASTER_EXPLICIT); - auto pButtonMasterSync2 = + pButtonLeaderSync1->set(static_cast(SyncMode::LeaderExplicit)); + auto pButtonLeaderSync2 = std::make_unique(m_sGroup2, "sync_mode"); - pButtonMasterSync2->set(SYNC_FOLLOWER); + pButtonLeaderSync2->set(static_cast(SyncMode::Follower)); ProcessBuffer(); // Set the file bpm of channel 1 to 160bpm. @@ -635,7 +635,7 @@ TEST_F(EngineSyncTest, RateChangeTest) { ControlObject::get(ConfigKey(m_sGroup1, "rate"))); EXPECT_DOUBLE_EQ(192.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm"))); - // Internal master should also be 192. + // Internal leader should also be 192. EXPECT_DOUBLE_EQ( 192.0, ControlObject::get(ConfigKey(m_sInternalClockGroup, "bpm"))); @@ -654,12 +654,12 @@ TEST_F(EngineSyncTest, RateChangeTest) { TEST_F(EngineSyncTest, RateChangeTestWeirdOrder) { // This is like the test above, but the user loads the track after the slider has been tweaked. - auto pButtonMasterSync1 = + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); - pButtonMasterSync1->slotSet(SYNC_MASTER_EXPLICIT); - auto pButtonMasterSync2 = + pButtonLeaderSync1->slotSet(static_cast(SyncMode::LeaderExplicit)); + auto pButtonLeaderSync2 = std::make_unique(m_sGroup2, "sync_mode"); - pButtonMasterSync2->slotSet(SYNC_FOLLOWER); + pButtonLeaderSync2->slotSet(static_cast(SyncMode::Follower)); ProcessBuffer(); // Set the file bpm of channel 1 to 160bpm. @@ -682,7 +682,7 @@ TEST_F(EngineSyncTest, RateChangeTestWeirdOrder) { ControlObject::get(ConfigKey(m_sGroup2, "rate"))); EXPECT_DOUBLE_EQ(192.0, ControlObject::get(ConfigKey(m_sGroup2, "bpm"))); - // Internal Master BPM should read the same. + // Internal Leader BPM should read the same. EXPECT_DOUBLE_EQ( 192.0, ControlObject::get(ConfigKey(m_sInternalClockGroup, "bpm"))); } @@ -702,19 +702,19 @@ TEST_F(EngineSyncTest, RateChangeTestOrder3) { EXPECT_DOUBLE_EQ( 120.0, ControlObject::get(ConfigKey(m_sGroup2, "file_bpm"))); - // Turn on Master. Setting explicit master causes this track's rate to be adopted instead + // Turn on Leader. Setting explicit leader causes this track's rate to be adopted instead // of matching against the other deck. - auto pButtonMasterSync1 = + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); - pButtonMasterSync1->set(SYNC_MASTER_EXPLICIT); + pButtonLeaderSync1->set(static_cast(SyncMode::LeaderExplicit)); ProcessBuffer(); - EXPECT_TRUE(isExplicitMaster(m_sGroup1)); + EXPECT_TRUE(isExplicitLeader(m_sGroup1)); EXPECT_DOUBLE_EQ(160.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm"))); // Turn on follower. - auto pButtonMasterSync2 = + auto pButtonLeaderSync2 = std::make_unique(m_sGroup2, "sync_mode"); - pButtonMasterSync2->set(SYNC_FOLLOWER); + pButtonLeaderSync2->set(static_cast(SyncMode::Follower)); ProcessBuffer(); // Follower should immediately set its slider. @@ -727,13 +727,13 @@ TEST_F(EngineSyncTest, RateChangeTestOrder3) { } TEST_F(EngineSyncTest, FollowerRateChange) { - // Confirm that followers can change master sync rate as well. - auto pButtonMasterSync1 = + // Confirm that followers can change sync lock rate as well. + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); - pButtonMasterSync1->set(SYNC_MASTER_EXPLICIT); - auto pButtonMasterSync2 = + pButtonLeaderSync1->set(static_cast(SyncMode::LeaderExplicit)); + auto pButtonLeaderSync2 = std::make_unique(m_sGroup2, "sync_mode"); - pButtonMasterSync2->set(SYNC_FOLLOWER); + pButtonLeaderSync2->set(static_cast(SyncMode::Follower)); ProcessBuffer(); // Set the file bpm of channel 1 to 160bpm. @@ -769,18 +769,18 @@ TEST_F(EngineSyncTest, FollowerRateChange) { } TEST_F(EngineSyncTest, InternalRateChangeTest) { - auto pButtonMasterSyncInternal = std::make_unique( - m_sInternalClockGroup, "sync_master"); - pButtonMasterSyncInternal->set(1.0); - auto pButtonMasterSync1 = + auto pButtonLeaderSyncInternal = std::make_unique( + m_sInternalClockGroup, "sync_leader"); + pButtonLeaderSyncInternal->set(1.0); + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); - pButtonMasterSync1->set(SYNC_FOLLOWER); - auto pButtonMasterSync2 = + pButtonLeaderSync1->set(static_cast(SyncMode::Follower)); + auto pButtonLeaderSync2 = std::make_unique(m_sGroup2, "sync_mode"); - pButtonMasterSync2->set(SYNC_FOLLOWER); + pButtonLeaderSync2->set(static_cast(SyncMode::Follower)); ProcessBuffer(); - EXPECT_TRUE(isExplicitMaster(m_sInternalClockGroup)); + EXPECT_TRUE(isExplicitLeader(m_sInternalClockGroup)); EXPECT_TRUE(isFollower(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); @@ -799,9 +799,9 @@ TEST_F(EngineSyncTest, InternalRateChangeTest) { ControlObject::getControl(ConfigKey(m_sGroup2, "file_bpm"))->get()); // Set the internal rate to 150. - auto pMasterSyncSlider = + auto pLeaderSyncSlider = std::make_unique(m_sInternalClockGroup, "bpm"); - pMasterSyncSlider->set(150.0); + pLeaderSyncSlider->set(150.0); EXPECT_DOUBLE_EQ(150.0, ControlObject::getControl(ConfigKey(m_sInternalClockGroup, "bpm")) ->get()); @@ -820,7 +820,7 @@ TEST_F(EngineSyncTest, InternalRateChangeTest) { ControlObject::getControl(ConfigKey(m_sGroup2, "bpm"))->get()); // Set the internal rate to 140. - pMasterSyncSlider->set(140.0); + pLeaderSyncSlider->set(140.0); // Update COs again. ProcessBuffer(); @@ -837,8 +837,8 @@ TEST_F(EngineSyncTest, InternalRateChangeTest) { ControlObject::getControl(ConfigKey(m_sGroup2, "bpm"))->get()); } -TEST_F(EngineSyncTest, MasterStopSliderCheck) { - // If the master is playing, and stop is pushed, the sliders should stay the same. +TEST_F(EngineSyncTest, LeaderStopSliderCheck) { + // If the leader is playing, and stop is pushed, the sliders should stay the same. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(120), mixxx::audio::kStartFramePos); m_pTrack1->trySetBeats(pBeats1); @@ -846,15 +846,15 @@ TEST_F(EngineSyncTest, MasterStopSliderCheck) { m_pTrack2->getSampleRate(), mixxx::Bpm(128), mixxx::audio::kStartFramePos); m_pTrack2->trySetBeats(pBeats2); - auto pButtonMasterSync1 = + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); - pButtonMasterSync1->slotSet(SYNC_MASTER_EXPLICIT); - auto pButtonMasterSync2 = + pButtonLeaderSync1->slotSet(static_cast(SyncMode::LeaderExplicit)); + auto pButtonLeaderSync2 = std::make_unique(m_sGroup2, "sync_mode"); - pButtonMasterSync2->slotSet(SYNC_FOLLOWER); + pButtonLeaderSync2->slotSet(static_cast(SyncMode::Follower)); ProcessBuffer(); - //EXPECT_TRUE(isExplicitMaster(m_sGroup1)); + //EXPECT_TRUE(isExplicitLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); auto pChannel1Play = std::make_unique(m_sGroup1, "play"); @@ -877,9 +877,9 @@ TEST_F(EngineSyncTest, MasterStopSliderCheck) { ControlObject::get(ConfigKey(m_sGroup2, "rate"))); } -TEST_F(EngineSyncTest, EnableOneDeckInitsMaster) { - // If Internal is master, and we turn sync on a playing deck, the playing deck sets the - // internal master and the beat distances are now aligned. +TEST_F(EngineSyncTest, EnableOneDeckInitsLeader) { + // If Internal is leader, and we turn sync on a playing deck, the playing deck sets the + // internal leader and the beat distances are now aligned. ControlObject::set(ConfigKey(m_sInternalClockGroup, "bpm"), 124.0); ControlObject::set(ConfigKey(m_sInternalClockGroup, "beat_distance"), 0.5); ProcessBuffer(); @@ -896,10 +896,10 @@ TEST_F(EngineSyncTest, EnableOneDeckInitsMaster) { // Enable Sync. We have to call requestEnableSync directly // because calling ProcessBuffer() tries to advance the beat_distance values. m_pEngineSync->requestSyncMode( - m_pEngineSync->getSyncableForGroup(m_sGroup1), SYNC_FOLLOWER); + m_pEngineSync->getSyncableForGroup(m_sGroup1), SyncMode::Follower); - // Internal is no longer master because there is exactly one playing deck. - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + // Internal is no longer leader because there is exactly one playing deck. + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sInternalClockGroup)); // Internal clock rate and beat distance should match that deck. @@ -922,10 +922,10 @@ TEST_F(EngineSyncTest, EnableOneDeckInitsMaster) { ControlObject::getControl(ConfigKey(m_sGroup2, "play"))->set(1.0); m_pEngineSync->requestSyncMode( - m_pEngineSync->getSyncableForGroup(m_sGroup2), SYNC_FOLLOWER); - // Deck 1 is still soft master. + m_pEngineSync->getSyncableForGroup(m_sGroup2), SyncMode::Follower); + // Deck 1 is still soft leader. EXPECT_TRUE(isFollower(m_sInternalClockGroup)); - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); EXPECT_DOUBLE_EQ( @@ -961,8 +961,8 @@ TEST_F(EngineSyncTest, MomentarySyncAlgorithmTwo) { EXPECT_DOUBLE_EQ(128.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm"))); } -TEST_F(EngineSyncTest, EnableOneDeckInitializesMaster) { - // Enabling sync on a deck causes it to be master, and sets bpm and clock. +TEST_F(EngineSyncTest, EnableOneDeckInitializesLeader) { + // Enabling sync on a deck causes it to be leader, and sets bpm and clock. // Set the deck to play. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(130), mixxx::audio::kStartFramePos); @@ -975,10 +975,10 @@ TEST_F(EngineSyncTest, EnableOneDeckInitializesMaster) { // Set the deck to follower. // As above, use direct call to avoid advancing beat distance. m_pEngineSync->requestSyncMode( - m_pEngineSync->getSyncableForGroup(m_sGroup1), SYNC_FOLLOWER); + m_pEngineSync->getSyncableForGroup(m_sGroup1), SyncMode::Follower); - // That first deck is now master - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + // That first deck is now leader + EXPECT_TRUE(isSoftLeader(m_sGroup1)); // Internal clock rate should be set and beat distances reset. EXPECT_DOUBLE_EQ(130.0, @@ -995,7 +995,7 @@ TEST_F(EngineSyncTest, EnableOneDeckInitializesMaster) { ->get()); } -TEST_F(EngineSyncTest, LoadTrackInitializesMaster) { +TEST_F(EngineSyncTest, LoadTrackInitializesLeader) { // First eject the fake tracks that come with the testing framework. m_pChannel1->getEngineBuffer()->slotEjectTrack(1.0); m_pChannel2->getEngineBuffer()->slotEjectTrack(1.0); @@ -1005,24 +1005,24 @@ TEST_F(EngineSyncTest, LoadTrackInitializesMaster) { std::make_unique(m_sGroup1, "sync_enabled"); pButtonSyncEnabled1->slotSet(1.0); - // No master because this deck has no track. - EXPECT_EQ(NULL, m_pEngineSync->getMaster()); + // No leader because this deck has no track. + EXPECT_EQ(NULL, m_pEngineSync->getLeader()); EXPECT_DOUBLE_EQ( 0.0, ControlObject::getControl(ConfigKey(m_sGroup1, "bpm"))->get()); - // The track load trigger a master change. + // The track load trigger a leader change. m_pMixerDeck1->loadFakeTrack(false, 140.0); - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_DOUBLE_EQ(140.0, ControlObject::getControl(ConfigKey(m_sGroup1, "bpm"))->get()); - // But as soon as we play, deck 1 is master + // But as soon as we play, deck 1 is leader ControlObject::getControl(ConfigKey(m_sGroup1, "play"))->set(1.0); - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); ControlObject::getControl(ConfigKey(m_sGroup1, "play"))->set(0.0); // If sync is on two decks and we load a track in only one of them, it will be - // master. + // leader. m_pChannel1->getEngineBuffer()->slotEjectTrack(1.0); EXPECT_TRUE(isFollower(m_sGroup1)); // no relevant tempo available so internal clock is following @@ -1034,13 +1034,13 @@ TEST_F(EngineSyncTest, LoadTrackInitializesMaster) { m_pMixerDeck1->loadFakeTrack(false, 128.0); - // Deck 2 is still empty so Deck 1 becomes master again - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + // Deck 2 is still empty so Deck 1 becomes leader again + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_DOUBLE_EQ(128.0, ControlObject::getControl(ConfigKey(m_sGroup1, "bpm"))->get()); // If sync is on two decks and one deck is loaded but not playing, we should - // initialize to that deck with internal clock master. + // initialize to that deck with internal clock leader. m_pMixerDeck2->loadFakeTrack(false, 110.0); EXPECT_TRUE(isFollower(m_sInternalClockGroup)); @@ -1054,9 +1054,9 @@ TEST_F(EngineSyncTest, LoadTrackInitializesMaster) { } TEST_F(EngineSyncTest, LoadTrackResetTempoOption) { - // Make sure playing decks with master sync enabled do not change tempo when + // Make sure playing decks with sync lock enabled do not change tempo when // the "Reset Speed/Tempo" preference is set and a track is loaded to another - // deck with master sync enabled. + // deck with sync lock enabled. m_pConfig->set(ConfigKey("[Controls]", "SpeedAutoReset"), ConfigValue(BaseTrackPlayer::RESET_SPEED)); @@ -1069,13 +1069,13 @@ TEST_F(EngineSyncTest, LoadTrackResetTempoOption) { std::make_unique(m_sGroup2, "sync_enabled"); pButtonSyncEnabled2->set(1.0); - // If sync is on and we load a track, that should initialize master. + // If sync is on and we load a track, that should initialize leader. TrackPointer track1 = m_pMixerDeck1->loadFakeTrack(false, 140.0); EXPECT_DOUBLE_EQ( 140.0, ControlObject::get(ConfigKey(m_sInternalClockGroup, "bpm"))); EXPECT_DOUBLE_EQ(140.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm"))); - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); // If sync is on two decks and we load a track while one is playing, // that should not change the playing deck. @@ -1151,7 +1151,7 @@ TEST_F(EngineSyncTest, LoadTrackResetTempoOption) { } TEST_F(EngineSyncTest, EnableOneDeckSliderUpdates) { - // If we enable a deck to be master, the internal slider should immediately update. + // If we enable a deck to be leader, the internal slider should immediately update. auto pButtonSyncEnabled1 = std::make_unique(m_sGroup1, "sync_enabled"); @@ -1165,8 +1165,8 @@ TEST_F(EngineSyncTest, EnableOneDeckSliderUpdates) { pButtonSyncEnabled1->slotSet(1.0); ProcessBuffer(); - // Group 1 should now be master (only one sync deck). - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + // Group 1 should now be leader (only one sync deck). + EXPECT_TRUE(isSoftLeader(m_sGroup1)); // Internal clock rate should be set. EXPECT_DOUBLE_EQ(130.0, @@ -1202,9 +1202,9 @@ TEST_F(EngineSyncTest, SyncToNonSyncDeck) { pButtonSyncEnabled2->set(0.0); ProcessBuffer(); - // There should be no master, and deck2 should match rate of deck1. Sync slider should be + // There should be no leader, and deck2 should match rate of deck1. Sync slider should be // updated with the value, however. - assertNoMaster(); + assertNoLeader(); EXPECT_DOUBLE_EQ( 130.0, ControlObject::get(ConfigKey(m_sInternalClockGroup, "bpm"))); assertSyncOff(m_sGroup2); @@ -1219,17 +1219,18 @@ TEST_F(EngineSyncTest, SyncToNonSyncDeck) { pButtonSyncEnabled1->set(0.0); ProcessBuffer(); - // There should be no master, and deck2 should match rate of deck1. + // There should be no leader, and deck2 should match rate of deck1. EXPECT_EQ(0, ControlObject::get( - ConfigKey(m_sInternalClockGroup, "sync_master"))); + ConfigKey(m_sInternalClockGroup, "sync_leader"))); EXPECT_DOUBLE_EQ( 100.0, ControlObject::get(ConfigKey(m_sInternalClockGroup, "bpm"))); - EXPECT_EQ(NULL, m_pEngineSync->getMaster()); - EXPECT_EQ(NULL, m_pEngineSync->getMasterSyncable()); - EXPECT_EQ(SYNC_NONE, ControlObject::get(ConfigKey(m_sGroup1, "sync_mode"))); + EXPECT_EQ(NULL, m_pEngineSync->getLeader()); + EXPECT_EQ(NULL, m_pEngineSync->getLeaderSyncable()); + EXPECT_EQ(static_cast(SyncMode::None), + ControlObject::get(ConfigKey(m_sGroup1, "sync_mode"))); EXPECT_EQ(0, ControlObject::get(ConfigKey(m_sGroup1, "sync_enabled"))); - EXPECT_EQ(0, ControlObject::get(ConfigKey(m_sGroup1, "sync_master"))); + EXPECT_EQ(0, ControlObject::get(ConfigKey(m_sGroup1, "sync_leader"))); EXPECT_DOUBLE_EQ(getRateSliderValue(100.0 / 130.0), ControlObject::get(ConfigKey(m_sGroup1, "rate"))); @@ -1244,17 +1245,18 @@ TEST_F(EngineSyncTest, SyncToNonSyncDeck) { pButtonSyncEnabled1->set(0.0); ProcessBuffer(); - // There should be no master, and deck2 should match rate of deck1. + // There should be no leader, and deck2 should match rate of deck1. EXPECT_EQ(0, ControlObject::get( - ConfigKey(m_sInternalClockGroup, "sync_master"))); + ConfigKey(m_sInternalClockGroup, "sync_leader"))); EXPECT_DOUBLE_EQ( 100.0, ControlObject::get(ConfigKey(m_sInternalClockGroup, "bpm"))); - EXPECT_EQ(NULL, m_pEngineSync->getMaster()); - EXPECT_EQ(NULL, m_pEngineSync->getMasterSyncable()); - EXPECT_EQ(SYNC_NONE, ControlObject::get(ConfigKey(m_sGroup2, "sync_mode"))); + EXPECT_EQ(NULL, m_pEngineSync->getLeader()); + EXPECT_EQ(NULL, m_pEngineSync->getLeaderSyncable()); + EXPECT_EQ(static_cast(SyncMode::None), + ControlObject::get(ConfigKey(m_sGroup2, "sync_mode"))); EXPECT_EQ(0, ControlObject::get(ConfigKey(m_sGroup2, "sync_enabled"))); - EXPECT_EQ(0, ControlObject::get(ConfigKey(m_sGroup2, "sync_master"))); + EXPECT_EQ(0, ControlObject::get(ConfigKey(m_sGroup2, "sync_leader"))); EXPECT_DOUBLE_EQ(getRateSliderValue(1.0), ControlObject::get(ConfigKey(m_sGroup2, "rate"))); } @@ -1287,8 +1289,8 @@ TEST_F(EngineSyncTest, MomentarySyncDependsOnPlayingStates) { pButtonSyncEnabled1->set(0.0); ProcessBuffer(); - // The master sync should still be off and the speed should match deck 2. - assertNoMaster(); + // The sync lock should still be off and the speed should match deck 2. + assertNoLeader(); assertSyncOff(m_sGroup1); assertSyncOff(m_sGroup2); EXPECT_DOUBLE_EQ( @@ -1302,7 +1304,7 @@ TEST_F(EngineSyncTest, MomentarySyncDependsOnPlayingStates) { pButtonSyncEnabled1->set(1.0); pButtonSyncEnabled1->set(0.0); ProcessBuffer(); - assertNoMaster(); + assertNoLeader(); assertSyncOff(m_sGroup1); assertSyncOff(m_sGroup2); EXPECT_DOUBLE_EQ( @@ -1316,7 +1318,7 @@ TEST_F(EngineSyncTest, MomentarySyncDependsOnPlayingStates) { pButtonSyncEnabled1->set(1.0); pButtonSyncEnabled1->set(0.0); ProcessBuffer(); - assertNoMaster(); + assertNoLeader(); assertSyncOff(m_sGroup1); assertSyncOff(m_sGroup2); EXPECT_DOUBLE_EQ( @@ -1331,7 +1333,7 @@ TEST_F(EngineSyncTest, MomentarySyncDependsOnPlayingStates) { pButtonSyncEnabled1->set(1.0); pButtonSyncEnabled1->set(0.0); ProcessBuffer(); - assertNoMaster(); + assertNoLeader(); assertSyncOff(m_sGroup1); assertSyncOff(m_sGroup2); EXPECT_DOUBLE_EQ( @@ -1353,7 +1355,7 @@ TEST_F(EngineSyncTest, EjectTrackSyncRemains) { // m_sGroup1 takes over EXPECT_TRUE(isFollower(m_sInternalClockGroup)); - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); assertSyncOff(m_sGroup2); pButtonEject1->set(1.0); @@ -1378,7 +1380,7 @@ TEST_F(EngineSyncTest, EjectTrackSyncRemains) { ProcessBuffer(); EXPECT_TRUE(isFollower(m_sInternalClockGroup)); - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); pButtonEject1->set(1.0); @@ -1387,11 +1389,11 @@ TEST_F(EngineSyncTest, EjectTrackSyncRemains) { EXPECT_TRUE(isFollower(m_sInternalClockGroup)); EXPECT_TRUE(isFollower(m_sGroup1)); - EXPECT_TRUE(isSoftMaster(m_sGroup2)); + EXPECT_TRUE(isSoftLeader(m_sGroup2)); } -TEST_F(EngineSyncTest, FileBpmChangesDontAffectMaster) { - // If filebpm changes, don't treat it like a rate change unless it's the master. +TEST_F(EngineSyncTest, FileBpmChangesDontAffectLeader) { + // If filebpm changes, don't treat it like a rate change unless it's the leader. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(100), mixxx::audio::kStartFramePos); m_pTrack1->trySetBeats(pBeats1); @@ -1408,17 +1410,17 @@ TEST_F(EngineSyncTest, FileBpmChangesDontAffectMaster) { pButtonSyncEnabled2->set(1.0); ProcessBuffer(); - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); - // Update the master's beats -- update the internal clock + // Update the leader's beats -- update the internal clock pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(160), mixxx::audio::kStartFramePos); m_pTrack1->trySetBeats(pBeats1); EXPECT_DOUBLE_EQ( 160.0, ControlObject::get(ConfigKey(m_sInternalClockGroup, "bpm"))); - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); // Update follower beats -- don't update internal clock. pBeats2 = BeatFactory::makeBeatGrid( @@ -1428,12 +1430,12 @@ TEST_F(EngineSyncTest, FileBpmChangesDontAffectMaster) { 160.0, ControlObject::get(ConfigKey(m_sInternalClockGroup, "bpm"))); } -TEST_F(EngineSyncTest, ExplicitMasterPostProcessed) { - // Regression test thanks to a bug. Make sure that an explicit master +TEST_F(EngineSyncTest, ExplicitLeaderPostProcessed) { + // Regression test thanks to a bug. Make sure that an explicit leader // channel gets post-processed. - auto pButtonMasterSync1 = + auto pButtonLeaderSync1 = std::make_unique(m_sGroup1, "sync_mode"); - pButtonMasterSync1->slotSet(SYNC_MASTER_EXPLICIT); + pButtonLeaderSync1->slotSet(static_cast(SyncMode::LeaderExplicit)); mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(160), mixxx::audio::kStartFramePos); m_pTrack1->trySetBeats(pBeats1); @@ -1473,10 +1475,10 @@ TEST_F(EngineSyncTest, ZeroBPMRateAdjustIgnored) { EXPECT_DOUBLE_EQ(getRateSliderValue(1.0), ControlObject::getControl(ConfigKey(m_sGroup2, "rate"))->get()); - // Also try with explicit master/follower setting + // Also try with explicit leader/follower setting pButtonSyncEnabled1->set(0.0); ControlObject::getControl(ConfigKey(m_sGroup1, "sync_mode")) - ->set(SYNC_MASTER_EXPLICIT); + ->set(static_cast(SyncMode::LeaderExplicit)); ControlObject::getControl(ConfigKey(m_sGroup1, "rate")) ->set(getRateSliderValue(1.4)); @@ -1485,7 +1487,7 @@ TEST_F(EngineSyncTest, ZeroBPMRateAdjustIgnored) { pButtonSyncEnabled1->set(0.0); ControlObject::getControl(ConfigKey(m_sGroup1, "sync_mode")) - ->set(SYNC_FOLLOWER); + ->set(static_cast(SyncMode::Follower)); ControlObject::getControl(ConfigKey(m_sGroup1, "rate")) ->set(getRateSliderValue(0.9)); @@ -1514,7 +1516,7 @@ TEST_F(EngineSyncTest, BeatDistanceBeforeStart) { } TEST_F(EngineSyncTest, ZeroLatencyRateChangeNoQuant) { - // Confirm that a rate change in an explicit master is instantly communicated + // Confirm that a rate change in an explicit leader is instantly communicated // to followers. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(128), mixxx::audio::kStartFramePos); @@ -1523,11 +1525,11 @@ TEST_F(EngineSyncTest, ZeroLatencyRateChangeNoQuant) { m_pTrack2->getSampleRate(), mixxx::Bpm(160), mixxx::audio::kStartFramePos); m_pTrack2->trySetBeats(pBeats2); - // Make Channel2 master to weed out any channel ordering issues. + // Make Channel2 leader to weed out any channel ordering issues. ControlObject::getControl(ConfigKey(m_sGroup2, "sync_mode")) - ->set(SYNC_FOLLOWER); + ->set(static_cast(SyncMode::Follower)); ControlObject::getControl(ConfigKey(m_sGroup1, "sync_mode")) - ->set(SYNC_FOLLOWER); + ->set(static_cast(SyncMode::Follower)); // Exaggerate the effect with a high rate. ControlObject::set(ConfigKey(m_sGroup2, "rate_ratio"), 10.0); @@ -1564,7 +1566,7 @@ TEST_F(EngineSyncTest, ZeroLatencyRateChangeNoQuant) { } TEST_F(EngineSyncTest, ZeroLatencyRateChangeQuant) { - // Confirm that a rate change in an explicit master is instantly communicated + // Confirm that a rate change in an explicit leader is instantly communicated // to followers. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(128), mixxx::audio::kStartFramePos); @@ -1576,11 +1578,11 @@ TEST_F(EngineSyncTest, ZeroLatencyRateChangeQuant) { ControlObject::getControl(ConfigKey(m_sGroup1, "quantize"))->set(1.0); ControlObject::getControl(ConfigKey(m_sGroup2, "quantize"))->set(1.0); - // Make Channel2 master to weed out any channel ordering issues. + // Make Channel2 leader to weed out any channel ordering issues. ControlObject::getControl(ConfigKey(m_sGroup2, "sync_mode")) - ->set(SYNC_FOLLOWER); + ->set(static_cast(SyncMode::Follower)); ControlObject::getControl(ConfigKey(m_sGroup1, "sync_mode")) - ->set(SYNC_FOLLOWER); + ->set(static_cast(SyncMode::Follower)); // Exaggerate the effect with a high rate. ControlObject::set(ConfigKey(m_sGroup2, "rate_ratio"), 10.0); @@ -1619,7 +1621,7 @@ TEST_F(EngineSyncTest, ZeroLatencyRateChangeQuant) { } TEST_F(EngineSyncTest, ZeroLatencyRateDiffQuant) { - // Confirm that a rate change in an explicit master is instantly communicated + // Confirm that a rate change in an explicit leader is instantly communicated // to followers. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(128), mixxx::audio::kStartFramePos); @@ -1630,11 +1632,11 @@ TEST_F(EngineSyncTest, ZeroLatencyRateDiffQuant) { ControlObject::getControl(ConfigKey(m_sGroup2, "quantize"))->set(1.0); - // Make Channel2 master to weed out any channel ordering issues. + // Make Channel2 leader to weed out any channel ordering issues. ControlObject::getControl(ConfigKey(m_sGroup2, "sync_mode")) - ->set(SYNC_FOLLOWER); + ->set(static_cast(SyncMode::Follower)); ControlObject::getControl(ConfigKey(m_sGroup1, "sync_mode")) - ->set(SYNC_FOLLOWER); + ->set(static_cast(SyncMode::Follower)); // Exaggerate the effect with a high rate. ControlObject::set(ConfigKey(m_sGroup2, "rate_ratio"), 10.0); @@ -1672,7 +1674,7 @@ TEST_F(EngineSyncTest, ZeroLatencyRateDiffQuant) { kMaxBeatDistanceEpsilon); } -// In this test, we set play *first* and then turn on master sync. +// In this test, we set play *first* and then turn on sync lock. // This exercises a slightly different ordering of signals that we // need to check. The Sync feature is unfortunately brittle. // This test exercises https://bugs.launchpad.net/mixxx/+bug/1884324 @@ -1698,13 +1700,13 @@ TEST_F(EngineSyncTest, ActivatingSyncDoesNotCauseDrifting) { ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance")) ->get()); - // engage first sync-master + // engage first sync-leader ControlObject::getControl(ConfigKey(m_sGroup1, "sync_mode")) - ->set(SYNC_FOLLOWER); + ->set(static_cast(SyncMode::Follower)); - // engage second Sync-master + // engage second Sync-leader ControlObject::getControl(ConfigKey(m_sGroup2, "sync_mode")) - ->set(SYNC_FOLLOWER); + ->set(static_cast(SyncMode::Follower)); // Run for a number of buffers for (int i = 0; i < 25; ++i) { @@ -1730,7 +1732,7 @@ TEST_F(EngineSyncTest, HalfDoubleBpmTest) { m_pTrack2->getSampleRate(), mixxx::Bpm(140), mixxx::audio::kStartFramePos); m_pTrack2->trySetBeats(pBeats2); - // Mixxx will choose the first playing deck to be master. Let's start deck 2 first. + // Mixxx will choose the first playing deck to be leader. Let's start deck 2 first. ControlObject::getControl(ConfigKey(m_sGroup1, "volume"))->set(1.0); ControlObject::getControl(ConfigKey(m_sGroup2, "volume"))->set(1.0); ProcessBuffer(); @@ -1743,15 +1745,15 @@ TEST_F(EngineSyncTest, HalfDoubleBpmTest) { ControlObject::getControl(ConfigKey(m_sGroup1, "play"))->set(1.0); ProcessBuffer(); - ASSERT_TRUE(isSoftMaster(m_sGroup2)); + ASSERT_TRUE(isSoftLeader(m_sGroup2)); ASSERT_TRUE(isFollower(m_sGroup1)); EXPECT_EQ(0.5, m_pChannel1->getEngineBuffer() - ->m_pSyncControl->m_masterBpmAdjustFactor); + ->m_pSyncControl->m_leaderBpmAdjustFactor); EXPECT_EQ(1.0, m_pChannel2->getEngineBuffer() - ->m_pSyncControl->m_masterBpmAdjustFactor); + ->m_pSyncControl->m_leaderBpmAdjustFactor); EXPECT_DOUBLE_EQ( m_pChannel1->getEngineBuffer()->m_pSyncControl->getBeatDistance(), m_pChannel2->getEngineBuffer()->m_pSyncControl->getBeatDistance()); @@ -1775,21 +1777,21 @@ TEST_F(EngineSyncTest, HalfDoubleBpmTest) { ControlObject::getControl(ConfigKey(m_sGroup2, "play"))->set(0.0); ControlObject::getControl(ConfigKey(m_sGroup1, "sync_mode")) - ->set(SYNC_NONE); + ->set(static_cast(SyncMode::None)); ControlObject::getControl(ConfigKey(m_sGroup2, "sync_mode")) - ->set(SYNC_NONE); + ->set(static_cast(SyncMode::None)); EXPECT_EQ(1.0, m_pChannel1->getEngineBuffer() - ->m_pSyncControl->m_masterBpmAdjustFactor); + ->m_pSyncControl->m_leaderBpmAdjustFactor); EXPECT_EQ(1.0, m_pChannel2->getEngineBuffer() - ->m_pSyncControl->m_masterBpmAdjustFactor); + ->m_pSyncControl->m_leaderBpmAdjustFactor); ControlObject::getControl(ConfigKey(m_sGroup1, "sync_mode")) - ->set(SYNC_FOLLOWER); + ->set(static_cast(SyncMode::Follower)); ControlObject::getControl(ConfigKey(m_sGroup2, "sync_mode")) - ->set(SYNC_FOLLOWER); + ->set(static_cast(SyncMode::Follower)); ControlObject::getControl(ConfigKey(m_sGroup1, "rate")) ->set(getRateSliderValue(1.0)); @@ -1801,10 +1803,10 @@ TEST_F(EngineSyncTest, HalfDoubleBpmTest) { EXPECT_EQ(1.0, m_pChannel1->getEngineBuffer() - ->m_pSyncControl->m_masterBpmAdjustFactor); + ->m_pSyncControl->m_leaderBpmAdjustFactor); EXPECT_EQ(2.0, m_pChannel2->getEngineBuffer() - ->m_pSyncControl->m_masterBpmAdjustFactor); + ->m_pSyncControl->m_leaderBpmAdjustFactor); // Exaggerate the effect with a high rate. ControlObject::getControl(ConfigKey(m_sGroup2, "rate")) @@ -1842,16 +1844,16 @@ TEST_F(EngineSyncTest, HalfDoubleThenPlay) { ControlObject::getControl(ConfigKey(m_sGroup1, "quantize"))->set(1.0); ControlObject::getControl(ConfigKey(m_sGroup2, "quantize"))->set(1.0); - // We expect that m_sGroup1 has adjusted its own bpm to the second deck and becomes a single master. + // We expect that m_sGroup1 has adjusted its own bpm to the second deck and becomes a single leader. // The internal clock is initialized right away. - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); EXPECT_DOUBLE_EQ(1.0, m_pChannel1->getEngineBuffer() - ->m_pSyncControl->m_masterBpmAdjustFactor); + ->m_pSyncControl->m_leaderBpmAdjustFactor); EXPECT_DOUBLE_EQ(2.0, m_pChannel2->getEngineBuffer() - ->m_pSyncControl->m_masterBpmAdjustFactor); + ->m_pSyncControl->m_leaderBpmAdjustFactor); EXPECT_DOUBLE_EQ(87.5, ControlObject::getControl(ConfigKey(m_sInternalClockGroup, "bpm")) ->get()); @@ -1903,10 +1905,10 @@ TEST_F(EngineSyncTest, HalfDoubleThenPlay) { pButtonSyncEnabled1->slotSet(1.0); EXPECT_DOUBLE_EQ(0.5, m_pChannel1->getEngineBuffer() - ->m_pSyncControl->m_masterBpmAdjustFactor); + ->m_pSyncControl->m_leaderBpmAdjustFactor); EXPECT_DOUBLE_EQ(1.0, m_pChannel2->getEngineBuffer() - ->m_pSyncControl->m_masterBpmAdjustFactor); + ->m_pSyncControl->m_leaderBpmAdjustFactor); ControlObject::getControl(ConfigKey(m_sGroup1, "play"))->set(1.0); ControlObject::getControl(ConfigKey(m_sGroup2, "play"))->set(1.0); @@ -1956,7 +1958,7 @@ TEST_F(EngineSyncTest, HalfDoubleInternalClockTest) { ControlObject::getControl(ConfigKey(m_sGroup1, "quantize"))->set(1.0); ControlObject::getControl(ConfigKey(m_sGroup2, "quantize"))->set(1.0); - // Make Channel2 master to weed out any channel ordering issues. + // Make Channel2 leader to weed out any channel ordering issues. ControlObject::getControl(ConfigKey(m_sGroup1, "sync_enabled"))->set(1); ControlObject::getControl(ConfigKey(m_sGroup2, "sync_enabled"))->set(1); @@ -2101,7 +2103,7 @@ TEST_F(EngineSyncTest, SyncPhaseToPlayingNonSyncDeck) { m_pTrack2->trySetBeats(pBeats2); // Set the sync deck playing with nothing else active. - // Next Deck becomes master and the Master clock is set to 100 BPM + // Next Deck becomes leader and the Leader clock is set to 100 BPM // The 130 BPM Track should be played at 100 BPM, rate = 0.769230769 pButtonSyncEnabled1->set(1.0); ControlObject::getControl(ConfigKey(m_sGroup1, "play"))->set(1.0); @@ -2130,7 +2132,7 @@ TEST_F(EngineSyncTest, SyncPhaseToPlayingNonSyncDeck) { // we expect that Deck 1 distance has not changed but the internal clock keeps going, because // the internal clock should continue playing even if the leader is stopped. - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_NEAR(0.019349962, ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))->get(), kMaxFloatingPointErrorLowPrecision); @@ -2149,7 +2151,7 @@ TEST_F(EngineSyncTest, SyncPhaseToPlayingNonSyncDeck) { // The first deck is still the only one with sync active. // TODO: It does sounds odd to start the track 1 at a random position and adjust the // phase later. Seeking into phase is the best option even with quantize off. - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_DOUBLE_EQ(100.0, ControlObject::getControl(ConfigKey(m_sGroup1, "bpm"))->get()); // The adjustment is calculated here: BpmControl::calcSyncAdjustment @@ -2185,7 +2187,7 @@ TEST_F(EngineSyncTest, SyncPhaseToPlayingNonSyncDeck) { m_pTrack3->trySetBeats(pBeats3); // This will sync to the first deck here and not the second (lp1784185) pButtonSyncEnabled3->set(1.0); - EXPECT_TRUE(isSoftMaster(m_sGroup3)); + EXPECT_TRUE(isSoftLeader(m_sGroup3)); ProcessBuffer(); EXPECT_DOUBLE_EQ(130.0, ControlObject::get(ConfigKey(m_sGroup3, "bpm"))); // revert that @@ -2196,9 +2198,9 @@ TEST_F(EngineSyncTest, SyncPhaseToPlayingNonSyncDeck) { pButtonSyncEnabled1->set(1.0); ProcessBuffer(); - // Soft master is now deck one because that was the last one we enabled and none of them + // Soft leader is now deck one because that was the last one we enabled and none of them // are playing. - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); ControlObject::getControl(ConfigKey(m_sGroup3, "play"))->set(1.0); ControlObject::getControl(ConfigKey(m_sGroup2, "play"))->set(1.0); @@ -2224,7 +2226,7 @@ TEST_F(EngineSyncTest, SyncPhaseToPlayingNonSyncDeck) { TEST_F(EngineSyncTest, UserTweakBeatDistance) { // If a deck has a user tweak, and another deck stops such that the first - // is used to reseed the master beat distance, make sure the user offset + // is used to reseed the leader beat distance, make sure the user offset // is reset. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(128), mixxx::audio::kStartFramePos); @@ -2257,7 +2259,7 @@ TEST_F(EngineSyncTest, UserTweakBeatDistance) { ProcessBuffer(); } - // Stop the second deck. This causes the master beat distance to get + // Stop the second deck. This causes the leader beat distance to get // seeded with the beat distance from deck 1. ControlObject::getControl(ConfigKey(m_sGroup2, "play"))->set(0.0); @@ -2277,7 +2279,7 @@ TEST_F(EngineSyncTest, UserTweakBeatDistance) { } TEST_F(EngineSyncTest, UserTweakPreservedInSeek) { - // Ensure that when we do a seek during master sync, the user offset is maintained. + // Ensure that when we do a seek during sync lock, the user offset is maintained. // This is about 128 bpm, but results in nice round numbers of samples. const double kDivisibleBpm = 44100.0 / 344.0; @@ -2356,9 +2358,9 @@ TEST_F(EngineSyncTest, UserTweakPreservedInSeek) { kMaxFloatingPointErrorLowPrecision); } -TEST_F(EngineSyncTest, FollowerUserTweakPreservedInMasterChange) { - // Ensure that when the master deck changes, the user offset is accounted for when - // reinitializing the master parameters.. +TEST_F(EngineSyncTest, FollowerUserTweakPreservedInLeaderChange) { + // Ensure that when the leader deck changes, the user offset is accounted for when + // reinitializing the leader parameters.. // This is about 128 bpm, but results in nice round numbers of samples. const double kDivisibleBpm = 44100.0 / 344.0; @@ -2369,7 +2371,7 @@ TEST_F(EngineSyncTest, FollowerUserTweakPreservedInMasterChange) { m_pTrack2->getSampleRate(), mixxx::Bpm(130), mixxx::audio::kStartFramePos); m_pTrack2->trySetBeats(pBeats2); - ControlObject::getControl(ConfigKey(m_sGroup1, "sync_master"))->set(1); + ControlObject::getControl(ConfigKey(m_sGroup1, "sync_leader"))->set(1); ControlObject::getControl(ConfigKey(m_sGroup2, "sync_enabled"))->set(1); ControlObject::set(ConfigKey(m_sGroup1, "quantize"), 1.0); ControlObject::set(ConfigKey(m_sGroup2, "quantize"), 1.0); @@ -2379,7 +2381,7 @@ TEST_F(EngineSyncTest, FollowerUserTweakPreservedInMasterChange) { ControlObject::set(ConfigKey(m_sGroup1, "play"), 1.0); ControlObject::set(ConfigKey(m_sGroup2, "play"), 1.0); - EXPECT_TRUE(isExplicitMaster(m_sGroup1)); + EXPECT_TRUE(isExplicitLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); ProcessBuffer(); @@ -2395,11 +2397,11 @@ TEST_F(EngineSyncTest, FollowerUserTweakPreservedInMasterChange) { kMaxFloatingPointErrorLowPrecision); } - // Switch master - ControlObject::getControl(ConfigKey(m_sGroup2, "sync_master"))->set(1); + // Switch leader + ControlObject::getControl(ConfigKey(m_sGroup2, "sync_leader"))->set(1); ProcessBuffer(); EXPECT_TRUE(isFollower(m_sGroup1)); - EXPECT_TRUE(isExplicitMaster(m_sGroup2)); + EXPECT_TRUE(isExplicitLeader(m_sGroup2)); for (int i = 0; i < 10; ++i) { ProcessBuffer(); @@ -2409,9 +2411,9 @@ TEST_F(EngineSyncTest, FollowerUserTweakPreservedInMasterChange) { } } -TEST_F(EngineSyncTest, MasterUserTweakPreservedInMasterChange) { - // Ensure that when the master deck changes, the user offset is accounted for when - // reinitializing the master parameters.. +TEST_F(EngineSyncTest, LeaderUserTweakPreservedInLeaderChange) { + // Ensure that when the leader deck changes, the user offset is accounted for when + // reinitializing the leader parameters.. // This is about 128 bpm, but results in nice round numbers of samples. const double kDivisibleBpm = 44100.0 / 344.0; @@ -2422,14 +2424,14 @@ TEST_F(EngineSyncTest, MasterUserTweakPreservedInMasterChange) { m_pTrack2->getSampleRate(), mixxx::Bpm(130), mixxx::audio::kStartFramePos); m_pTrack2->trySetBeats(pBeats2); - ControlObject::getControl(ConfigKey(m_sGroup1, "sync_master"))->set(1); + ControlObject::getControl(ConfigKey(m_sGroup1, "sync_leader"))->set(1); ControlObject::getControl(ConfigKey(m_sGroup2, "sync_enabled"))->set(1); ControlObject::set(ConfigKey(m_sGroup1, "quantize"), 1.0); ControlObject::set(ConfigKey(m_sGroup2, "quantize"), 1.0); ControlObject::set(ConfigKey(m_sGroup1, "play"), 1.0); ControlObject::set(ConfigKey(m_sGroup2, "play"), 1.0); - EXPECT_TRUE(isExplicitMaster(m_sGroup1)); + EXPECT_TRUE(isExplicitLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); ProcessBuffer(); @@ -2438,7 +2440,7 @@ TEST_F(EngineSyncTest, MasterUserTweakPreservedInMasterChange) { EXPECT_DOUBLE_EQ(kDivisibleBpm, ControlObject::getControl(ConfigKey(m_sGroup2, "bpm"))->get()); - // Apply user tweak offset to master -- to test the bug we found, we need + // Apply user tweak offset to leader -- to test the bug we found, we need // to apply it indirectly. ControlObject::set(ConfigKey(m_sGroup1, "rate_temp_up"), 1); for (int i = 0; i < 5; ++i) { @@ -2449,11 +2451,11 @@ TEST_F(EngineSyncTest, MasterUserTweakPreservedInMasterChange) { } ControlObject::set(ConfigKey(m_sGroup1, "rate_temp_up"), 0); - // Switch master - ControlObject::getControl(ConfigKey(m_sGroup2, "sync_master"))->set(1); + // Switch leader + ControlObject::getControl(ConfigKey(m_sGroup2, "sync_leader"))->set(1); ProcessBuffer(); EXPECT_TRUE(isFollower(m_sGroup1)); - EXPECT_TRUE(isExplicitMaster(m_sGroup2)); + EXPECT_TRUE(isExplicitLeader(m_sGroup2)); for (int i = 0; i < 10; ++i) { ProcessBuffer(); @@ -2463,7 +2465,7 @@ TEST_F(EngineSyncTest, MasterUserTweakPreservedInMasterChange) { } } -TEST_F(EngineSyncTest, MasterBpmNeverZero) { +TEST_F(EngineSyncTest, LeaderBpmNeverZero) { mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid( m_pTrack1->getSampleRate(), mixxx::Bpm(128), mixxx::audio::kStartFramePos); m_pTrack1->trySetBeats(pBeats1); @@ -2738,7 +2740,7 @@ TEST_F(EngineSyncTest, ChangeBeatGrid) { ProcessBuffer(); - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_DOUBLE_EQ(130.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm"))); EXPECT_DOUBLE_EQ(130.0, ControlObject::get(ConfigKey(m_sInternalClockGroup, "bpm"))); @@ -2749,7 +2751,7 @@ TEST_F(EngineSyncTest, ChangeBeatGrid) { ProcessBuffer(); // expect no change in Deck 1 - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); EXPECT_DOUBLE_EQ(130.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm"))); EXPECT_DOUBLE_EQ(0, ControlObject::get(ConfigKey(m_sGroup2, "bpm"))); @@ -2759,8 +2761,8 @@ TEST_F(EngineSyncTest, ChangeBeatGrid) { ControlObject::set(ConfigKey(m_sGroup1, "play"), 0.0); ProcessBuffer(); - // Group1 remains master because it is the only one with a tempo. - EXPECT_TRUE(isSoftMaster(m_sGroup1)); + // Group1 remains leader because it is the only one with a tempo. + EXPECT_TRUE(isSoftLeader(m_sGroup1)); EXPECT_TRUE(isFollower(m_sGroup2)); // Load a new beatgrid during playing, this happens when the analyser is finished. @@ -2771,9 +2773,9 @@ TEST_F(EngineSyncTest, ChangeBeatGrid) { ProcessBuffer(); // Since deck 1 is not playing, deck 2 doesn't change its speed to match theirs. Deck 2 - // should be master now, and playing at our own rate. The other deck should have + // should be leader now, and playing at our own rate. The other deck should have // changed rate to match us. - EXPECT_TRUE(isSoftMaster(m_sGroup2)); + EXPECT_TRUE(isSoftLeader(m_sGroup2)); EXPECT_TRUE(isFollower(m_sGroup1)); EXPECT_TRUE(isFollower(m_sInternalClockGroup)); EXPECT_DOUBLE_EQ(140.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm"))); @@ -2786,7 +2788,7 @@ TEST_F(EngineSyncTest, ChangeBeatGrid) { EXPECT_TRUE(isFollower(m_sInternalClockGroup)); EXPECT_TRUE(isFollower(m_sGroup1)); - EXPECT_TRUE(isSoftMaster(m_sGroup2)); + EXPECT_TRUE(isSoftLeader(m_sGroup2)); // Load a new beatgrid again, this happens when the user adjusts the beatgrid mixxx::BeatsPointer pBeats2n = BeatFactory::makeBeatGrid( @@ -2795,7 +2797,7 @@ TEST_F(EngineSyncTest, ChangeBeatGrid) { ProcessBuffer(); - // We expect that the second deck is still playing at unity -- it was the master + // We expect that the second deck is still playing at unity -- it was the leader // and it should not change speed just because it reloaded and the bpm changed. EXPECT_DOUBLE_EQ(75.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm"))); // Expect to sync on half beats @@ -2824,8 +2826,10 @@ TEST_F(EngineSyncTest, BeatMapQuantizePlay) { ControlObject::set(ConfigKey(m_sGroup1, "quantize"), 1.0); ControlObject::set(ConfigKey(m_sGroup2, "quantize"), 1.0); - ControlObject::getControl(ConfigKey(m_sGroup1, "sync_mode"))->set(SYNC_MASTER_EXPLICIT); - ControlObject::getControl(ConfigKey(m_sGroup2, "sync_mode"))->set(SYNC_FOLLOWER); + ControlObject::getControl(ConfigKey(m_sGroup1, "sync_mode")) + ->set(static_cast(SyncMode::LeaderExplicit)); + ControlObject::getControl(ConfigKey(m_sGroup2, "sync_mode")) + ->set(static_cast(SyncMode::Follower)); ControlObject::getControl(ConfigKey(m_sGroup1, "play"))->set(1.0); @@ -2859,17 +2863,17 @@ TEST_F(EngineSyncTest, BpmAdjustFactor) { ControlObject::set(ConfigKey(m_sGroup2, "sync_enabled"), 1.0); ProcessBuffer(); - // group 2 should be synced to the first playing deck and becomes master + // group 2 should be synced to the first playing deck and becomes leader EXPECT_DOUBLE_EQ(40.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm"))); EXPECT_DOUBLE_EQ(80.0, ControlObject::get(ConfigKey(m_sGroup2, "bpm"))); - EXPECT_TRUE(isSoftMaster(m_sGroup2)); + EXPECT_TRUE(isSoftLeader(m_sGroup2)); assertSyncOff(m_sGroup1); ControlObject::set(ConfigKey(m_sGroup2, "play"), 1.0); ProcessBuffer(); - EXPECT_TRUE(isSoftMaster(m_sGroup2)); + EXPECT_TRUE(isSoftLeader(m_sGroup2)); // Pretend a changing beatgrid - static_cast(m_pEngineSync->getMasterSyncable())->setLocalBpm(152); + static_cast(m_pEngineSync->getLeaderSyncable())->setLocalBpm(152); ProcessBuffer(); ControlObject::set(ConfigKey(m_sGroup1, "sync_enabled"), 1.0); @@ -2880,11 +2884,11 @@ TEST_F(EngineSyncTest, BpmAdjustFactor) { EXPECT_DOUBLE_EQ(40.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm"))); EXPECT_DOUBLE_EQ(80.0, ControlObject::get(ConfigKey(m_sGroup2, "bpm"))); EXPECT_TRUE(isFollower(m_sGroup1)); - EXPECT_TRUE(isSoftMaster(m_sGroup2)); + EXPECT_TRUE(isSoftLeader(m_sGroup2)); EXPECT_TRUE(isFollower(m_sInternalClockGroup)); } -TEST_F(EngineSyncTest, ImplicitMasterToInternalClock) { +TEST_F(EngineSyncTest, ImplicitLeaderToInternalClock) { m_pMixerDeck1->loadFakeTrack(false, 100.0); m_pMixerDeck2->loadFakeTrack(false, 125.0); ProcessBuffer(); @@ -2902,26 +2906,26 @@ TEST_F(EngineSyncTest, ImplicitMasterToInternalClock) { ControlObject::set(ConfigKey(m_sGroup2, "sync_enabled"), 1.0); ProcessBuffer(); - // group 2 should be synced to the first playing deck and becomes master + // group 2 should be synced to the first playing deck and becomes leader EXPECT_DOUBLE_EQ(125.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm"))); EXPECT_DOUBLE_EQ(125.0, ControlObject::get(ConfigKey(m_sGroup2, "bpm"))); - ASSERT_FALSE(isSoftMaster(m_sGroup1)); - ASSERT_TRUE(isSoftMaster(m_sGroup2)); - ASSERT_FALSE(isSoftMaster(m_sInternalClockGroup)); + ASSERT_FALSE(isSoftLeader(m_sGroup1)); + ASSERT_TRUE(isSoftLeader(m_sGroup2)); + ASSERT_FALSE(isSoftLeader(m_sInternalClockGroup)); ProcessBuffer(); // Drop Track, no change ControlObject::set(ConfigKey(m_sGroup1, "volume"), 1.0); - ASSERT_FALSE(isSoftMaster(m_sGroup1)); - ASSERT_TRUE(isSoftMaster(m_sGroup2)); - ASSERT_FALSE(isSoftMaster(m_sInternalClockGroup)); + ASSERT_FALSE(isSoftLeader(m_sGroup1)); + ASSERT_TRUE(isSoftLeader(m_sGroup2)); + ASSERT_FALSE(isSoftLeader(m_sInternalClockGroup)); - // Other track stops, master switches to deck 1 + // Other track stops, leader switches to deck 1 ControlObject::set(ConfigKey(m_sGroup2, "volume"), 0.0); ProcessBuffer(); ProcessBuffer(); - ASSERT_TRUE(isSoftMaster(m_sGroup1)); - ASSERT_FALSE(isSoftMaster(m_sGroup2)); - ASSERT_FALSE(isSoftMaster(m_sInternalClockGroup)); + ASSERT_TRUE(isSoftLeader(m_sGroup1)); + ASSERT_FALSE(isSoftLeader(m_sGroup2)); + ASSERT_FALSE(isSoftLeader(m_sInternalClockGroup)); } diff --git a/src/test/synccontroltest.cpp b/src/test/synccontroltest.cpp index 9e9e8a159bf..59a62d88a29 100644 --- a/src/test/synccontroltest.cpp +++ b/src/test/synccontroltest.cpp @@ -1,7 +1,7 @@ -// Tests for Master Sync. +// Tests for Sync Lock. // There are no tests for actual deck playback, since I don't know how to mock that out yet. // The following manual tests should probably be performed: -// * Quantize mode nudges tracks in sync, whether internal or deck master. +// * Quantize mode nudges tracks in sync, whether internal or deck leader. // * Flinging tracks with the waveform should work. // * vinyl??