Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c1010a6
make emitLoadTrackToPlayer and emitAutoDJStateChanged a protected non…
daschuer Oct 27, 2019
cf658a9
move no outro start fallback code into getOutroStartPosition()
daschuer Oct 27, 2019
df29633
consider current position of the from deck after chaning the transiti…
daschuer Oct 27, 2019
2b1f525
fix AutoDJProcessorTest.FadeToDeck2_Long_Transition test. This fixes …
daschuer Oct 27, 2019
5e6988e
Cache hasFadeTransition before possible override
daschuer Oct 28, 2019
74fdcb8
Adjust FadeToDeck2_Pause_Transition for no fading transitions
daschuer Oct 28, 2019
277f5da
improve comments
daschuer Oct 28, 2019
96a5a45
improve error handing in case of -1 cue positions.
daschuer Oct 28, 2019
873e313
improve crossfaderChanged()
daschuer Oct 29, 2019
d6e6cf4
Adjust short track workaround in outro start mode
daschuer Oct 30, 2019
70214df
Adjust intro and outro change slots
daschuer Oct 30, 2019
e1c45e5
don't bother with playing state when calculating a new transition
daschuer Oct 30, 2019
6dac3a6
Don't use non cons references in playerPositionChanged() and remove f…
daschuer Oct 31, 2019
fd36927
Don't use non const references in toggleAutoDJ()
daschuer Oct 31, 2019
2f88f54
Reset startPos, just in case calculateTransition() is not able to set…
daschuer Oct 31, 2019
7036b74
Set the just loaded deck as toDeck
daschuer Nov 3, 2019
9951daa
respect the rate slider when calculating auto-DJ transitions
daschuer Nov 4, 2019
db49654
Whatch rate changes
daschuer Nov 4, 2019
efa6c00
fix recursive positionChanged call. Fix omitting fist seek.
daschuer Nov 7, 2019
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
29 changes: 16 additions & 13 deletions src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,15 @@ double AutoDJProcessor::getIntroEndPosition(DeckAttributes* pDeck) {
}

double AutoDJProcessor::getOutroStartPosition(DeckAttributes* pDeck) {
return samplePositionToSeconds(pDeck->outroStartPosition(), pDeck);
double outroStart = samplePositionToSeconds(pDeck->outroStartPosition(), pDeck);
if (outroStart < 0.0) {
// Assume a zero length outro if outroStartIsNot set.
// The outroEnd is automatically placed by AnalyzerSilence, so use
// that as a fallback if the user has not placed outroStart. If it has
// not been placed, getOutroEndPosition will return the end of the track.
outroStart = getOutroEndPosition(pDeck);
}
return outroStart;
}

double AutoDJProcessor::getOutroEndPosition(DeckAttributes* pDeck) {
Expand Down Expand Up @@ -1037,13 +1045,6 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
double outroStart = getOutroStartPosition(pFromDeck);
double fromDeckPosition = pFromDeck->playPosition() * pFromDeck->duration();

if (outroStart <= 0.0) {
// Assume a zero length outro.
// The outroEnd is automatically placed by AnalyzerSilence, so use
// that as a fallback if the user has not placed outroStart. If it has
// not been placed, getOutroEndPosition will return the end of the track.
outroStart = outroEnd;
}
if (fromDeckPosition > outroStart) {
// We have already passed outroStart
// This can happen if we have just enabled auto DJ
Expand Down Expand Up @@ -1136,7 +1137,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
pFromDeck->fadeEndPos = outroEnd;
pToDeck->startPos = introStart;
} else {
useFixedFadeTime(pFromDeck, pToDeck, outroEnd, introStart);
useFixedFadeTime(pFromDeck, pToDeck, fromDeckPosition, outroEnd, introStart);
}
break;
case TransitionMode::FadeAtOutroStart:
Expand Down Expand Up @@ -1191,7 +1192,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
pFromDeck->fadeEndPos = outroEnd;
pToDeck->startPos = introStart;
} else {
useFixedFadeTime(pFromDeck, pToDeck, outroEnd, introStart);
useFixedFadeTime(pFromDeck, pToDeck, fromDeckPosition, outroEnd, introStart);
}
break;
case TransitionMode::FixedSkipSilence:
Expand All @@ -1208,6 +1209,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
startPoint = toDeckPosition;
}
useFixedFadeTime(pFromDeck, pToDeck,
fromDeckPosition,
getLastSoundPosition(pFromDeck),
startPoint);
}
Expand All @@ -1227,6 +1229,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
startPoint = toDeckPosition;
}
useFixedFadeTime(pFromDeck, pToDeck,
fromDeckPosition,
pFromDeck->duration(),
startPoint);
}
Expand All @@ -1251,7 +1254,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
}

