summaryrefslogtreecommitdiffstats
path: root/src/analyzer
diff options
context:
space:
mode:
authorJan Holthuis <jholthuis@mixxx.org>2021-07-06 15:44:06 +0200
committerJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2021-07-08 01:45:25 +0200
commitf61c710f6a896febb356567198356bc5d00aef45 (patch)
tree0b9851435eac305d7a5220b5a3d1a9be45729edf /src/analyzer
parent4aba92d78cc5ec9d0fb0eebea33b0614e0102f35 (diff)
AnalyzerSilence: Use mixxx::audio::FramePos in storeResults()
Diffstat (limited to 'src/analyzer')
-rw-r--r--src/analyzer/analyzersilence.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/analyzer/analyzersilence.cpp b/src/analyzer/analyzersilence.cpp
index 11f53ec631..1ded54a610 100644
--- a/src/analyzer/analyzersilence.cpp
+++ b/src/analyzer/analyzersilence.cpp
@@ -90,16 +90,16 @@ void AnalyzerSilence::storeResults(TrackPointer pTrack) {
m_iSignalEnd = m_iFramesProcessed;
}
- double firstSound = mixxx::kAnalysisChannels * m_iSignalStart;
- double lastSound = mixxx::kAnalysisChannels * m_iSignalEnd;
+ const auto firstSoundPosition = mixxx::audio::FramePos(m_iSignalStart);
+ const auto lastSoundPosition = mixxx::audio::FramePos(m_iSignalEnd);
CuePointer pAudibleSound = pTrack->findCueByType(mixxx::CueType::AudibleSound);
if (pAudibleSound == nullptr) {
pAudibleSound = pTrack->createAndAddCue(
mixxx::CueType::AudibleSound,
Cue::kNoHotCue,
- firstSound,
- lastSound);
+ firstSoundPosition,
+ lastSoundPosition);
} else {
// The user has no way to directly edit the AudibleSound cue. If the user
// has deleted the Intro or Outro Cue, this analysis will be rerun when
@@ -107,33 +107,35 @@ void AnalyzerSilence::storeResults(TrackPointer pTrack) {
// positions. This could be helpful, for example, when the track length
// is changed in a different program, or the silence detection threshold
// is changed.
- pAudibleSound->setStartAndEndPosition(firstSound, lastSound);
+ pAudibleSound->setStartAndEndPosition(firstSoundPosition, lastSoundPosition);
}
CuePointer pIntroCue = pTrack->findCueByType(mixxx::CueType::Intro);
- double mainCue = pTrack->getCuePoint().getPosition();
- double introStart = firstSound;
+ mixxx::audio::FramePos mainCuePosition = pTrack->getMainCuePosition();
+ mixxx::audio::FramePos introStartPosition = firstSoundPosition;
// Before Mixxx 2.3, the default position for the main cue was 0.0. In this
// case, move the main cue point to the first sound. This case can be
// distinguished from a user intentionally setting the main cue position
// to 0.0 at a later time after analysis because in that case the intro cue
// would have already been created by this analyzer.
- bool upgradingWithMainCueAtDefault = (mainCue == 0.0 && pIntroCue == nullptr);
- if (mainCue == Cue::kNoPosition || upgradingWithMainCueAtDefault) {
- pTrack->setCuePoint(CuePosition(firstSound));
+ bool upgradingWithMainCueAtDefault =
+ (mainCuePosition == mixxx::audio::kStartFramePos &&
+ pIntroCue == nullptr);
+ if (!mainCuePosition.isValid() || upgradingWithMainCueAtDefault) {
+ pTrack->setMainCuePosition(firstSoundPosition);
// NOTE: the actual default for this ConfigValue is set in DlgPrefDeck.
} else if (m_pConfig->getValue(ConfigKey("[Controls]", "SetIntroStartAtMainCue"), false) &&
pIntroCue == nullptr) {
- introStart = mainCue;
+ introStartPosition = mainCuePosition;
}
if (pIntroCue == nullptr) {
pIntroCue = pTrack->createAndAddCue(
mixxx::CueType::Intro,
Cue::kNoHotCue,
- introStart,
- Cue::kNoPosition);
+ introStartPosition,
+ mixxx::audio::kInvalidFramePos);
}
CuePointer pOutroCue = pTrack->findCueByType(mixxx::CueType::Outro);
@@ -141,7 +143,7 @@ void AnalyzerSilence::storeResults(TrackPointer pTrack) {
pOutroCue = pTrack->createAndAddCue(
mixxx::CueType::Outro,
Cue::kNoHotCue,
- Cue::kNoPosition,
- lastSound);
+ mixxx::audio::kInvalidFramePos,
+ lastSoundPosition);
}
}