From 430a8f83fe9e3c8d1b53f3c93d16037c9a674acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 14 Aug 2023 00:50:37 +0200 Subject: [PATCH] Auto-DJ: Don't adopt first sound as intro start, when user has explicit deleted it. Use transition time instead if possible, else fall back to first sound. --- src/library/autodj/autodjprocessor.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/library/autodj/autodjprocessor.cpp b/src/library/autodj/autodjprocessor.cpp index 0a25997630f..50467635171 100644 --- a/src/library/autodj/autodjprocessor.cpp +++ b/src/library/autodj/autodjprocessor.cpp @@ -1093,8 +1093,25 @@ void AutoDJProcessor::playerOutroEndChanged(DeckAttributes* pAttributes, double double AutoDJProcessor::getIntroStartSecond(DeckAttributes* pDeck) { const mixxx::audio::FramePos trackEndPosition = pDeck->trackEndPosition(); const mixxx::audio::FramePos introStartPosition = pDeck->introStartPosition(); + const mixxx::audio::FramePos introEndPosition = pDeck->introEndPosition(); if (!introStartPosition.isValid() || introStartPosition > trackEndPosition) { - return getFirstSoundSecond(pDeck); + double firstSoundSecond = getFirstSoundSecond(pDeck); + if (!introEndPosition.isValid() || introEndPosition > trackEndPosition) { + // No intro start and intro end set, use First Sound. + return firstSoundSecond; + } + double introEndSecond = framePositionToSeconds(introEndPosition, pDeck); + if (m_transitionTime >= 0 && firstSoundSecond < introEndSecond) { + double introStartFromTime = introEndSecond - m_transitionTime; + if (introStartFromTime > firstSoundSecond) { + // The introStart is automatically placed by AnalyzerSilence at the first sound + // Here the user has removed it, but has placed an intro end. + // Use the transition time instead the dismissed first sound position. + return introStartFromTime; + } + return firstSoundSecond; + } + return introEndSecond; } return framePositionToSeconds(introStartPosition, pDeck); }