Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Sync to the loaded deck with the lowest index if no track is playing #1818

Merged
merged 4 commits into from
Jan 1, 2019

Conversation

daschuer
Copy link
Member

This fixes https://bugs.launchpad.net/mixxx/+bug/1784185

I have targeted it to 2.1 because it has a limited scope and it has a test.
The current behavior can be really annoying, if the last syncable it a sampler, that was reloaded automatically from a last session

@Be-ing Be-ing changed the base branch from 2.1 to master September 23, 2018 04:38
@Be-ing
Copy link
Contributor

Be-ing commented Sep 23, 2018

I do not think it is a good idea to put major UX changes in bugfix releases. IMO this change should go to master where it can get lots of testing before it is released.

@daschuer
Copy link
Member Author

This is a real bug, try it out. It is somehow a regression from keeping persistent tracks in samplers.
Once a track is in the samplers all decks sync to that sampler. It took me a while to figure out where the odd BPM comes from when syncing without a playing deck.

@daschuer daschuer changed the base branch from master to 2.1 October 4, 2018 18:55
@daschuer
Copy link
Member Author

Who wants to test this? Only a few lines of code.

@daschuer
Copy link
Member Author

@ywwg can you have a brief look here?

@daschuer daschuer added this to the 2.1.6 milestone Dec 13, 2018
@daschuer
Copy link
Member Author

This is also reported here https://bugs.launchpad.net/mixxx/+bug/1808698
Who can have a look into this PR?

@xeruf
Copy link
Contributor

xeruf commented Dec 18, 2018

@daschuer what do we need to look into? Verify that it works? Because the code changes are trivial ^^

@daschuer
Copy link
Member Author

Yes, does it work and is it sensible.
If yes respond with a formal LGTM and we can merge it.

// is not, do not sync.
if (pSyncable->isPlaying() && !other_deck->isPlaying()) {
// If the requesting deck is playing, or we have already a
// non plaing deck found, only watch out for playing decks.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: plaing -> playing

@@ -1340,9 +1340,9 @@ TEST_F(EngineSyncTest, SyncPhaseToPlayingNonSyncDeck) {
ControlObject::getControl(ConfigKey(m_sGroup1, "play"))->set(1.0);
ProcessBuffer();

EXPECT_FLOAT_EQ(140.0,
EXPECT_FLOAT_EQ(100.0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this is testing is that if there is a playing deck with master sync enabled, we should choose that as the sync target. That seems like a different change from what the bug was saying. If a deck is playing with sync, it should definitely be the thing that other decks sync to. So this test change seems wrong to me

if (pSyncable->isPlaying() && !other_deck->isPlaying()) {
// If the requesting deck is playing, or we have already a
// non plaing deck found, only watch out for playing decks.
if ((foundTargetBpm || pSyncable->isPlaying())
Copy link
Member

@ywwg ywwg Dec 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original logic was right. The bug is that if we go through all the decks and we don't find a syncable playing deck, we end up falling back to the last-seen deck.

I think the correct fix could be:

if (pSyncable->isPlaying() && !other_deck->isPlaying()) {
 continue;
}

// Only update the target bpm if we haven't already got one, or we found a playing syncable deck
if (!foundTargetBpm || pOtherSyncable->isPlaying()) {
  foundTargetBpm = true;
  targetBpm = otherDeckBpm;
  targetBaseBpm = pOtherSyncable->getBaseBpm();
  targetBeatDistance = pOtherSyncable->getBeatDistance();
}

if (pOtherSyncable->isPlaying()) {...

Copy link
Member Author

@daschuer daschuer Dec 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: (missread your code before)
Both versions behave the same, right?
In this case I would prefere mine, because it has a single continue to reject a syncable. On the other hand I don't really mind ... Or is there an issue with my code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I see how it's changed around. I think this is fine, thanks!

ControlObject::getControl(ConfigKey(m_sInternalClockGroup, "bpm"))->get());
EXPECT_FLOAT_EQ(140.0, ControlObject::getControl(ConfigKey(m_sGroup1, "bpm"))->get());
EXPECT_FLOAT_EQ(100.0, ControlObject::getControl(ConfigKey(m_sGroup1, "bpm"))->get());
// The exact beat distance will be one buffer past .6, but this is good
// enough to confirm that it worked.
EXPECT_GT(0.7, ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))->get());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a new test explicitly for this bug. Set up three decks, all without sync. Deck 1 has bpm 100, deck 2 has bpm 140, deck 3 has bpm 160. When sync is enabled, the resulting sync bpm should be 140, whereas with the old code it'd be 160

Copy link
Member

@ywwg ywwg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking at this, and my apologies for the very complex master sync code. You found the right place to fix this but I think the fix is slightly different.

@daschuer
Copy link
Member Author

Ok, The test is fixed. Ready to merge!

@daschuer
Copy link
Member Author

@ywwg: What do you think now?

@ywwg
Copy link
Member

ywwg commented Jan 1, 2019

Hi sorry for the slow response, checking now! (my github notifications are not set very well :()

Copy link
Member

@ywwg ywwg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great, thanks!

if (pSyncable->isPlaying() && !other_deck->isPlaying()) {
// If the requesting deck is playing, or we have already a
// non plaing deck found, only watch out for playing decks.
if ((foundTargetBpm || pSyncable->isPlaying())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I see how it's changed around. I think this is fine, thanks!

@daschuer
Copy link
Member Author

daschuer commented Jan 1, 2019

Thank you for comming back.

@daschuer daschuer merged commit 965aa92 into mixxxdj:2.1 Jan 1, 2019
@daschuer daschuer modified the milestones: 2.1.6, 2.1.7 Jan 1, 2019
@daschuer daschuer deleted the lp1784185 branch September 26, 2021 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants