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 Lock: Differentiate track loading from beats updating #3944

Merged
merged 20 commits into from
Oct 7, 2021

Conversation

ywwg
Copy link
Member

@ywwg ywwg commented Jun 4, 2021

When we load a track, we want the deck to sync to other decks.
When we update beats of a Leader deck, we want it to remain at the same playback speed.

@ywwg
Copy link
Member Author

ywwg commented Jun 16, 2021

fix this commit history as well

@coveralls
Copy link

coveralls commented Jul 19, 2021

Pull Request Test Coverage Report for Build 1156225558

  • 25 of 39 (64.1%) changed or added relevant lines in 4 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.02%) to 25.985%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/engine/sync/enginesync.cpp 2 4 50.0%
src/engine/sync/synccontrol.cpp 15 19 78.95%
src/engine/controls/bpmcontrol.cpp 2 10 20.0%
Files with Coverage Reduction New Missed Lines %
src/engine/controls/bpmcontrol.cpp 1 65.02%
src/engine/cachingreader/cachingreaderworker.cpp 2 63.48%
Totals Coverage Status
Change from base Build 1154301022: 0.02%
Covered Lines: 20023
Relevant Lines: 77056

💛 - Coveralls

@ywwg ywwg marked this pull request as ready for review July 22, 2021 22:34
@ywwg
Copy link
Member Author

ywwg commented Jul 23, 2021

ugh this commit history is now borked, fixing...

@ywwg ywwg force-pushed the synclock-05-explicitload branch from a5b0969 to 0d1eb3f Compare July 23, 2021 00:57
@ywwg
Copy link
Member Author

ywwg commented Jul 23, 2021

ok I manually squashed this down to one simple commit.

@ywwg ywwg requested a review from Holzhaus July 23, 2021 00:59
@Holzhaus
Copy link
Member

ok I manually squashed this down to one simple commit.

For such PRs I think it would be good to add the PR description to the commit message as well. No need to amend the commit, but I think it would be good practice in the future ;-)

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. Didn't test this yet but code look good.

