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

Fix issues with half/double and Sync Lock #3899

Merged
merged 27 commits into from
Jun 15, 2021
Merged

Conversation

ywwg
Copy link
Member

@ywwg ywwg commented May 23, 2021

One part of Sync Lock that isn't well-described by the code is the idea of which Syncable is responsible for initializing the Sync Leader values. This is not the same as the leader! For instance, when you push and hold sync, that deck becomes the leader but it initializes based on the values of some other deck. This concept was causing problems with half/double bpm calculation. The code is a little more explicit now, and doesn't just assume that the Sync Leader should be the source of sync params.

Also fixed some super edge cases

@@ -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) {
Copy link
Member Author

Choose a reason for hiding this comment

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

very proud of this fix. It was hard to track down.

@ywwg
Copy link
Member Author

ywwg commented May 23, 2021

p.s.: I really, really hate half-double syncing and wish I had never done it :P.

@ywwg ywwg requested review from Holzhaus and daschuer May 23, 2021 18:34
@ywwg
Copy link
Member Author

ywwg commented May 28, 2021

The PR after this will rename master->leader! So let's get this in yes? :)

@Holzhaus
Copy link
Member

Clazy checks failed

@ywwg
Copy link
Member Author

ywwg commented May 28, 2021

Clazy checks failed

fixed

Copy link
Member

@Holzhaus Holzhaus left a comment

Choose a reason for hiding this comment

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

Thanks, I noticed no issues when testing this, but I can't really comment on the code changes because I'm not familiar enough with it. Would be good if someone else would have a look.

@@ -1445,6 +1445,23 @@ TEST_F(EngineSyncTest, ZeroBPMRateAdjustIgnored) {
ControlObject::getControl(ConfigKey(m_sGroup2, "rate"))->get());
}

TEST_F(EngineSyncTest, DISABLED_BeatDistanceBeforeStart) {
Copy link
Member

Choose a reason for hiding this comment

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

Are you planning to fix this in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

I have a notable momentary pitch change in case of a implicit leader deck playing audible and a inaudible follower disables sync.

  • Play track A
  • Enable Sync A
  • Move x-fader to A
  • Play track B
  • Enable Sync B
  • A is implicit Leader
  • Nudge Track A
  • Disable Sync B
  • Hear a tempo dip in Track A -> wrong!

This can be noticed the best if Track A is a 440 Hz Sine wave analyzed with a const beat grid.

src/engine/sync/enginesync.cpp Outdated Show resolved Hide resolved
src/engine/sync/enginesync.cpp Outdated Show resolved Hide resolved
src/engine/sync/enginesync.cpp Outdated Show resolved Hide resolved
continue;
}
pSyncable->setMasterParams(beatDistance, baseBpm, bpm);
}
}

bool EngineSync::noPlayingFollowers() const {
Syncable* EngineSync::getOnlyPlayingSyncable() const {
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 the function name can be improved.
Only playing can also mean that it is playing without being synced or without being audible.
Something like:
getLonlyPlayingSyncronizedSyncable();
getLonlyPlayingSyncable();

Copy link
Member Author

Choose a reason for hiding this comment

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

do you mean "lonely" ? :) I tried "getUniquePlayingSyncedDeck"

@ywwg ywwg force-pushed the stopped-explicit branch from adbf37e to 85bbc63 Compare June 1, 2021 03:12
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
@ywwg ywwg force-pushed the stopped-explicit branch from 85bbc63 to 35ed9c9 Compare June 1, 2021 03:13
@ywwg
Copy link
Member Author

ywwg commented Jun 1, 2021

I have a notable momentary pitch change in case of a implicit leader deck playing audible and a inaudible follower disables sync.

fixed.

@daschuer
Copy link
Member

daschuer commented Jun 3, 2021

I can confirm the pitch dip issue is fixed with a nudged leader deck.

Somehow the leader buttons are now broken. Is this a visual skin issue? The plain main branch is also affected.

When I load a new track to a stopped explicit master deck the follower becomes high pitched.
I don't think that this is a valid use case.

if (pOnlyPlayer) {
// Even if we didn't change master, if there is only one player (us), then we should
// reinit the beat distance.
pOnlyPlayer->notifyOnlyPlayingSyncable();
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@ywwg
Copy link
Member Author

ywwg commented Jun 3, 2021

When I load a new track to a stopped explicit master deck the follower becomes high pitched.
I don't think that this is a valid use case.

this is one of those edge cases. It's an explicit leader, so it's supposed to be in charge of the rate. Should we instead say that loading a new track causes it to relinquish explicit leader state? What's the right behavior?

@ronso0
Copy link
Member

ronso0 commented Jun 3, 2021

Somehow the leader buttons are now broken. Is this a visual skin issue? The plain main branch is also affected.

fixed with 52786c9
text outlines stack order is not respected Qt SVG, thus the same path with an outline needs be behind the text :
we need to polish and add the Leader control to all skins anyway.

@ywwg
Copy link
Member Author

ywwg commented Jun 3, 2021

Yes the leader button was always meant to be temp. Is it ok if I leave it for now?

@github-actions github-actions bot added the skins label Jun 3, 2021
@ywwg
Copy link
Member Author

ywwg commented Jun 4, 2021

I made the decks a few pixels taller to make room for the button. Is that ok for now?

@ywwg
Copy link
Member Author

ywwg commented Jun 4, 2021

Would it be ok if I fix the track load change in the next PR? That's a separate bug from this one and this PR has been hanging around a while. I have a good track record of fixing these things :)

@ywwg
Copy link
Member Author

ywwg commented Jun 4, 2021

sync the leader from a follower during load

This conflcts with our conclusion in https://bugs.launchpad.net/mixxx/+bug/1808698. There, we decided 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." The test we wrote has the other decks all changing speed to match the new value.

@ywwg
Copy link
Member Author

ywwg commented Jun 4, 2021

I suppose the difference here is between when the beats are updated due to a track load (should resync to the playing bpm) vs beats are updated due to rescan (should keep the slider where it is).

@ywwg
Copy link
Member Author

ywwg commented Jun 4, 2021

OK I have a new PR that fixes the track load behavior. It is very far downstream of this PR so I'd really like to get this in so we can move ahead

@ywwg ywwg requested review from daschuer and Holzhaus June 4, 2021 19:51
@ywwg
Copy link
Member Author

ywwg commented Jun 14, 2021

friendly ping -- I'd really like to start getting these in

@daschuer
Copy link
Member

I have noticed an inconsistency:
1:

  • Play Deck A with Sync enabled (Implicit Leader)
  • Nudge deck A
  • Sync Deck B
  • Play Deck B
  • -> Beat markers are in sync

2:

  • Play Deck A with Sync enabled (Implicit Leader)
  • Sync Deck B (paused)
  • Nudge deck A
  • Play Deck B
  • -> Beat markers are out of sync

I can imagine arguments for both behaviors, but both should behave the same.
For now, I would prefer the first. Nudging is used to make two decks sound good, when playing together.
When playing allown this feature is pointless.

@daschuer
Copy link
Member

The behavior of nudging is IMHO correct, when playing with three decks.
I can nudge the leader of two decks. When I now add play a third synced deck it is in sync with the other follower, which is perfect.

After rethinking the whole, my conclusion is: The current behavior is OK.

@daschuer
Copy link
Member

LGTM, Thank you.

@daschuer daschuer merged commit d8a9fd3 into mixxxdj:main Jun 15, 2021
@ywwg
Copy link
Member Author

ywwg commented Jun 16, 2021

ok cool. There's still a lot to fix with Sync Lock so we'll keep working on it

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