From af218bc06bb6fd03ef36f4feb87009f95f802c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 17 Jan 2018 21:16:30 +0100 Subject: [PATCH 1/8] Remove unnecessarry rounding --- src/engine/enginebuffer.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/engine/enginebuffer.cpp b/src/engine/enginebuffer.cpp index f7cedafc75f5..3ca3de6e6ffd 100644 --- a/src/engine/enginebuffer.cpp +++ b/src/engine/enginebuffer.cpp @@ -1176,9 +1176,6 @@ void EngineBuffer::processSeek(bool paused) { if ((seekType & SEEK_PHASE) && !paused && m_pQuantize->toBool()) { position = m_pBpmControl->getNearestPositionInPhase(position, true, true); } - - double newPlayFrame = position / kSamplesPerFrame; - position = round(newPlayFrame) * kSamplesPerFrame; if (position != m_filepos_play) { setNewPlaypos(position); } From 8d6a163fe0661f52b617f0da8c4168a503075578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 17 Jan 2018 22:34:08 +0100 Subject: [PATCH 2/8] Do not jump out of a loop if we adjust a phase (lp1743010) --- src/engine/enginebuffer.cpp | 8 +++++--- src/engine/enginebuffer.h | 2 +- src/engine/enginecontrol.cpp | 3 ++- src/engine/enginecontrol.h | 2 +- src/engine/loopingcontrol.cpp | 5 +++-- src/engine/loopingcontrol.h | 2 +- src/engine/ratecontrol.cpp | 3 ++- src/engine/ratecontrol.h | 2 +- src/engine/readaheadmanager.cpp | 2 +- src/test/readaheadmanager_test.cpp | 3 ++- 10 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/engine/enginebuffer.cpp b/src/engine/enginebuffer.cpp index 3ca3de6e6ffd..6e05b1917fb5 100644 --- a/src/engine/enginebuffer.cpp +++ b/src/engine/enginebuffer.cpp @@ -443,7 +443,7 @@ void EngineBuffer::readToCrossfadeBuffer(const int iBufferSize) { // WARNING: This method is not thread safe and must not be called from outside // the engine callback! -void EngineBuffer::setNewPlaypos(double newpos) { +void EngineBuffer::setNewPlaypos(double newpos, bool adjustingPhase) { //qDebug() << m_group << "engine new pos " << newpos; m_filepos_play = newpos; @@ -464,7 +464,7 @@ void EngineBuffer::setNewPlaypos(double newpos) { for (QList::iterator it = m_engineControls.begin(); it != m_engineControls.end(); ++it) { EngineControl *pControl = *it; - pControl->notifySeek(m_filepos_play); + pControl->notifySeek(m_filepos_play, adjustingPhase); } verifyPlay(); // verify or update play button and indicator @@ -1157,12 +1157,14 @@ void EngineBuffer::processSeek(bool paused) { seekType |= SEEK_PHASE; } + bool adjustingPhase = false; switch (seekType) { case SEEK_NONE: return; case SEEK_PHASE: // only adjust phase position = m_filepos_play; + adjustingPhase = true; break; case SEEK_EXACT: case SEEK_STANDARD: // = SEEK_EXACT | SEEK_PHASE @@ -1177,7 +1179,7 @@ void EngineBuffer::processSeek(bool paused) { position = m_pBpmControl->getNearestPositionInPhase(position, true, true); } if (position != m_filepos_play) { - setNewPlaypos(position); + setNewPlaypos(position, adjustingPhase); } } diff --git a/src/engine/enginebuffer.h b/src/engine/enginebuffer.h index 4148358410c3..dd20d30c968c 100644 --- a/src/engine/enginebuffer.h +++ b/src/engine/enginebuffer.h @@ -218,7 +218,7 @@ class EngineBuffer : public EngineObject { void readToCrossfadeBuffer(const int iBufferSize); // Reset buffer playpos and set file playpos. - void setNewPlaypos(double playpos); + void setNewPlaypos(double playpos, bool adjustingPhase); void processSyncRequests(); void processSeek(bool paused); diff --git a/src/engine/enginecontrol.cpp b/src/engine/enginecontrol.cpp index 9e8f1e9f28c1..632553ce5c09 100644 --- a/src/engine/enginecontrol.cpp +++ b/src/engine/enginecontrol.cpp @@ -99,8 +99,9 @@ void EngineControl::seek(double sample) { } } -void EngineControl::notifySeek(double dNewPlaypos) { +void EngineControl::notifySeek(double dNewPlaypos, bool adjustingPhase) { Q_UNUSED(dNewPlaypos); + Q_UNUSED(adjustingPhase); } EngineBuffer* EngineControl::pickSyncTarget() { diff --git a/src/engine/enginecontrol.h b/src/engine/enginecontrol.h index 550f16094bc7..1661a0b6821f 100644 --- a/src/engine/enginecontrol.h +++ b/src/engine/enginecontrol.h @@ -66,7 +66,7 @@ class EngineControl : public QObject { } // Called whenever a seek occurs to allow the EngineControl to respond. - virtual void notifySeek(double dNewPlaypo); + virtual void notifySeek(double dNewPlaypo, bool adjustingPhase); public slots: virtual void trackLoaded(TrackPointer pNewTrack, TrackPointer pOldTrack); diff --git a/src/engine/loopingcontrol.cpp b/src/engine/loopingcontrol.cpp index af981f6fe3e1..5d3cc9733ffd 100644 --- a/src/engine/loopingcontrol.cpp +++ b/src/engine/loopingcontrol.cpp @@ -752,12 +752,13 @@ void LoopingControl::slotLoopEndPos(double pos) { } // This is called from the engine thread -void LoopingControl::notifySeek(double dNewPlaypos) { +void LoopingControl::notifySeek(double dNewPlaypos, bool adjustingPhase) { LoopSamples loopSamples = m_loopSamples.getValue(); double currentSample = m_currentSample.getValue(); - if (m_bLoopingEnabled) { + if (m_bLoopingEnabled && !adjustingPhase) { // Disable loop when we jumping out, or over a catching loop, // using hot cues or waveform overview. + // Do not jump out of a loop if we adjust a phase (lp1743010) if (currentSample >= loopSamples.start && currentSample <= loopSamples.end && dNewPlaypos < loopSamples.start) { diff --git a/src/engine/loopingcontrol.h b/src/engine/loopingcontrol.h index 42141abde17f..11c1ca0ed148 100644 --- a/src/engine/loopingcontrol.h +++ b/src/engine/loopingcontrol.h @@ -48,7 +48,7 @@ class LoopingControl : public EngineControl { // sample, if set. void hintReader(HintVector* pHintList) override; - void notifySeek(double dNewPlaypos) override; + void notifySeek(double dNewPlaypos, bool adjustingPhase) override; public slots: void slotLoopIn(double pressed); diff --git a/src/engine/ratecontrol.cpp b/src/engine/ratecontrol.cpp index 6c28ebfb64cb..35739a3da3eb 100644 --- a/src/engine/ratecontrol.cpp +++ b/src/engine/ratecontrol.cpp @@ -669,6 +669,7 @@ void RateControl::resetRateTemp(void) setRateTemp(0.0); } -void RateControl::notifySeek(double playPos) { +void RateControl::notifySeek(double playPos, bool adjustingPhase) { + Q_UNUSED(adjustingPhase); m_pScratchController->notifySeek(playPos); } diff --git a/src/engine/ratecontrol.h b/src/engine/ratecontrol.h index c67d0cd531ce..bd8b407fe56f 100644 --- a/src/engine/ratecontrol.h +++ b/src/engine/ratecontrol.h @@ -92,7 +92,7 @@ class RateControl : public EngineControl { // Set Rate Ramp Sensitivity static void setRateRampSensitivity(int); static int getRateRampSensitivity(); - void notifySeek(double dNewPlaypos) override; + void notifySeek(double dNewPlaypos, bool adjustingPhase) override; public slots: void slotReverseRollActivate(double); diff --git a/src/engine/readaheadmanager.cpp b/src/engine/readaheadmanager.cpp index e10ae22e8b74..ee9dcd301234 100644 --- a/src/engine/readaheadmanager.cpp +++ b/src/engine/readaheadmanager.cpp @@ -237,7 +237,7 @@ double ReadAheadManager::getFilePlaypositionFromLog( // (Not looping control) if (shouldNotifySeek) { if (m_pRateControl) { - m_pRateControl->notifySeek(entry.virtualPlaypositionStart); + m_pRateControl->notifySeek(entry.virtualPlaypositionStart, false); } } diff --git a/src/test/readaheadmanager_test.cpp b/src/test/readaheadmanager_test.cpp index be03d6d8a8f8..5deec9bc4847 100644 --- a/src/test/readaheadmanager_test.cpp +++ b/src/test/readaheadmanager_test.cpp @@ -56,8 +56,9 @@ class StubLoopControl : public LoopingControl { Q_UNUSED(pHintList); } - void notifySeek(double dNewPlaypos) override { + void notifySeek(double dNewPlaypos, bool adjustingPhase) override { Q_UNUSED(dNewPlaypos); + Q_UNUSED(adjustingPhase); } public slots: From f1f1da12c8795c7d966614677817341167fa9027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 17 Jan 2018 23:25:30 +0100 Subject: [PATCH 3/8] Improve handling of beatloops bejond track end (lp1743885) --- src/engine/loopingcontrol.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/engine/loopingcontrol.cpp b/src/engine/loopingcontrol.cpp index 5d3cc9733ffd..82c33348e181 100644 --- a/src/engine/loopingcontrol.cpp +++ b/src/engine/loopingcontrol.cpp @@ -966,17 +966,8 @@ void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable } newloopSamples.end = m_pBeats->findNBeatsFromSample(newloopSamples.start, beats); - - if (newloopSamples.start == newloopSamples.end) { - if ((newloopSamples.end + 2) > samples) { - newloopSamples.start -= 2; - } else { - newloopSamples.end += 2; - } - } - - // Do not allow beat loops to go beyond the end of the track - if (newloopSamples.end > samples) { + if (newloopSamples.start >= newloopSamples.end // happens when the call above fails + || newloopSamples.end > samples) { // Do not allow beat loops to go beyond the end of the track // If a track is loaded with beatloop_size larger than // the distance between the loop in point and // the end of the track, let beatloop_size be set to From 68c3ebde2acc036399e294113b85c99c58da6168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 20 Jan 2018 17:39:43 +0100 Subject: [PATCH 4/8] Remove non thread save m_prviousSample --- src/engine/bpmcontrol.cpp | 8 +------- src/engine/bpmcontrol.h | 4 ---- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/engine/bpmcontrol.cpp b/src/engine/bpmcontrol.cpp index 54de67f699d5..06dbaf9af57c 100644 --- a/src/engine/bpmcontrol.cpp +++ b/src/engine/bpmcontrol.cpp @@ -25,7 +25,6 @@ const int kLocalBpmSpan = 4; BpmControl::BpmControl(QString group, UserSettingsPointer pConfig) : EngineControl(group, pConfig), - m_dPreviousSample(0), m_dSyncTargetBeatDistance(0.0), m_dSyncInstantaneousBpm(0.0), m_dLastSyncAdjustment(1.0), @@ -785,11 +784,6 @@ void BpmControl::slotBeatsTranslateMatchAlignment(double v) { } } -void BpmControl::setCurrentSample(const double dCurrentSample, const double dTotalSamples) { - m_dPreviousSample = dCurrentSample; - EngineControl::setCurrentSample(dCurrentSample, dTotalSamples); -} - double BpmControl::updateLocalBpm() { double prev_local_bpm = m_pLocalBpm->get(); double local_bpm = 0; @@ -810,7 +804,7 @@ double BpmControl::updateLocalBpm() { } double BpmControl::updateBeatDistance() { - double beat_distance = getBeatDistance(m_dPreviousSample); + double beat_distance = getBeatDistance(getCurrentSample()); m_pThisBeatDistance->set(beat_distance); if (getSyncMode() == SYNC_NONE) { m_dUserOffset = 0.0; diff --git a/src/engine/bpmcontrol.h b/src/engine/bpmcontrol.h index 7c1ed553dbdf..12e28297aa00 100644 --- a/src/engine/bpmcontrol.h +++ b/src/engine/bpmcontrol.h @@ -36,9 +36,7 @@ class BpmControl : public EngineControl { double getNearestPositionInPhase(double dThisPosition, bool respectLoops, bool playing); double getPhaseOffset(double dThisPosition); double getBeatDistance(double dThisPosition) const; - double getPreviousSample() const { return m_dPreviousSample; } - void setCurrentSample(const double dCurrentSample, const double dTotalSamples) override; void setTargetBeatDistance(double beatDistance); void setInstantaneousBpm(double instantaneousBpm); void resetSyncAdjustment(); @@ -148,8 +146,6 @@ class BpmControl : public EngineControl { // Button that translates beats to match another playing deck ControlPushButton* m_pBeatsTranslateMatchAlignment; - double m_dPreviousSample; - // Master Sync objects and values. ControlObject* m_pSyncMode; ControlProxy* m_pThisBeatDistance; From c4f0b099ae45db60ed8dd6cec0d49e204c596840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 20 Jan 2018 17:46:17 +0100 Subject: [PATCH 5/8] silence qDebug() from the engine thread --- src/engine/loopingcontrol.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/loopingcontrol.cpp b/src/engine/loopingcontrol.cpp index 82c33348e181..b798abb0232e 100644 --- a/src/engine/loopingcontrol.cpp +++ b/src/engine/loopingcontrol.cpp @@ -389,8 +389,8 @@ double LoopingControl::nextTrigger(bool reverse, m_oldLoopSamples = loopSamples; if (*pTarget != kNoTrigger) { // jump immediately - qDebug() << currentSample << - m_oldLoopSamples.start << loopSamples.start << loopSamples.end; + //qDebug() << currentSample << + // m_oldLoopSamples.start << loopSamples.start << loopSamples.end; return currentSample; } } From aa0fef183a0c6d73f688df613d91af155658b5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 20 Jan 2018 18:29:23 +0100 Subject: [PATCH 6/8] Fix escaping small beatloops lp1744162 --- src/engine/loopingcontrol.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/engine/loopingcontrol.cpp b/src/engine/loopingcontrol.cpp index b798abb0232e..c948b4e28655 100644 --- a/src/engine/loopingcontrol.cpp +++ b/src/engine/loopingcontrol.cpp @@ -385,6 +385,22 @@ double LoopingControl::nextTrigger(bool reverse, // should be moved with it *pTarget = seekInsideAdjustedLoop(currentSample, m_oldLoopSamples.start, loopSamples.start, loopSamples.end); + } else { + bool movedOut = false; + // Ceck if we have moved out of the loop, before we could enable it + if (reverse) { + if (m_oldLoopSamples.start > currentSample) { + movedOut = true; + } + } else { + if (m_oldLoopSamples.end < currentSample) { + movedOut = true; + } + } + if (movedOut) { + *pTarget = seekInsideAdjustedLoop(currentSample, + loopSamples.start, loopSamples.start, loopSamples.end); + } } m_oldLoopSamples = loopSamples; if (*pTarget != kNoTrigger) { From 1fc190eee7bb3dd3c2552238a12ae663d377786c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 20 Jan 2018 22:19:27 +0100 Subject: [PATCH 7/8] fix typo --- src/engine/loopingcontrol.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/engine/loopingcontrol.cpp b/src/engine/loopingcontrol.cpp index c948b4e28655..cc69e2babdd7 100644 --- a/src/engine/loopingcontrol.cpp +++ b/src/engine/loopingcontrol.cpp @@ -389,11 +389,11 @@ double LoopingControl::nextTrigger(bool reverse, bool movedOut = false; // Ceck if we have moved out of the loop, before we could enable it if (reverse) { - if (m_oldLoopSamples.start > currentSample) { + if (loopSamples.start > currentSample) { movedOut = true; } } else { - if (m_oldLoopSamples.end < currentSample) { + if (loopSamples.end < currentSample) { movedOut = true; } } @@ -406,7 +406,7 @@ double LoopingControl::nextTrigger(bool reverse, if (*pTarget != kNoTrigger) { // jump immediately //qDebug() << currentSample << - // m_oldLoopSamples.start << loopSamples.start << loopSamples.end; + // m_oldLoopSamples.start << loopSamples.start << loopSamples.end << pTarget; return currentSample; } } @@ -1135,7 +1135,6 @@ void LoopingControl::slotLoopMove(double beats) { int LoopingControl::seekInsideAdjustedLoop( double currentSample, double old_loop_in, double new_loop_in, double new_loop_out) { - // Copy on stack since m_iCurrentSample sample can change under us. if (currentSample >= new_loop_in && currentSample <= new_loop_out) { // playposition already is inside the loop return kNoTrigger; From 07dca3a555837149e8485b84bfd02080a82ce958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 21 Jan 2018 21:54:09 +0100 Subject: [PATCH 8/8] Improve comments --- src/engine/loopingcontrol.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/engine/loopingcontrol.cpp b/src/engine/loopingcontrol.cpp index cc69e2babdd7..c9fedc5a160c 100644 --- a/src/engine/loopingcontrol.cpp +++ b/src/engine/loopingcontrol.cpp @@ -387,7 +387,7 @@ double LoopingControl::nextTrigger(bool reverse, m_oldLoopSamples.start, loopSamples.start, loopSamples.end); } else { bool movedOut = false; - // Ceck if we have moved out of the loop, before we could enable it + // Check if we have moved out of the loop, before we could enable it if (reverse) { if (loopSamples.start > currentSample) { movedOut = true; @@ -405,8 +405,6 @@ double LoopingControl::nextTrigger(bool reverse, m_oldLoopSamples = loopSamples; if (*pTarget != kNoTrigger) { // jump immediately - //qDebug() << currentSample << - // m_oldLoopSamples.start << loopSamples.start << loopSamples.end << pTarget; return currentSample; } }