From dd608bf8e07d102e26aab16998a12e2f7c976b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 14 Aug 2023 00:29:05 +0200 Subject: [PATCH 1/5] Auto-DJ: Don't adopt last sound as outro end, when user has explicit deleted it. Use transition time instead if possible, else fall back to last sound. --- src/library/autodj/autodjprocessor.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/library/autodj/autodjprocessor.cpp b/src/library/autodj/autodjprocessor.cpp index 38051d0d11d..0a25997630f 100644 --- a/src/library/autodj/autodjprocessor.cpp +++ b/src/library/autodj/autodjprocessor.cpp @@ -1127,12 +1127,28 @@ double AutoDJProcessor::getOutroStartSecond(DeckAttributes* pDeck) { double AutoDJProcessor::getOutroEndSecond(DeckAttributes* pDeck) { const mixxx::audio::FramePos trackEndPosition = pDeck->trackEndPosition(); + const mixxx::audio::FramePos outroStartPosition = pDeck->outroStartPosition(); const mixxx::audio::FramePos outroEndPosition = pDeck->outroEndPosition(); if (!outroEndPosition.isValid() || outroEndPosition > trackEndPosition) { - return getLastSoundSecond(pDeck); + double lastSoundSecond = getLastSoundSecond(pDeck); + if (!outroStartPosition.isValid() || outroStartPosition > trackEndPosition) { + // No outro start and outro end set, use Last Sound. + return lastSoundSecond; + } + double outroStartSecond = framePositionToSeconds(outroStartPosition, pDeck); + if (m_transitionTime >= 0 && lastSoundSecond > outroStartSecond) { + double outroEndFromTime = outroStartSecond + m_transitionTime; + if (outroEndFromTime < lastSoundSecond) { + // The outroEnd is automatically placed by AnalyzerSilence at the last sound + // Here the user has removed it, but has placed a outro start. + // Use the transition time instead the dismissed last sound position. + return outroEndFromTime; + } + return lastSoundSecond; + } + return outroStartSecond; } return framePositionToSeconds(outroEndPosition, pDeck); - ; } double AutoDJProcessor::getFirstSoundSecond(DeckAttributes* pDeck) { 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 2/5] 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); } From 8f892dc0743dc424b5e640a76d45f89396e62512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 5 Oct 2023 08:17:04 +0200 Subject: [PATCH 3/5] Add some comments --- src/library/autodj/autodjprocessor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/library/autodj/autodjprocessor.cpp b/src/library/autodj/autodjprocessor.cpp index 50467635171..ba48a3eb4af 100644 --- a/src/library/autodj/autodjprocessor.cpp +++ b/src/library/autodj/autodjprocessor.cpp @@ -1148,10 +1148,12 @@ double AutoDJProcessor::getOutroEndSecond(DeckAttributes* pDeck) { const mixxx::audio::FramePos outroEndPosition = pDeck->outroEndPosition(); if (!outroEndPosition.isValid() || outroEndPosition > trackEndPosition) { double lastSoundSecond = getLastSoundSecond(pDeck); + DEBUG_ASSERT(lastSoundSecond <= framePositionToSeconds(trackEndPosition, pDeck)); if (!outroStartPosition.isValid() || outroStartPosition > trackEndPosition) { // No outro start and outro end set, use Last Sound. return lastSoundSecond; } + // Try to find a better Outro End using Outro Start and transition time double outroStartSecond = framePositionToSeconds(outroStartPosition, pDeck); if (m_transitionTime >= 0 && lastSoundSecond > outroStartSecond) { double outroEndFromTime = outroStartSecond + m_transitionTime; From 8e1e8bb96b6516690c0addb26244178bfb54e5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 18 Dec 2023 22:39:45 +0100 Subject: [PATCH 4/5] Improve comments Co-authored-by: ronso0 --- src/library/autodj/autodjprocessor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/autodj/autodjprocessor.cpp b/src/library/autodj/autodjprocessor.cpp index ba48a3eb4af..80a42a7f18f 100644 --- a/src/library/autodj/autodjprocessor.cpp +++ b/src/library/autodj/autodjprocessor.cpp @@ -1106,7 +1106,7 @@ double AutoDJProcessor::getIntroStartSecond(DeckAttributes* pDeck) { 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. + // Use the transition time instead of the dismissed first sound position. return introStartFromTime; } return firstSoundSecond; @@ -1160,7 +1160,7 @@ double AutoDJProcessor::getOutroEndSecond(DeckAttributes* pDeck) { if (outroEndFromTime < lastSoundSecond) { // The outroEnd is automatically placed by AnalyzerSilence at the last sound // Here the user has removed it, but has placed a outro start. - // Use the transition time instead the dismissed last sound position. + // Use the transition time instead of the dismissed last sound position. return outroEndFromTime; } return lastSoundSecond; From c2a54a7ed06c6f355d8da21a56b76f6e7c2c0faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 18 Dec 2023 23:29:07 +0100 Subject: [PATCH 5/5] Allow to place an automatic set transition into the prerole --- src/library/autodj/autodjprocessor.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/library/autodj/autodjprocessor.cpp b/src/library/autodj/autodjprocessor.cpp index 80a42a7f18f..474f2a80fc0 100644 --- a/src/library/autodj/autodjprocessor.cpp +++ b/src/library/autodj/autodjprocessor.cpp @@ -1101,15 +1101,8 @@ double AutoDJProcessor::getIntroStartSecond(DeckAttributes* pDeck) { 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 of the dismissed first sound position. - return introStartFromTime; - } - return firstSoundSecond; + if (m_transitionTime >= 0) { + return introEndSecond - m_transitionTime; } return introEndSecond; }