-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues with half/double and Sync Lock #3899
Changes from 6 commits
507bb03
0718058
c521601
15cd3d4
35ed9c9
ec01df8
b041a6e
d8c843a
8984df9
ae18e4e
0e03653
58d0e4b
534eacf
bd560c0
4e9f8f4
4ccdebe
259cfa5
d450bca
b0c51f0
372d9e4
08cead7
7efe916
fc5813f
257b943
daba011
7b56e59
3e331c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,19 +238,17 @@ void SyncControl::setMasterBpm(double bpm) { | |
} | ||
} | ||
|
||
void SyncControl::notifyMasterParamSource() { | ||
m_masterBpmAdjustFactor = kBpmUnity; | ||
} | ||
|
||
void SyncControl::setMasterParams( | ||
double beatDistance, double baseBpm, double bpm) { | ||
// Calculate the factor for the file bpm. That gives the best | ||
// result at any rate slider position. | ||
double masterBpmAdjustFactor = determineBpmMultiplier(fileBpm(), baseBpm); | ||
if (isMaster(getSyncMode())) { | ||
// In Master mode we adjust the incoming Bpm for the initial sync. | ||
bpm *= masterBpmAdjustFactor; | ||
m_masterBpmAdjustFactor = kBpmUnity; | ||
} else { | ||
// in Follower mode we keep the factor when reporting our BPM | ||
m_masterBpmAdjustFactor = masterBpmAdjustFactor; | ||
if (kLogger.traceEnabled()) { | ||
kLogger.trace() << "SyncControl::setMasterParams" << getGroup() | ||
<< beatDistance << baseBpm << bpm; | ||
} | ||
m_masterBpmAdjustFactor = determineBpmMultiplier(fileBpm(), baseBpm); | ||
setMasterBpm(bpm); | ||
setMasterBeatDistance(beatDistance); | ||
} | ||
|
@@ -274,7 +272,10 @@ double SyncControl::determineBpmMultiplier(double myBpm, double targetBpm) const | |
void SyncControl::updateTargetBeatDistance() { | ||
double targetDistance = m_unmultipliedTargetBeatDistance; | ||
if (kLogger.traceEnabled()) { | ||
kLogger.trace() << getGroup() << "SyncControl::updateTargetBeatDistance, unmult distance" << targetDistance; | ||
kLogger.trace() | ||
<< getGroup() | ||
<< "SyncControl::updateTargetBeatDistance, unmult distance" | ||
<< targetDistance << m_masterBpmAdjustFactor; | ||
} | ||
|
||
// Determining the target distance is not as simple as x2 or /2. Since one | ||
|
@@ -289,7 +290,8 @@ void SyncControl::updateTargetBeatDistance() { | |
targetDistance *= kBpmDouble; | ||
} else if (m_masterBpmAdjustFactor == kBpmHalve) { | ||
targetDistance *= kBpmHalve; | ||
if (m_pBeatDistance->get() >= 0.5) { | ||
// Our beat distance CO is still a buffer behind, so take the current value. | ||
if (m_pBpmControl->getBeatDistance(getSampleOfTrack().current) >= 0.5) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very proud of this fix. It was hard to track down. |
||
targetDistance += 0.5; | ||
} | ||
} | ||
|
@@ -301,7 +303,8 @@ void SyncControl::updateTargetBeatDistance() { | |
|
||
double SyncControl::getBpm() const { | ||
if (kLogger.traceEnabled()) { | ||
kLogger.trace() << getGroup() << "SyncControl::getBpm()"; | ||
kLogger.trace() << getGroup() << "SyncControl::getBpm()" | ||
<< m_pBpm->get() << "/" << m_masterBpmAdjustFactor; | ||
} | ||
return m_pBpm->get() / m_masterBpmAdjustFactor; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1445,6 +1445,24 @@ TEST_F(EngineSyncTest, ZeroBPMRateAdjustIgnored) { | |
ControlObject::getControl(ConfigKey(m_sGroup2, "rate"))->get()); | ||
} | ||
|
||
TEST_F(EngineSyncTest, DISABLED_BeatDistanceBeforeStart) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you planning to fix this in this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no -- this is a much more complex issue and I'm not even sure what's going wrong. This is a pretty rare circumstance, and shouldn't be a release-blocker, let alone a PR-blocker. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
// https://bugs.launchpad.net/mixxx/+bug/1930143 | ||
// If the start position is before zero, we should still initialize the beat distance | ||
// correctly. Unfortunately, this currently doesn't work. | ||
|
||
mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 128, 0.0); | ||
m_pTrack1->trySetBeats(pBeats1); | ||
ControlObject::set(ConfigKey(m_sGroup1, "playposition"), -.05); | ||
ControlObject::getControl(ConfigKey(m_sGroup1, "sync_mode")) | ||
->set(SYNC_MASTER_SOFT); | ||
ControlObject::getControl(ConfigKey(m_sGroup1, "play"))->set(1.0); | ||
ProcessBuffer(); | ||
EXPECT_NEAR( | ||
ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))->get(), | ||
ControlObject::getControl(ConfigKey(m_sInternalClockGroup, "beat_distance"))->get(), | ||
kMaxBeatDistanceEpsilon); | ||
} | ||
|
||
TEST_F(EngineSyncTest, ZeroLatencyRateChangeNoQuant) { | ||
// Confirm that a rate change in an explicit master is instantly communicated | ||
// to followers. | ||
|
@@ -1664,10 +1682,10 @@ TEST_F(EngineSyncTest, HalfDoubleBpmTest) { | |
ControlObject::getControl(ConfigKey(m_sGroup1, "play"))->set(1.0); | ||
ProcessBuffer(); | ||
|
||
EXPECT_EQ(1.0, | ||
EXPECT_EQ(0.5, | ||
m_pChannel1->getEngineBuffer() | ||
->m_pSyncControl->m_masterBpmAdjustFactor); | ||
EXPECT_EQ(2.0, | ||
EXPECT_EQ(1.0, | ||
m_pChannel2->getEngineBuffer() | ||
->m_pSyncControl->m_masterBpmAdjustFactor); | ||
EXPECT_DOUBLE_EQ( | ||
|
@@ -1789,7 +1807,7 @@ TEST_F(EngineSyncTest, HalfDoubleThenPlay) { | |
|
||
ProcessBuffer(); | ||
|
||
EXPECT_DOUBLE_EQ(87.5, | ||
EXPECT_DOUBLE_EQ(175, | ||
ControlObject::getControl(ConfigKey(m_sInternalClockGroup, "bpm")) | ||
->get()); | ||
|
||
|
@@ -2021,12 +2039,13 @@ TEST_F(EngineSyncTest, SyncPhaseToPlayingNonSyncDeck) { | |
|
||
ProcessBuffer(); | ||
|
||
// we expect that Deck 1 distance has not changed and the internal clock follows it exactly. | ||
// 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_NEAR(0.019349962, | ||
ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))->get(), | ||
kMaxFloatingPointErrorLowPrecision); | ||
EXPECT_NEAR(0.019349962, | ||
EXPECT_NEAR(0.038699924, | ||
ControlObject::getControl(ConfigKey(m_sInternalClockGroup, "beat_distance"))->get(), | ||
kMaxFloatingPointErrorLowPrecision); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you rename this to something like:
notifyUniquePlaying() or such?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done