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 bpm edit fix Lp1808698 #1955

Merged
merged 12 commits into from
Jan 9, 2019
Merged

sync bpm edit fix Lp1808698 #1955

merged 12 commits into from
Jan 9, 2019

Conversation

daschuer
Copy link
Member

This fixes the issue that the follower deck changes tempo if you edit the beat grid.
A test is in place confirming that the bug is fixed.

@daschuer daschuer added this to the 2.1.6 milestone Dec 23, 2018
@xeruf
Copy link
Contributor

xeruf commented Dec 23, 2018

Yes, I just tested it and it seems to work without issues as i expected it 👍

@daschuer
Copy link
Member Author

Great. Thank you for testing. Who has interests to do the code review?

virtual void requestSyncMode(Syncable* pSyncable, SyncMode mode) = 0;

// Used by Syncables to tell EngineSync it wants to be enabled in any mode
// (master/follower).
virtual void requestEnableSync(Syncable* pSyncable, bool enabled) = 0;

// A Syncable must never call notifyBpmChanged in response to a setMasterBpm()
// call.
virtual void notifyBpmChanged(Syncable* pSyncable, double bpm,
Copy link
Contributor

@uklotzde uklotzde Dec 27, 2018

Choose a reason for hiding this comment

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

Why not a separate signal notifyFileBpmChanged, like notifyInstantaneousBpmChanged? We should either use one signal with an enumeration parameter or separate signals, but not a mixture of both style.

Separate signals seem to make sense here, because we also have separate slots for the different use cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I have refactored the call a bit. I hope I have got your point.

@@ -825,7 +825,7 @@ double BpmControl::updateLocalBpm() {
double BpmControl::updateBeatDistance() {
double beat_distance = getBeatDistance(getSampleOfTrack().current);
m_pThisBeatDistance->set(beat_distance);
if (getSyncMode() == SYNC_NONE) {
if (getSyncMode() <= SYNC_NONE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The same (or negated) comparison appears way too often and you can easily get it wrong. Please introduce a specialized function for this use case, e.g. bool isSynchronized(SyncMode syncMode) or whatever.

Copy link
Contributor

Choose a reason for hiding this comment

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

!isSynchronized()

Copy link
Contributor

Choose a reason for hiding this comment

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

Ping

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.

@@ -52,7 +52,7 @@ Syncable* BaseSyncableListener::getSyncableForGroup(const QString& group) {

bool BaseSyncableListener::syncDeckExists() const {
foreach (const Syncable* pSyncable, m_syncables) {
if (pSyncable->getSyncMode() != SYNC_NONE && pSyncable->getBaseBpm() > 0) {
if (pSyncable->getSyncMode() > SYNC_NONE && pSyncable->getBaseBpm() > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

...and please also add a new member function bool isSynchronized() const for convenience.

@daschuer
Copy link
Member Author

OK, Done.

@daschuer daschuer modified the milestones: 2.1.6, 2.1.7 Jan 1, 2019
@@ -64,7 +64,7 @@ int BaseSyncableListener::playingSyncDeckCount() const {

foreach (const Syncable* pSyncable, m_syncables) {
SyncMode sync_mode = pSyncable->getSyncMode();
if (sync_mode == SYNC_NONE) {
if (sync_mode <= SYNC_NONE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about this one?

return false;
}
continue;
}
if (theSyncable->isPlaying() && (theSyncable->getSyncMode() != SYNC_NONE)) {
if (theSyncable->isPlaying() && (isSynchonized)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Too many braces

// master bpm, our bpm value is adopted.
m_pEngineSync->requestBpmUpdate(this, bpm);
} else {
// SYNC_MASTER
Copy link
Contributor

Choose a reason for hiding this comment

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

DEBUG_ASSERT instead of comment

// Note: bpmcontrol has updated local_bpm just before
double local_bpm = m_pLocalBpm ? m_pLocalBpm->get() : 0.0;

if (getSyncMode() <= SYNC_NONE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

!isSynchronized()?

@@ -63,8 +63,7 @@ int BaseSyncableListener::playingSyncDeckCount() const {
int playing_sync_decks = 0;

foreach (const Syncable* pSyncable, m_syncables) {
SyncMode sync_mode = pSyncable->getSyncMode();
if (sync_mode == SYNC_NONE) {
if (!pSyncable->isSynchronized()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if (pSyncable->isSynchronized() && pSyncable->isPlaying()) {

@daschuer
Copy link
Member Author

daschuer commented Jan 5, 2019

done

@daschuer
Copy link
Member Author

daschuer commented Jan 9, 2019

Thank you for review.

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