Skip to content
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

Fix sharp cut transition after cueing a track without a defined intro #11629

Merged
merged 3 commits into from
Jun 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Comment on lines +1284 to +1290
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this limitation? IIUC if the user seeks far before the intro, then this will just skip the fade, does this make sense? Why would this be desirable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imagine a live recording with some introduction words.
The user probably has marked an intro when the music starts. Without this change and with a previous track without an outro the loooong intro time is used for fading if it is cued at 0:00. This is likely not desired. Now the transition time from the spin box is used in this case.

The other use case is the part of the bug fix. If the track is cued at intro start and the user touches the jog for a small seek. The intro is still used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense I guess. I just worry about the complexity this introduces. AutoDJ is already quite unpredictable IMO and this doesn't make it any better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also a drop in the bucket, so who cares...

}
}

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