Skip to content

Mastersyc double / half Bpm Fix. #6

Merged
ywwg merged 22 commits into
ywwg:mastersync-onemasterfrom
daschuer:mastersyc_onemaster2
Apr 26, 2020
Merged

Mastersyc double / half Bpm Fix. #6
ywwg merged 22 commits into
ywwg:mastersync-onemasterfrom
daschuer:mastersyc_onemaster2

Conversation

@daschuer
Copy link
Copy Markdown

This fixes some nasty double / half Bpm situations.

Please have a look at src/test/enginesynctest.cpp first.
The tests partly tests the old behavior and the code had workarounds to make the test still succeed.

I have adjusted the test to the new assumptions and cleaned up the code accordingly.

The main assumption are:

  • A master never changes speed due to other decks.
  • If I enable sync on one deck, only this deck changes tempo.

This works now with playing and paused decks in the same way.

I have also re-enabed the explicit master feature. The state is always accepted for a deck and keept in standby until the deck has a valid tempo. As we know bad things kan happen in the head of the night with it. But since it is only accessible by special mappings, it is OK for me.

Copy link
Copy Markdown
Owner

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

I tried to build this and got:

/home/owen/src/github/mixxx/src/mixer/basetrackplayer.cpp: In member function ‘void BaseTrackPlayerImpl::connectLoadedTrack()’:
/home/owen/src/github/mixxx/src/mixer/basetrackplayer.cpp:289:31: error: no matching function for call to ‘BaseTrackPlayerImpl::connect(std::__shared_ptr<Track, __gnu_cxx::_S_atomic>::element_type*, void (Track::*)(double), std::unique_ptr<ControlObject>::pointer, void (ControlProxy::*)(double))’
  289 |             &ControlProxy::set);

Comment thread src/engine/sync/internalclock.cpp Outdated
m_mode(SYNC_NONE),
m_iOldSampleRate(44100),
m_dOldBpm(124.0),
m_baseBpm(124.0),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

for consistency this should be m_dBaseBpm

Comment thread src/engine/sync/internalclock.cpp Outdated

