-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Enable beatloop activation directly after activating a hotcue #2190
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
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7a418a7
set loop position to queued seek position before activating beatloop
goddisignz 255fd69
implemented most requested changes
goddisignz c8f9a5b
added parameter for synchronized position in engines "notifySeek"
goddisignz cc375f6
Revert "added parameter for synchronized position in engines "notifyS…
goddisignz d441ca8
let the loopingcontroller adjust synced seeks if necessary
goddisignz 2fdffa2
prevent jumping out of loop if loop is smaller than one bar
goddisignz 7ea5f07
remove obsolete adjustingPhase parameter
goddisignz 0d1cb49
do not unset m_iSeekQueued before controls have been notified
goddisignz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,11 +5,12 @@ | |
| #include <QtDebug> | ||
|
|
||
| #include "control/controlobject.h" | ||
| #include "preferences/usersettings.h" | ||
| #include "control/controlpushbutton.h" | ||
| #include "engine/controls/loopingcontrol.h" | ||
| #include "engine/controls/bpmcontrol.h" | ||
| #include "engine/controls/enginecontrol.h" | ||
| #include "engine/controls/loopingcontrol.h" | ||
| #include "engine/enginebuffer.h" | ||
| #include "preferences/usersettings.h" | ||
| #include "util/compatibility.h" | ||
| #include "util/math.h" | ||
| #include "util/sample.h" | ||
|
|
@@ -768,22 +769,21 @@ void LoopingControl::slotLoopEndPos(double pos) { | |
| } | ||
|
|
||
| // This is called from the engine thread | ||
| void LoopingControl::notifySeek(double dNewPlaypos, bool adjustingPhase) { | ||
| void LoopingControl::notifySeek(double dNewPlaypos) { | ||
| LoopSamples loopSamples = m_loopSamples.getValue(); | ||
| double currentSample = m_currentSample.getValue(); | ||
| if (m_bLoopingEnabled && !adjustingPhase) { | ||
| if (m_bLoopingEnabled) { | ||
| // 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) { | ||
| // jumping out of loop in backwards | ||
| setLoopingEnabled(false); | ||
| } | ||
| if (currentSample <= loopSamples.end && | ||
| dNewPlaypos > loopSamples.end) { | ||
| // jumping out a loop or over a catching loop forward | ||
| dNewPlaypos >= loopSamples.end) { | ||
| // jumping out or to the exact end of a loop or over a catching loop forward | ||
| setLoopingEnabled(false); | ||
| } | ||
| } | ||
|
|
@@ -806,6 +806,55 @@ bool LoopingControl::isLoopingEnabled() { | |
| return m_bLoopingEnabled; | ||
| } | ||
|
|
||
| double LoopingControl::getSyncPositionInsideLoop(double dRequestedPlaypos, double dSyncedPlayPos) { | ||
| // no loop, no adjustment | ||
| if (!m_bLoopingEnabled) { | ||
| return dSyncedPlayPos; | ||
| } | ||
|
|
||
| LoopSamples loopSamples = m_loopSamples.getValue(); | ||
|
|
||
| // if the request itself is outside loop do nothing | ||
| // loop will be disabled later by notifySeek(...) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or does it make sense to have the loop disable logic here? |
||
| if (dRequestedPlaypos < loopSamples.start || dRequestedPlaypos >= loopSamples.end) { | ||
| return dSyncedPlayPos; | ||
| } | ||
|
|
||
| // the requested position is inside the loop (e.g hotcue at start) | ||
| double loopSize = loopSamples.end - loopSamples.start; | ||
|
|
||
| // the synced position is in front of the loop | ||
| // adjust the synced position to same amount in front of the loop end | ||
| if (dSyncedPlayPos <= loopSamples.start) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be just < |
||
| double adjustment = loopSamples.start - dSyncedPlayPos; | ||
|
|
||
| // if the adjustment is larger then the loop subtract N times the loopsize | ||
| // prevents jumping in front of the loop | ||
| // works like modulo on doubles | ||
| int numLoopsInAdjustment = adjustment / loopSize; | ||
| adjustment = adjustment - (numLoopsInAdjustment * loopSize); | ||
|
|
||
| return loopSamples.end - adjustment; | ||
| } | ||
|
|
||
| // the synced position is behind the loop | ||
| // adjust the synced position to same amount behind the loop start | ||
| if (dSyncedPlayPos >= loopSamples.end) { | ||
| double adjustment = dSyncedPlayPos - loopSamples.end; | ||
|
|
||
| // if the adjustment is larger then the loop subtract N times the loopsize | ||
| // prevents jumping behind the loop | ||
| // works like modulo on doubles | ||
| int numLoopsInAdjustment = adjustment / loopSize; | ||
| adjustment = adjustment - (numLoopsInAdjustment * loopSize); | ||
|
|
||
| return loopSamples.start + adjustment; | ||
| } | ||
|
|
||
| // both, requested and synced position are inside the loop -> do nothing | ||
| return dSyncedPlayPos; | ||
| } | ||
|
|
||
| void LoopingControl::trackLoaded(TrackPointer pNewTrack) { | ||
| if (m_pTrack) { | ||
| disconnect(m_pTrack.get(), &Track::beatsUpdated, | ||
|
|
@@ -958,6 +1007,13 @@ void LoopingControl::updateBeatLoopingControls() { | |
| } | ||
|
|
||
| void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable) { | ||
| // if a seek was queued in the engine buffer move the current sample to its position | ||
| double p_seekPosition = 0; | ||
| if (getEngineBuffer()->isSeekQueued(&p_seekPosition)) { | ||
| // seek position is already quantized if quantization is enabled | ||
| m_currentSample.setValue(p_seekPosition); | ||
| } | ||
|
|
||
| double maxBeatSize = s_dBeatSizes[sizeof(s_dBeatSizes)/sizeof(s_dBeatSizes[0]) - 1]; | ||
| double minBeatSize = s_dBeatSizes[0]; | ||
| if (beats < 0) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.