diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2020-08-03 22:49:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-03 22:49:10 +0200 |
commit | cd7c3e0f29862e6eda3b378dd5096f7d1695a708 (patch) | |
tree | fd3fd103affcd74fbd494605cc5f1a73f0329243 | |
parent | 6630ff70572f94d72cd0aadc34e8837b9053950f (diff) | |
parent | 0f983aa09fa3b0f9dabbb1e586c81f1ff6c32b8d (diff) |
Merge pull request #2951 from daschuer/autodj_test_debug_assert
Autodj test debug assert
-rw-r--r-- | src/library/autodj/autodjprocessor.cpp | 88 | ||||
-rw-r--r-- | src/test/autodjprocessor_test.cpp | 2 |
2 files changed, 39 insertions, 51 deletions
diff --git a/src/library/autodj/autodjprocessor.cpp b/src/library/autodj/autodjprocessor.cpp index 2f11e7e569..252171bed4 100644 --- a/src/library/autodj/autodjprocessor.cpp +++ b/src/library/autodj/autodjprocessor.cpp @@ -1223,7 +1223,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, double introLength = introEnd - introStart; switch (m_transitionMode) { - case TransitionMode::FullIntroOutro: + case TransitionMode::FullIntroOutro: { // Use the outro or intro length for the transition time, whichever is // shorter. Let the full outro and intro play; do not cut off any part // of either. @@ -1245,41 +1245,32 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, // If only the outro or intro length is marked but not both, use the one // that is marked for the transition time. If neither is marked, fall // back to the transition time from the spinbox. - if (outroLength > 0 && introLength > 0) { - if (outroLength > introLength) { - pFromDeck->fadeBeginPos = outroEnd - introLength; - pFromDeck->fadeEndPos = outroEnd; - pToDeck->startPos = introStart; - } else { - pFromDeck->fadeBeginPos = outroStart; - pFromDeck->fadeEndPos = outroEnd; - pToDeck->startPos = introStart; + double transitionLength = introLength; + if (outroLength > 0) { + if (transitionLength <= 0 || transitionLength > outroLength) { + // Use outro length when the intro is not defined or longer + // than the outro. + transitionLength = outroLength; } - } else if (outroLength > 0 && introLength <= 0) { - if (outroLength + introStart < pToDeck->fadeBeginPos) { - pFromDeck->fadeBeginPos = outroStart; - } else { - // This happens if the toDeck track has no intro set and the - // outro of the fromDeck track is longer than the whole toDeck - // track - outroLength = pToDeck->fadeBeginPos - introStart; - VERIFY_OR_DEBUG_ASSERT(outroLength > 0) { + } + if (transitionLength > 0) { + const double transitionEnd = introStart + transitionLength; + if (transitionEnd > pToDeck->fadeBeginPos) { + // End intro before next outro starts + transitionLength = pToDeck->fadeBeginPos - introStart; + VERIFY_OR_DEBUG_ASSERT(transitionLength > 0) { // We seek to intro start above in this case so this never happens - outroLength = 1; + transitionLength = 1; } - pFromDeck->fadeBeginPos = outroEnd - outroLength; } - pFromDeck->fadeEndPos = outroEnd; - pToDeck->startPos = introStart; - } else if (introLength > 0 && outroLength <= 0) { - pFromDeck->fadeBeginPos = outroEnd - introLength; + pFromDeck->fadeBeginPos = outroEnd - transitionLength; pFromDeck->fadeEndPos = outroEnd; pToDeck->startPos = introStart; } else { useFixedFadeTime(pFromDeck, pToDeck, fromDeckPosition, outroEnd, introStart); } - break; - case TransitionMode::FadeAtOutroStart: + } break; + case TransitionMode::FadeAtOutroStart: { // Use the outro or intro length for the transition time, whichever is // shorter. If the outro is longer than the intro, cut off the end // of the outro. @@ -1301,40 +1292,35 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, // If only the outro or intro length is marked but not both, use the one // that is marked for the transition time. If neither is marked, fall // back to the transition time from the spinbox. - if (outroLength > 0 && introLength > 0) { - pFromDeck->fadeBeginPos = outroStart; - if (outroLength > introLength) { - // Cut off end of outro - pFromDeck->fadeEndPos = outroStart + introLength; - } else { - pFromDeck->fadeEndPos = outroEnd; + double transitionLength = outroLength; + if (transitionLength > 0) { + if (introLength > 0) { + if (outroLength > introLength) { + // Cut off end of outro + transitionLength = introLength; + } } - pToDeck->startPos = introStart; - } else if (outroLength > 0 && introLength <= 0) { - if (outroLength + introStart < pToDeck->fadeBeginPos) { - pFromDeck->fadeBeginPos = outroStart; - pFromDeck->fadeEndPos = outroEnd; - } else { - // This happens if the toDeck track has no intro set and the - // outro of the fromDeck track is longer than the whole toDeck - // track - outroLength = pToDeck->fadeBeginPos - introStart; - VERIFY_OR_DEBUG_ASSERT(outroLength > 0) { + const double transitionEnd = introStart + transitionLength; + if (transitionEnd > pToDeck->fadeBeginPos) { + // End intro before next outro starts + transitionLength = pToDeck->fadeBeginPos - introStart; + VERIFY_OR_DEBUG_ASSERT(transitionLength > 0) { // We seek to intro start above in this case so this never happens - outroLength = 1; + transitionLength = 1; } - pFromDeck->fadeBeginPos = outroStart; - pFromDeck->fadeEndPos = outroStart + outroLength; } + pFromDeck->fadeBeginPos = outroStart; + pFromDeck->fadeEndPos = outroStart + transitionLength; pToDeck->startPos = introStart; - } else if (introLength > 0 && outroLength <= 0) { - pFromDeck->fadeBeginPos = outroEnd - introLength; + } else if (introLength > 0) { + transitionLength = introLength; + pFromDeck->fadeBeginPos = outroEnd - transitionLength; pFromDeck->fadeEndPos = outroEnd; pToDeck->startPos = introStart; } else { useFixedFadeTime(pFromDeck, pToDeck, fromDeckPosition, outroEnd, introStart); } - break; + } break; case TransitionMode::FixedSkipSilence: { double startPoint; pToDeck->fadeBeginPos = getLastSoundSecond(pToDeck); diff --git a/src/test/autodjprocessor_test.cpp b/src/test/autodjprocessor_test.cpp index 77bad5411c..ce85211060 100644 --- a/src/test/autodjprocessor_test.cpp +++ b/src/test/autodjprocessor_test.cpp @@ -51,6 +51,8 @@ class FakeDeck : public BaseTrackPlayer { outroEndPos(ConfigKey(group, "outro_end_position")) { play.setButtonMode(ControlPushButton::TOGGLE); repeat.setButtonMode(ControlPushButton::TOGGLE); + outroStartPos.set(Cue::kNoPosition); + outroEndPos.set(Cue::kNoPosition); } void fakeTrackLoadedEvent(TrackPointer pTrack) { |