Skip to content

Commit

Permalink
AutoDJProcessor: Readability: Append "Second" suffix to variables
Browse files Browse the repository at this point in the history
  • Loading branch information
cr7pt0gr4ph7 committed May 18, 2024
1 parent 06ddbb9 commit 39e91ca
Showing 1 changed file with 38 additions and 30 deletions.
68 changes: 38 additions & 30 deletions src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1452,12 +1452,12 @@ void AutoDJProcessor::calculateTransitionImpl(
// Check for tracks that are too short
// ===================================

const double fromDeckEndPosition = getEndSecond(fromTrack);
const double toDeckEndPosition = getEndSecond(toTrack);
const double fromDeckEndSecond = getEndSecond(fromTrack);
const double toDeckEndSecond = getEndSecond(toTrack);
// Since the end position is measured in seconds from 0:00 it is also
// the track duration. Use this alias for better readability.
const double fromDeckDuration = fromDeckEndPosition;
const double toDeckDuration = toDeckEndPosition;
const double fromDeckDuration = fromDeckEndSecond;
const double toDeckDuration = toDeckEndSecond;

VERIFY_OR_DEBUG_ASSERT(fromDeckDuration >= kMinimumTrackDurationSec) {
// Track has no duration or too short. This should not happen, because short
Expand Down Expand Up @@ -1488,23 +1488,23 @@ void AutoDJProcessor::calculateTransitionImpl(
// Within this function, the outro refers to the outro of the currently
// playing track and the intro refers to the intro of the next track.

double outroEnd = getOutroEndSecond(fromTrack);
double outroStart = getOutroStartSecond(fromTrack);
double outroEndSecond = getOutroEndSecond(fromTrack);
double outroStartSecond = getOutroStartSecond(fromTrack);
const double fromDeckPosition = fromDeckDuration * fromTrack.playPosition();

VERIFY_OR_DEBUG_ASSERT(outroEnd <= fromDeckEndPosition) {
outroEnd = fromDeckEndPosition;
VERIFY_OR_DEBUG_ASSERT(outroEndSecond <= fromDeckEndSecond) {
outroEndSecond = fromDeckEndSecond;
}

if (fromDeckPosition > outroStart) {
if (fromDeckPosition > outroStartSecond) {
// We have already passed outroStart
// This can happen if we have just enabled auto DJ
outroStart = fromDeckPosition;
if (fromDeckPosition > outroEnd) {
outroEnd = math_min(outroStart + fabs(m_transitionTime), fromDeckEndPosition);
outroStartSecond = fromDeckPosition;
if (fromDeckPosition > outroEndSecond) {
outroEndSecond = math_min(outroStartSecond + fabs(m_transitionTime), fromDeckEndSecond);
}
}
double outroLength = outroEnd - outroStart;
double outroLength = outroEndSecond - outroStartSecond;

double toDeckPositionSeconds = toDeckDuration * toTrack.playPosition();
// Store here a possible fadeBeginPos for the transition after next
Expand All @@ -1520,25 +1520,25 @@ void AutoDJProcessor::calculateTransitionImpl(
toTrack.fadeBeginPos = toDeckOutroStartSecond;

double toDeckStartSeconds = toDeckPositionSeconds;
const double introStart = getIntroStartSecond(toTrack);
const double introEnd = getIntroEndSecond(toTrack);
const double introStartSecond = getIntroStartSecond(toTrack);
const double introEndSecond = getIntroEndSecond(toTrack);
if (seekToStartPoint || toDeckPositionSeconds >= toTrack.fadeBeginPos) {
// toDeckPosition >= toTrack.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.
toDeckStartSeconds = introStart;
toDeckStartSeconds = introStartSecond;
}

double introLength = 0;

// introEnd is equal introStart in case it has not yet been set
if (toDeckStartSeconds < introEnd && introStart < introEnd) {
if (toDeckStartSeconds < introEndSecond && introStartSecond < introEndSecond) {
// 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 = introEndSecond - toDeckStartSeconds;
if (introLength > (introEndSecond - introStartSecond) * 2 &&
introLength > (introEndSecond - introStartSecond) + m_transitionTime &&
introLength > outroLength) {
introLength = 0;
}
Expand Down Expand Up @@ -1591,11 +1591,15 @@ void AutoDJProcessor::calculateTransitionImpl(
transitionLength = 1;
}
}
fromTrack.fadeBeginPos = outroEnd - transitionLength;
fromTrack.fadeEndPos = outroEnd;
fromTrack.fadeBeginPos = outroEndSecond - transitionLength;
fromTrack.fadeEndPos = outroEndSecond;
toTrack.startPos = toDeckStartSeconds;
} else {
useFixedFadeTime(fromTrack, toTrack, fromDeckPosition, outroEnd, toDeckStartSeconds);
useFixedFadeTime(fromTrack,
toTrack,
fromDeckPosition,
outroEndSecond,
toDeckStartSeconds);
}
} break;
case TransitionMode::FadeAtOutroStart: {
Expand Down Expand Up @@ -1637,16 +1641,20 @@ void AutoDJProcessor::calculateTransitionImpl(
transitionLength = 1;
}
}
fromTrack.fadeBeginPos = outroStart;
fromTrack.fadeEndPos = outroStart + transitionLength;
fromTrack.fadeBeginPos = outroStartSecond;
fromTrack.fadeEndPos = outroStartSecond + transitionLength;
toTrack.startPos = toDeckStartSeconds;
} else if (introLength > 0) {
transitionLength = introLength;
fromTrack.fadeBeginPos = outroEnd - transitionLength;
fromTrack.fadeEndPos = outroEnd;
fromTrack.fadeBeginPos = outroEndSecond - transitionLength;
fromTrack.fadeEndPos = outroEndSecond;
toTrack.startPos = toDeckStartSeconds;
} else {
useFixedFadeTime(fromTrack, toTrack, fromDeckPosition, outroEnd, toDeckStartSeconds);
useFixedFadeTime(fromTrack,
toTrack,
fromDeckPosition,
outroEndSecond,
toDeckStartSeconds);
}
} break;
case TransitionMode::FixedSkipSilence: {
Expand All @@ -1671,7 +1679,7 @@ void AutoDJProcessor::calculateTransitionImpl(
case TransitionMode::FixedFullTrack:
default: {
double startPoint;
toTrack.fadeBeginPos = toDeckEndPosition;
toTrack.fadeBeginPos = toDeckEndSecond;
if (seekToStartPoint || toDeckPositionSeconds >= toTrack.fadeBeginPos) {
// toDeckPosition >= toTrack.fadeBeginPos happens when the
// user has seeked or played the to track behind fadeBeginPos of
Expand All @@ -1681,7 +1689,7 @@ void AutoDJProcessor::calculateTransitionImpl(
} else {
startPoint = toDeckPositionSeconds;
}
useFixedFadeTime(fromTrack, toTrack, fromDeckPosition, fromDeckEndPosition, startPoint);
useFixedFadeTime(fromTrack, toTrack, fromDeckPosition, fromDeckEndSecond, startPoint);
}
}

Expand Down

0 comments on commit 39e91ca

Please sign in to comment.