Skip to content
Open
Changes from 1 commit
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
36 changes: 36 additions & 0 deletions src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,42 @@ void AutoDJProcessor::playerPositionChanged(DeckAttributes* pAttributes,
}
}

// Start the toDeck early so it is already playing (and not cold-starting)
// by the time the crossfader transition begins. We trigger kEarlyPlaySeconds
// before fadeBeginPos and seek the toDeck back by however much time actually
// remain until fadeBeginPos at that moment.
if (m_eState == ADJ_IDLE && thisDeck->isFromDeck && !otherDeck->loading &&
Comment thread
ywwg marked this conversation as resolved.
thisDeckPlaying && !otherDeckPlaying &&
otherDeck->startPos != kKeepPosition) {
Comment thread
ywwg marked this conversation as resolved.
const double fromDeckDurationSec = getEndSecond(thisDeck);
if (fromDeckDurationSec > 0.0) {
constexpr double kEarlyPlaySeconds = 1.0;
const double earlyPlayPos =
thisDeck->fadeBeginPos - (kEarlyPlaySeconds / fromDeckDurationSec);
Comment thread
ywwg marked this conversation as resolved.
Outdated
if (thisPlayPosition >= earlyPlayPos &&
thisPlayPosition < thisDeck->fadeBeginPos) {
Comment thread
ywwg marked this conversation as resolved.
Outdated
const double toDeckDurationSec = getEndSecond(otherDeck);
if (toDeckDurationSec > 0.0) {
// Seek the toDeck back by the exact number of seconds remaining
// until fadeBeginPos so that startPos aligns with the fade start,
// regardless of where in the buffer window this callback fired.
const double secondsUntilFade =
(thisDeck->fadeBeginPos - thisPlayPosition) * fromDeckDurationSec;
const double earlyStartPos =
otherDeck->startPos - (secondsUntilFade / toDeckDurationSec);
Comment thread
ywwg marked this conversation as resolved.
Outdated
otherDeck->setPlayPosition(earlyStartPos);
otherDeck->play();
Comment thread
ywwg marked this conversation as resolved.
Outdated
Comment thread
ywwg marked this conversation as resolved.
Outdated
if constexpr (sDebug) {
qDebug() << this << "playerPositionChanged"
<< "early play toDeck at" << earlyStartPos
<< "(" << secondsUntilFade << "s before startPos"
<< otherDeck->startPos << ")";
}
}
}
}
}

// If we are past this deck's posThreshold then:
// - transition into fading mode, play the other deck and fade to it.
// - check if fading is done and stop the deck
Expand Down