void AutoDJProcessor::useFixedFadeTime(DeckAttributes* pFromDeck,
DeckAttributes* pToDeck, double endPoint, double startPoint) {
DeckAttributes* pToDeck, double fromDeckPosition, double endPoint, double startPoint) {
if (m_transitionTime > 0.0) {
// Guard against the next track being too short. This transition must finish
// before the next transition starts.
Expand All @@ -1275,12 +1278,12 @@ void AutoDJProcessor::useFixedFadeTime(DeckAttributes* pFromDeck,
double transitionTime = math_min(toDeckOutroStart - startPoint,
m_transitionTime);

pFromDeck->fadeBeginPos = endPoint - transitionTime;
pFromDeck->fadeBeginPos = math_max(endPoint - transitionTime, fromDeckPosition);
pFromDeck->fadeEndPos = endPoint;
pToDeck->startPos = startPoint;
} else {
pFromDeck->fadeBeginPos = endPoint;
pFromDeck->fadeEndPos = endPoint - m_transitionTime;
pFromDeck->fadeEndPos = endPoint;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This breaks fading with a negative transition time. AutoDJ stops in this case.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This was causes elsewhere, but fixed now.

pToDeck->startPos = startPoint + m_transitionTime;
}
}
Expand Down
21 changes: 11 additions & 10 deletions src/library/autodj/autodjprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,6 @@ class AutoDJProcessor : public QObject {
void fadeNow();
AutoDJError toggleAutoDJ(bool enable);

// The following virtual signal wrappers are used for testing
virtual void emitLoadTrackToPlayer(TrackPointer pTrack, QString group,
bool play) {
emit(loadTrackToPlayer(pTrack, group, play));
}
virtual void emitAutoDJStateChanged(AutoDJProcessor::AutoDJState state) {
emit(autoDJStateChanged(state));
}

signals:
void loadTrackToPlayer(TrackPointer pTrack, QString group,
bool play);
Expand All @@ -229,6 +220,16 @@ class AutoDJProcessor : public QObject {
void controlShuffle(double value);
void controlSkipNext(double value);

protected:
// The following virtual signal wrappers are used for testing
virtual void emitLoadTrackToPlayer(TrackPointer pTrack, QString group,
bool play) {
emit(loadTrackToPlayer(pTrack, group, play));
}
virtual void emitAutoDJStateChanged(AutoDJProcessor::AutoDJState state) {
emit(autoDJStateChanged(state));
}

private:
// Gets or sets the crossfader position while normalizing it so that -1 is
// all the way mixed to the left side and 1 is all the way mixed to the
Expand All @@ -254,7 +255,7 @@ class AutoDJProcessor : public QObject {
DeckAttributes* pToDeck,
bool seekToStartPoint);
void useFixedFadeTime(DeckAttributes* pFromDeck, DeckAttributes* pToDeck,
double endPoint, double startPoint);
double fromDeckPosition, double endPoint, double startPoint);
DeckAttributes* getOtherDeck(const DeckAttributes* pFromDeck,
bool playing = false);

Expand Down