void InternalClock::setMasterBaseBpm(double bpm) {
Q_UNUSED(bpm)
qDebug() << "InternalClock::getBaseBpm()" << m_baseBpm;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

make sure to remove debug comment or put them behind a conditional (preferred)

Comment thread src/test/enginesynctest.cpp Outdated
Comment thread src/test/enginesynctest.cpp Outdated
Comment thread src/test/enginesynctest.cpp Outdated
Depending on the event different slots of bpmconro and synccontrol where
called in different order. This leads to various hard to tack issues
because the cal heriarchy is unclear when reading signal slot connections.

Now bpmconrol is always updated before synccontrol and we onbly look to Beats.
Loading a track and changing beats are treated the same.
This avoids a tempo shift when the internal clock takes over from a perviouse master with half or double matched bpm.
@daschuer
Copy link
Copy Markdown
Author

Ups, that is a rebase issue, because I cant build the final branch anymore because I am on Xenial.
I need to rebase again to not produce failing commits.

@daschuer daschuer force-pushed the mastersyc_onemaster2 branch from 5fe1045 to 2c1b8e6 Compare April 21, 2020 21:43
@daschuer
Copy link
Copy Markdown
Author

Done. I hope it builds now.

Comment thread src/engine/sync/internalclock.cpp Outdated
m_iOldSampleRate(44100),
m_dOldBpm(124.0),
m_baseBpm(124.0),
m_dbaseBpm(124.0),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

please fix capitalization: m_dBaseBpm

@ywwg
Copy link
Copy Markdown
Owner

ywwg commented Apr 22, 2020

it builds now! And works. thanks! Just a couple small nits and then I'll merge into my branch

@daschuer
Copy link
Copy Markdown
Author

Done.

@ywwg ywwg merged commit b0e0f37 into ywwg:mastersync-onemaster Apr 26, 2020
ywwg pushed a commit that referenced this pull request Jun 17, 2020
Hercules DJControl Inpulse 200: Fix some code stye issues
ywwg pushed a commit that referenced this pull request Feb 6, 2021
@daschuer daschuer deleted the mastersyc_onemaster2 branch September 26, 2021 17:37
ywwg pushed a commit that referenced this pull request Mar 18, 2022
…h sync

When loading a track that is not yet present in the library (and thus
doesn't have any BPM because it hasn't been analyzed yet) while another
deck is playing and both decks have sync enabled, a debug assertion is
triggered:

    DEBUG ASSERT: "isValid()" in function double mixxx::Bpm::value() const at src/track/bpm.h:53
    Aborted (core dumped)

The backtrace looks as follows:

    #0  0x00007f175c87234c in __pthread_kill_implementation () at /usr/lib/libc.so.6
    #1  0x00007f175c8254b8 in raise () at /usr/lib/libc.so.6
    #2  0x00007f175c80f534 in abort () at /usr/lib/libc.so.6
    #3  0x00007f175cf05ee4 in qt_assert(char const*, char const*, int) () at /usr/lib/libQt5Core.so.5
    #4  0x000055deb2e67e1c in mixxx::(anonymous namespace)::handleMessage(QtMsgType, QMessageLogContext const&, QString const&) (type=<optimized out>, context=<optimized out>, input=<optimized out>) at src/util/logging.cpp:355
    #5  0x00007f175cf47128 in  () at /usr/lib/libQt5Core.so.5
    #6  0x00007f175cf3fd8a in  () at /usr/lib/libQt5Core.so.5
    #7  0x00007f175cf06526 in QMessageLogger::critical(char const*, ...) const () at /usr/lib/libQt5Core.so.5
    #8  0x000055deb2e5c720 in mixxx_debug_assert(char const*, char const*, int, char const*) (assertion=assertion@entry=0x55deb39bd0db "isValid()", file=file@entry=0x55deb39bbf30 "src/track/bpm.h", line=line@entry=53, function=function@entry=0x55deb39bbf08 "double mixxx::Bpm::value() const") at gsrc/util/assert.h:9
    #9  0x000055deb2ee7e7e in mixxx_debug_assert_return_true(char const*, char const*, int, char const*) (function=0x55deb39bbf08 "double mixxx::Bpm::value() const", line=53, file=0x55deb39bbf30 "src/track/bpm.h", assertion=0x55deb39bd0db "isValid()") at gsrc/util/assert.h:18
    #10 mixxx::Bpm::value() const (this=<synthetic pointer>) at src/track/bpm.h:53
    #11 mixxx::operator*(mixxx::Bpm, double) (multiple=1, bpm=...) at src/track/bpm.h:160
    #12 SyncControl::setLocalBpm(mixxx::Bpm) (this=<optimized out>, localBpm=...) at src/engine/sync/synccontrol.cpp:567
    #13 0x000055deb34c7ba3 in EngineBuffer::postProcess(int) (this=0x55deb56eb060, iBufferSize=2048) at src/engine/enginebuffer.cpp:1318
    #14 0x000055deb3139023 in EngineMaster::processChannels(int) (this=0x55deb5449440, iBufferSize=<optimized out>) at src/engine/enginemaster.cpp:383
    mixxxdj#15 0x000055deb31394f7 in EngineMaster::process(int) (this=0x55deb5449440, iBufferSize=iBufferSize@entry=2048) at src/engine/enginemaster.cpp:410
    mixxxdj#16 0x000055deb2f91d0b in SoundManager::onDeviceOutputCallback(long) (this=<optimized out>, iFramesPerBuffer=iFramesPerBuffer@entry=1024) at src/soundio/soundmanager.cpp:596
    mixxxdj#17 0x000055deb32dd794 in SoundDevicePortAudio::callbackProcessClkRef(long, float*, float const*, PaStreamCallbackTimeInfo const*, unsigned long) (this=0x55deb553e6b0, framesPerBuffer=1024, out=<optimized out>, in=<optimized out>, timeInfo=<optimized out>, statusFlags=<optimized out>) at src/soundio/sounddeviceportaudio.cpp:965

This happens because `newLocalBpm` is invalid when `localBpm` is
invalid. Trying to do sync decks while no tempo information is available
does not make sense, so we only synchronize decks if the local BPM is
available.
ywwg pushed a commit that referenced this pull request Jun 12, 2023
Silence some float conversion warnings by making conversion explicit
ywwg pushed a commit that referenced this pull request Feb 9, 2024
VersionStore: Remove Apple fallback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants