forked from mixxxdj/mixxx
-
Notifications
You must be signed in to change notification settings - Fork 3
AutoDJProcessorTest.FadeToDeck2_Long_Transition fix #34
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
Merged
Be-ing
merged 19 commits into
Be-ing:autodj_intro_outro
from
daschuer:autodj_intro_outro
Nov 7, 2019
Merged
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c1010a6
make emitLoadTrackToPlayer and emitAutoDJStateChanged a protected non…
daschuer cf658a9
move no outro start fallback code into getOutroStartPosition()
daschuer df29633
consider current position of the from deck after chaning the transiti…
daschuer 2b1f525
fix AutoDJProcessorTest.FadeToDeck2_Long_Transition test. This fixes …
daschuer 5e6988e
Cache hasFadeTransition before possible override
daschuer 74fdcb8
Adjust FadeToDeck2_Pause_Transition for no fading transitions
daschuer 277f5da
improve comments
daschuer 96a5a45
improve error handing in case of -1 cue positions.
daschuer 873e313
improve crossfaderChanged()
daschuer d6e6cf4
Adjust short track workaround in outro start mode
daschuer 70214df
Adjust intro and outro change slots
daschuer e1c45e5
don't bother with playing state when calculating a new transition
daschuer 6dac3a6
Don't use non cons references in playerPositionChanged() and remove f…
daschuer fd36927
Don't use non const references in toggleAutoDJ()
daschuer 2f88f54
Reset startPos, just in case calculateTransition() is not able to set…
daschuer 7036b74
Set the just loaded deck as toDeck
daschuer 9951daa
respect the rate slider when calculating auto-DJ transitions
daschuer db49654
Whatch rate changes
daschuer efa6c00
fix recursive positionChanged call. Fix omitting fist seek.
daschuer 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -622,14 +622,16 @@ void AutoDJProcessor::playerPositionChanged(DeckAttributes* pAttributes, | |
| } | ||
|
|
||
| if (m_eState == ADJ_IDLE) { | ||
| if (!thisDeckPlaying) { | ||
| if (!thisDeckPlaying && thisPlayPosition < 1) { | ||
| // this is a cueing seek, recalculate the transition, from the | ||
| // new position. | ||
| // This can be our own seek to startPos or a random seek by a user. | ||
| // we need to call calculateTransition() because we are not sure. | ||
| // If using the full track mode with a transition time of 0, | ||
| // thisDeckPlaying will be false but the transition should not be | ||
| // recalculated here. | ||
| // Don't adjust transition when reaching the end. In this case it is | ||
| // always stopped. | ||
| calculateTransition(&otherDeck, &thisDeck, false); | ||
| } else if (thisDeck.isRepeat()) { | ||
| // repeat pauses auto DJ | ||
|
|
@@ -644,6 +646,8 @@ void AutoDJProcessor::playerPositionChanged(DeckAttributes* pAttributes, | |
| if (thisPlayPosition >= thisDeck.fadeBeginPos && thisDeck.isFromDeck) { | ||
| if (m_eState == ADJ_IDLE) { | ||
| if (thisDeckPlaying || thisPlayPosition >= 1.0) { | ||
| // cache this before calculating the new transition in otherDeck.play(); | ||
| bool hasFadeTransition = thisDeck.fadeBeginPos < thisDeck.fadeEndPos; | ||
| if (!otherDeckPlaying) { | ||
| // Re-cue the track if the user has seeked it to the very end | ||
| if (otherDeck.playPosition() >= otherDeck.fadeBeginPos) { | ||
|
|
@@ -656,6 +660,12 @@ void AutoDJProcessor::playerPositionChanged(DeckAttributes* pAttributes, | |
| // that was "on deck" from the top of the queue. | ||
| removeLoadedTrackFromTopOfQueue(otherDeck); | ||
|
|
||
| if (!hasFadeTransition) { | ||
| setCrossfader(thisDeck.isLeft() ? 1.0 : -1.0); | ||
| thisDeck.stop(); | ||
| loadNextTrackFromQueue(thisDeck); | ||
| return; | ||
| } | ||
| m_transitionProgress = 0.0; | ||
| // Set the state as FADING. | ||
| m_eState = thisDeck.isLeft() ? ADJ_LEFT_FADING : ADJ_RIGHT_FADING; | ||
|
|
@@ -685,24 +695,6 @@ void AutoDJProcessor::playerPositionChanged(DeckAttributes* pAttributes, | |
| m_transitionProgress = 1.0; | ||
| } else { | ||
| // We are in Fading state. | ||
|
|
||
| // The math below will not work with a transition time of 0. | ||
| if (thisDeck.fadeBeginPos == thisDeck.fadeEndPos) { | ||
| setCrossfader(crossfaderTarget); | ||
| m_transitionProgress = 1.0; | ||
| // Usually code above will take care of these steps when the | ||
| // playposition updates again, however this does not occur when | ||
| // using the Full Track mode with a fade time of 0 because the | ||
| // toDeck stops. | ||
| if (thisPlayPosition >= 1) { | ||
| otherDeck.play(); | ||
| loadNextTrackFromQueue(thisDeck); | ||
| m_eState = ADJ_IDLE; | ||
| emitAutoDJStateChanged(m_eState); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| // Calculate the current transitionProgress, the place between begin | ||
| // and end position and the step we have taken since the last call | ||
| double transitionProgress = (thisPlayPosition - thisDeck.fadeBeginPos) / | ||
|
|
@@ -932,7 +924,15 @@ double AutoDJProcessor::getIntroEndPosition(DeckAttributes* pDeck) { | |
| } | ||
|
|
||
| double AutoDJProcessor::getOutroStartPosition(DeckAttributes* pDeck) { | ||
| return samplePositionToSeconds(pDeck->outroStartPosition(), pDeck); | ||
| double outroStart = samplePositionToSeconds(pDeck->outroStartPosition(), pDeck); | ||
| if (outroStart < 0.0) { | ||
| // Assume a zero length outro if outroStartIsNot set. | ||
| // The outroEnd is automatically placed by AnalyzerSilence, so use | ||
| // that as a fallback if the user has not placed outroStart. If it has | ||
| // not been placed, getOutroEndPosition will return the end of the track. | ||
| outroStart = getOutroEndPosition(pDeck); | ||
| } | ||
| return outroStart; | ||
| } | ||
|
|
||
| double AutoDJProcessor::getOutroEndPosition(DeckAttributes* pDeck) { | ||
|
|
@@ -1037,13 +1037,6 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, | |
| double outroStart = getOutroStartPosition(pFromDeck); | ||
| double fromDeckPosition = pFromDeck->playPosition() * pFromDeck->duration(); | ||
|
|
||
| if (outroStart <= 0.0) { | ||
| // Assume a zero length outro. | ||
| // The outroEnd is automatically placed by AnalyzerSilence, so use | ||
| // that as a fallback if the user has not placed outroStart. If it has | ||
| // not been placed, getOutroEndPosition will return the end of the track. | ||
| outroStart = outroEnd; | ||
| } | ||
| if (fromDeckPosition > outroStart) { | ||
| // We have already passed outroStart | ||
| // This can happen if we have just enabled auto DJ | ||
|
|
@@ -1060,6 +1053,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, | |
| // here it is done for FullIntroOutro and FadeAtOutroStart. | ||
| // It is adjusted below for the other modes. | ||
| pToDeck->fadeBeginPos = getOutroStartPosition(pToDeck); | ||
| pToDeck->fadeEndPos = getOutroEndPosition(pToDeck); | ||
|
|
||
| double introStart; | ||
| if (seekToStartPoint || toDeckPosition >= pToDeck->fadeBeginPos) { | ||
|
|
@@ -1136,7 +1130,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, | |
| pFromDeck->fadeEndPos = outroEnd; | ||
| pToDeck->startPos = introStart; | ||
| } else { | ||
| useFixedFadeTime(pFromDeck, pToDeck, outroEnd, introStart); | ||
| useFixedFadeTime(pFromDeck, pToDeck, fromDeckPosition, outroEnd, introStart); | ||
| } | ||
| break; | ||
| case TransitionMode::FadeAtOutroStart: | ||
|
|
@@ -1191,7 +1185,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, | |
| pFromDeck->fadeEndPos = outroEnd; | ||
| pToDeck->startPos = introStart; | ||
| } else { | ||
| useFixedFadeTime(pFromDeck, pToDeck, outroEnd, introStart); | ||
| useFixedFadeTime(pFromDeck, pToDeck, fromDeckPosition, outroEnd, introStart); | ||
| } | ||
| break; | ||
| case TransitionMode::FixedSkipSilence: | ||
|
|
@@ -1208,6 +1202,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, | |
| startPoint = toDeckPosition; | ||
| } | ||
| useFixedFadeTime(pFromDeck, pToDeck, | ||
| fromDeckPosition, | ||
| getLastSoundPosition(pFromDeck), | ||
| startPoint); | ||
| } | ||
|
|
@@ -1227,6 +1222,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, | |
| startPoint = toDeckPosition; | ||
| } | ||
| useFixedFadeTime(pFromDeck, pToDeck, | ||
| fromDeckPosition, | ||
| pFromDeck->duration(), | ||
| startPoint); | ||
| } | ||
|
|
@@ -1237,6 +1233,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, | |
| pFromDeck->fadeEndPos /= fromTrackDuration; | ||
| pToDeck->startPos /= toTrackDuration; | ||
| pToDeck->fadeBeginPos /= toTrackDuration; | ||
| pToDeck->fadeEndPos /= toTrackDuration; | ||
|
|
||
| pFromDeck->isFromDeck = true; | ||
| pToDeck->isFromDeck = false; | ||
|
|
@@ -1251,11 +1248,15 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, | |
| } | ||
|
|
||
| void AutoDJProcessor::useFixedFadeTime(DeckAttributes* pFromDeck, | ||
| DeckAttributes* pToDeck, double endPoint, double startPoint) { | ||
| DeckAttributes* pToDeck, double fromDeckPosition, double endPoint, double startPoint) { | ||
| if (m_transitionTime > 0.0) { | ||
| // Guard against the next track being too short. This transition must finish | ||
| // before the next transition starts. | ||
| double toDeckOutroStart = pToDeck->fadeBeginPos; | ||
| if (pToDeck->fadeBeginPos >= pToDeck->fadeEndPos) { | ||
| // no outro defined, the toDeck will also use the transition time | ||
| toDeckOutroStart -= m_transitionTime; | ||
| } | ||
| if (toDeckOutroStart <= startPoint) { | ||
| // we are already too late | ||
| // Check OutroEnd as alternative, which is for all transition mode | ||
|
|
@@ -1275,12 +1276,12 @@ void AutoDJProcessor::useFixedFadeTime(DeckAttributes* pFromDeck, | |
| double transitionTime = math_min(toDeckOutroStart - startPoint, | ||
| m_transitionTime); | ||
|
|
||
| pFromDeck->fadeBeginPos = endPoint - transitionTime; | ||
| pFromDeck->fadeBeginPos = math_max(endPoint - transitionTime, fromDeckPosition); | ||
| pFromDeck->fadeEndPos = endPoint; | ||
| pToDeck->startPos = startPoint; | ||
| } else { | ||
| pFromDeck->fadeBeginPos = endPoint; | ||
| pFromDeck->fadeEndPos = endPoint - m_transitionTime; | ||
| pFromDeck->fadeEndPos = endPoint; | ||
|
Owner
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. This breaks fading with a negative transition time. AutoDJ stops in this case.
Author
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. This was causes elsewhere, but fixed now. |
||
| pToDeck->startPos = startPoint + m_transitionTime; | ||
| } | ||
| } | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When could this be false? It is not obvious. At first glance it seems like this should be a debug assert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is always false, if you use a negative or zero transition time.
I will add a comment.