src/engine/sync/synccontrol.cpp Outdated Show resolved Hide resolved
src/test/enginesynctest.cpp Outdated Show resolved Hide resolved
auto pButtonLeaderSync1 =
std::make_unique<ControlProxy>(m_sGroup1, "sync_mode");
pButtonLeaderSync1->set(static_cast<double>(SyncMode::LeaderExplicit));
ProcessBuffer();
EXPECT_TRUE(isExplicitLeader(m_sGroup1));
EXPECT_DOUBLE_EQ(160.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm")));
EXPECT_DOUBLE_EQ(120.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm")));
Copy link
Member

Choose a reason for hiding this comment

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

These test value changes are just for easier calculation by hand, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the behavior of mixxx changed, the test now acts differently than it did before. So, I had to update some of the values. (Where appropriate, I also updated comments)

@@ -533,7 +531,7 @@ void EngineSync::onCallbackEnd(int sampleRate, int bufferSize) {
m_pInternalClock->onCallbackEnd(sampleRate, bufferSize);
}

EngineChannel* EngineSync::getLeader() const {
EngineChannel* EngineSync::getLeaderChannel() const {
Copy link
Member

Choose a reason for hiding this comment

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

Looks unrelated, but but probably makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah it helped clarify -- "getLeader" would seemingly return a Syncable*

ywwg and others added 3 commits July 23, 2021 11:24
Use nullptr instead of NULL (reviewer suggestion)

Co-authored-by: Jan Holthuis <holthuis.jan@googlemail.com>
constify bool (reviewer suggestion)

Co-authored-by: Jan Holthuis <holthuis.jan@googlemail.com>
src/test/enginesynctest.cpp Outdated Show resolved Hide resolved
src/test/enginesynctest.cpp Outdated Show resolved Hide resolved
@@ -281,7 +281,7 @@ void EngineMaster::processChannels(int iBufferSize) {
m_activeChannels.clear();

//ScopedTimer timer("EngineMaster::processChannels");
EngineChannel* pMasterChannel = m_pMasterSync->getLeader();
EngineChannel* pMasterChannel = m_pMasterSync->getLeaderChannel();
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused about the Master term here. I should rename it anyway (probably in a dedicated PR), but pMasterChannel does refer to the sync leader channel not the main output channel, right? This is a bit confusing.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, it should be LeaderChannel. I will file a PR to update the language

Copy link
Member Author

Choose a reason for hiding this comment

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

eh, just fixed it anyway

ywwg and others added 4 commits July 28, 2021 08:48
review note: NULL -> nullptr

Co-authored-by: Jan Holthuis <holthuis.jan@googlemail.com>
review note: NULL -> nullptr

Co-authored-by: Jan Holthuis <holthuis.jan@googlemail.com>
@daschuer
Copy link
Member

daschuer commented Aug 1, 2021

Normal loading of tracks now work like expected.
However there is an issue with instant doubles.
If I dag the follower track to the leader deck, both decks receive a tempo change.
It also happens if I drag the follower track to the leader deck.
The rate shall not change IMHO in this case.

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 think this needs also some love for the instant double case.

@ywwg
Copy link
Member Author

ywwg commented Aug 4, 2021

ah ok. Yeah I'll take a look at that

@ywwg
Copy link
Member Author

ywwg commented Aug 6, 2021

I can't reproduce the issue with doubles you describe. Also in your description you twice describe dragging the follower track onto the leader deck as if they are different cases. Can you please describe this case in detail, like: which decks have sync on? Which decks have tracks? What are the track bpms? Where are the rate sliders? etc etc.

@daschuer
Copy link
Member

daschuer commented Aug 6, 2021

I was not able to reproduce this issue with const bpm track but it works with a beat map track see:

simplescreenrecorder-2021-08-06_09.48.11.mp4

@ywwg
Copy link
Member Author

ywwg commented Aug 22, 2021

Can you test with this branch? https://github.com/ywwg/mixxx/tree/synclock-05-explicitload-debug

@ywwg
Copy link
Member Author

ywwg commented Aug 22, 2021

(the bug is that bpmcontrol contains an obsolete function called syncTempo which attempts to duplicate the synclock logic but does a very poor job of it. I have removed the function and replace the few calls to it with proper calls to synclock code)

@ywwg
Copy link
Member Author

ywwg commented Sep 12, 2021

fixed conflict

}

syncTempo();
m_pSyncEnabled->set(value != 0);
Copy link
Member

Choose a reason for hiding this comment

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

This is the momentary sync of tempo only when right clicking the sync button.
Mapping this to sync enabled will also sync the phase = seeks the track.
The original use case is syncing the tempo without seeking. This is now no longer possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

moved these controls to the synccontrol and reimplemented using the correct code.

@daschuer
Copy link
Member

Unfortunately the tempo change issue when doing instant double still exists:

simplescreenrecorder-2021-09-12_23.17.05_edit.mp4

@ywwg
Copy link
Member Author

ywwg commented Sep 25, 2021

This is a bug with deck cloning, not Sync. And this only happens with beatmap tracks. I believe this is happening because the order of the clone events is wrong:

  • track is loaded
  • bpm is synced
  • track seek takes place

The sync operation is taking place before the cloned track has performed its seek -- and at the beginning of the track, the local bpm may be very different. So Mixxx is taking the actual un-seeked local bpm and applying the rate slider, getting a new bpm, and then setting that as the new bpm. So the bpm error will compound in the direction of the rate slider. I don't know a lot about deck cloning so I don't really know how to fix this. But what we should do is do the seek first and then initiate the rate matching.

I'd like to consider this issue "mostly fixed" except for this edge case. Let's file a bug for this new issue and get these other fixes in.

m_pRateRatio->set(target->getBpm() * multiplier / localBpm);
}

void SyncControl::slotControlBeatSync(double value) {
Copy link
Member

Choose a reason for hiding this comment

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

This changes the behavior from a momentary control to a permanent switch.
I think we must not change it silently.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@daschuer
Copy link
Member

daschuer commented Oct 7, 2021

I can confirm that the instant double issue is no regression from this PR. I have filed https://bugs.launchpad.net/mixxx/+bug/1946385

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.

LGTM, Thank you.

@daschuer daschuer merged commit bc3d041 into mixxxdj:main Oct 7, 2021
@ywwg
Copy link
Member Author

ywwg commented Oct 8, 2021

thanks for your patience <3

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