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

SyncLock: Don't recalc half/double multiplier on every callback #3706

Merged
merged 2 commits into from
Jun 29, 2021

Conversation

ywwg
Copy link
Member

@ywwg ywwg commented Mar 14, 2021

This PR builds on #3698. It contains some refactoring to make the functions clearer.

@ywwg ywwg marked this pull request as draft March 14, 2021 20:42
@ywwg ywwg force-pushed the synclock-03-halfdoublefix branch 2 times, most recently from 8e46045 to ab1ae45 Compare March 15, 2021 19:53
@ywwg
Copy link
Member Author

ywwg commented Mar 16, 2021

This patch is ready for review except that it builds on #3698 and there's no way to tell github to show the diff to that patch instead of main

@ywwg ywwg force-pushed the synclock-03-halfdoublefix branch from bc87485 to 92175c1 Compare May 14, 2021 16:31
@ywwg ywwg marked this pull request as ready for review May 14, 2021 16:32
@ywwg
Copy link
Member Author

ywwg commented May 14, 2021

rebased / updated etc! ready for review

@daschuer
Copy link
Member

Did you forget to push? I assume you want to make a single commit on top of main.

@daschuer
Copy link
Member

Which code line contains the fix? Maybe it is also to have a single commit containing the fix only.

@ywwg ywwg force-pushed the synclock-03-halfdoublefix branch 2 times, most recently from 027f60a to 4844230 Compare May 15, 2021 14:43
pSyncable->setMasterParams(beatDistance, mbaseBpm, mbpm);
// update from current master
pSyncable->updateMasterBeatDistance(beatDistance);
pSyncable->updateMasterBpm(mbpm);
Copy link
Member Author

@ywwg ywwg May 15, 2021

Choose a reason for hiding this comment

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

this is the fix -- we just update the beat distance and bpm, NOT basebpm. Updating basebpm triggers all of the half/double code, and we should not do that on every callback.

@ywwg
Copy link
Member Author

ywwg commented May 15, 2021

rebased and squashed. Sorry to mix the refactor with the fix.

@daschuer
Copy link
Member

Is this still [WIP] according to the title?

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 there is a remaining issue: When I sync to a non const tempo track at master in a slow start region with 100 BPM a cont track is synced to it it follows the track lets say to 150 BPM.
When I change now the explicite master to the const track, the original master haves the tempo.
That was at least surprising. I think we should also in this case not recalc the multiplier.

@ywwg
Copy link
Member Author

ywwg commented May 23, 2021

I am finding major half/double issues in the code in general :(. I will try to fix those first.

@ywwg
Copy link
Member Author

ywwg commented Jun 1, 2021

This now is a followon to #3899

@ywwg ywwg marked this pull request as draft June 4, 2021 19:51
@ywwg ywwg force-pushed the synclock-03-halfdoublefix branch from be3d82c to dd0c6da Compare June 16, 2021 02:03
@ywwg ywwg marked this pull request as ready for review June 16, 2021 02:03
@ywwg
Copy link
Member Author

ywwg commented Jun 16, 2021

I'll split out the fix

@ywwg ywwg marked this pull request as draft June 16, 2021 02:06
@ywwg ywwg force-pushed the synclock-03-halfdoublefix branch 2 times, most recently from 6640a28 to 2d2b485 Compare June 16, 2021 02:22
@ywwg ywwg marked this pull request as ready for review June 16, 2021 02:22
@ywwg
Copy link
Member Author

ywwg commented Jun 16, 2021

ok should be good now

@daschuer
Copy link
Member

This has a failing test now.

@daschuer
Copy link
Member

daschuer commented Jun 20, 2021

I can confirm that the original issue is fixed, now random pitch change when a track is playing.

I have only discovered this weird case:

When I have a playing track in deck A and it has a tempo change in this case form 107 to 100 and the follower is cued to take over at 160 it sits at 107 than suddenly changes to 200.
This a constructed edge case, but the result is surprising.

I think we mus t accept this case to make the feature work at a whole.

Of cause this does not happen when the internal clock takes over.
[BPM]", "sync_lock_algorithm" = REFER_LOCK_BPM
But that is currently not accessible for ordinary users.

@ywwg ywwg force-pushed the synclock-03-halfdoublefix branch from 2d2b485 to 47cd79e Compare June 23, 2021 22:19
@ywwg
Copy link
Member Author

ywwg commented Jun 23, 2021

fixed broken test (force push)

@ywwg ywwg requested a review from daschuer June 23, 2021 22:19
@daschuer
Copy link
Member

daschuer commented Jun 24, 2021

Don't rebase PRs under review. I can now review and test the whole PR again, because I cannot see what has changed and fixed the test.

Do you have the original commits you .git folder?
Maybe you can re-create them or at least point me to your changes.

@daschuer
Copy link
Member

Fortunately I had the original testing branch in my .git folder.
The fix was just:

index cfe50230b1..fc51115364 100644
--- a/src/test/enginesynctest.cpp
+++ b/src/test/enginesynctest.cpp
@@ -1839,7 +1839,7 @@ TEST_F(EngineSyncTest, HalfDoubleThenPlay) {
     ProcessBuffer();
     pButtonSyncEnabled2->slotSet(1.0);
     pButtonSyncEnabled1->slotSet(1.0);
-    EXPECT_DOUBLE_EQ(0.5,
+    EXPECT_DOUBLE_EQ(1.0,
             m_pChannel1->getEngineBuffer()
                     ->m_pSyncControl->m_masterBpmAdjustFactor);
     EXPECT_DOUBLE_EQ(1.0,

Next time it would be much less hassle if you just commit that fix. Easy to review and now business logic touched.

@daschuer daschuer merged commit 521ab45 into mixxxdj:main Jun 29, 2021
@ywwg ywwg changed the title [WIP] SyncLock: Don't recalc half/double multiplier on every callback SyncLock: Don't recalc half/double multiplier on every callback Jul 9, 2021
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.

3 participants