Skip to content

Commit

Permalink
Merge pull request #11629 from daschuer/gh11621
Browse files Browse the repository at this point in the history
Fix sharp cut transition after cueing a track without a defined intro
  • Loading branch information
Swiftb0y authored Jun 12, 2023
2 parents 8749e1f + c03d885 commit 6385f30
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,23 +1266,29 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
}
pToDeck->fadeBeginPos = toDeckOutroStartSecond;

double introStart;
double toDeckStartSeconds = toDeckPositionSeconds;
const double introStart = getIntroStartSecond(pToDeck);
const double introEnd = getIntroEndSecond(pToDeck);
if (seekToStartPoint || toDeckPositionSeconds >= pToDeck->fadeBeginPos) {
// toDeckPosition >= pToDeck->fadeBeginPos happens when the
// user has seeked or played the to track behind fadeBeginPos of
// the fade after the next.
// In this case we recue the track just before the transition.
introStart = getIntroStartSecond(pToDeck);
} else {
introStart = toDeckPositionSeconds;
toDeckStartSeconds = introStart;
}

double introLength = 0;

// This returns introStart in case the user has not yet set an intro end
const double introEnd = getIntroEndSecond(pToDeck);
if (introStart < introEnd) {
introLength = introEnd - introStart;
// introEnd is equal introStart in case it has not yet been set
if (toDeckStartSeconds < introEnd && introStart < introEnd) {
// Limit the intro length that results from a revers seek
// to a reasonable values. If the seek was too big, ignore it.
introLength = introEnd - toDeckStartSeconds;
if (introLength > (introEnd - introStart) * 2 &&
introLength > (introEnd - introStart) + m_transitionTime &&
introLength > outroLength) {
introLength = 0;
}
}

if constexpr (sDebug) {
Expand Down Expand Up @@ -1323,20 +1329,20 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
}
}
if (transitionLength > 0) {
const double transitionEnd = introStart + transitionLength;
const double transitionEnd = toDeckStartSeconds + transitionLength;
if (transitionEnd > pToDeck->fadeBeginPos) {
// End intro before next outro starts
transitionLength = pToDeck->fadeBeginPos - introStart;
transitionLength = pToDeck->fadeBeginPos - toDeckStartSeconds;
VERIFY_OR_DEBUG_ASSERT(transitionLength > 0) {
// We seek to intro start above in this case so this never happens
transitionLength = 1;
}
}
pFromDeck->fadeBeginPos = outroEnd - transitionLength;
pFromDeck->fadeEndPos = outroEnd;
pToDeck->startPos = introStart;
pToDeck->startPos = toDeckStartSeconds;
} else {
useFixedFadeTime(pFromDeck, pToDeck, fromDeckPosition, outroEnd, introStart);
useFixedFadeTime(pFromDeck, pToDeck, fromDeckPosition, outroEnd, toDeckStartSeconds);
}
} break;
case TransitionMode::FadeAtOutroStart: {
Expand Down Expand Up @@ -1369,25 +1375,25 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
transitionLength = introLength;
}
}
const double transitionEnd = introStart + transitionLength;
const double transitionEnd = toDeckStartSeconds + transitionLength;
if (transitionEnd > pToDeck->fadeBeginPos) {
// End intro before next outro starts
transitionLength = pToDeck->fadeBeginPos - introStart;
transitionLength = pToDeck->fadeBeginPos - toDeckStartSeconds;
VERIFY_OR_DEBUG_ASSERT(transitionLength > 0) {
// We seek to intro start above in this case so this never happens
transitionLength = 1;
}
}
pFromDeck->fadeBeginPos = outroStart;
pFromDeck->fadeEndPos = outroStart + transitionLength;
pToDeck->startPos = introStart;
pToDeck->startPos = toDeckStartSeconds;
} else if (introLength > 0) {
transitionLength = introLength;
pFromDeck->fadeBeginPos = outroEnd - transitionLength;
pFromDeck->fadeEndPos = outroEnd;
pToDeck->startPos = introStart;
pToDeck->startPos = toDeckStartSeconds;
} else {
useFixedFadeTime(pFromDeck, pToDeck, fromDeckPosition, outroEnd, introStart);
useFixedFadeTime(pFromDeck, pToDeck, fromDeckPosition, outroEnd, toDeckStartSeconds);
}
} break;
case TransitionMode::FixedSkipSilence: {
Expand Down

0 comments on commit 6385f30

Please sign in to comment.