diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2021-03-11 16:12:49 +0100 |
---|---|---|
committer | Uwe Klotz <uklotz@mixxx.org> | 2021-03-11 16:12:49 +0100 |
commit | 48c80b6a5d3600464f48a7751ea97932d4685bad (patch) | |
tree | d5d0146766d3897fb7defd466242c8f019ed8811 /src/analyzer | |
parent | 94f606603d2180af5c8c8f5a1e3126544637d69a (diff) | |
parent | 086afe214a2c6baea6c0cb746548506a2d5f6cbd (diff) |
Merge branch '2.3' of git@github.com:mixxxdj/mixxx.git into main
# Conflicts:
# src/library/baseexternalplaylistmodel.cpp
Diffstat (limited to 'src/analyzer')
-rw-r--r-- | src/analyzer/analyzerbeats.cpp | 52 |
1 files changed, 11 insertions, 41 deletions
diff --git a/src/analyzer/analyzerbeats.cpp b/src/analyzer/analyzerbeats.cpp index e6f8fbab53..7d9339c9c9 100644 --- a/src/analyzer/analyzerbeats.cpp +++ b/src/analyzer/analyzerbeats.cpp @@ -164,14 +164,20 @@ bool AnalyzerBeats::shouldAnalyze(TrackPointer pTrack) const { qDebug() << "Re-analyzing track with invalid BPM despite preference settings."; return true; } - if (pBeats->findNextBeat(0) <= 0.0) { + + QString subVersion = pBeats->getSubVersion(); + if (subVersion == mixxx::rekordboxconstants::beatsSubversion) { + return m_bPreferencesReanalyzeImported; + } + + if (subVersion.isEmpty() && pBeats->findNextBeat(0) <= 0.0 && + m_pluginId != mixxx::AnalyzerSoundTouchBeats::pluginInfo().id) { + // This happens if the beat grid was created from the metadata BPM value. qDebug() << "First beat is 0 for grid so analyzing track to find first beat."; return true; } - // Version check QString version = pBeats->getVersion(); - QString subVersion = pBeats->getSubVersion(); QHash<QString, QString> extraVersionInfo = getExtraVersionInfo( pluginID, m_bPreferencesFastAnalysis); @@ -183,9 +189,7 @@ bool AnalyzerBeats::shouldAnalyze(TrackPointer pTrack) const { iMinBpm, iMaxBpm, extraVersionInfo); - if (subVersion == mixxx::rekordboxconstants::beatsSubversion) { - return m_bPreferencesReanalyzeImported; - } + if (version == newVersion && subVersion == newSubVersion) { // If the version and settings have not changed then if the world is // sane, re-analyzing will do nothing. @@ -251,41 +255,7 @@ void AnalyzerBeats::storeResults(TrackPointer pTrack) { pBeats = BeatFactory::makeBeatGrid(m_sampleRate, bpm, 0.0f); } - mixxx::BeatsPointer pCurrentBeats = pTrack->getBeats(); - - // If the track has no beats object then set our newly generated one - // regardless of beat lock. - if (!pCurrentBeats) { - pTrack->setBeats(pBeats); - return; - } - - // If the track received the beat lock while we were analyzing it then we - // abort setting it. - if (pTrack->isBpmLocked()) { - qDebug() << "Track was BPM-locked as we were analyzing it. Aborting analysis."; - return; - } - - // If the user prefers to replace old beatgrids with newly generated ones or - // the old beatgrid has 0-bpm then we replace it. - bool zeroCurrentBpm = pCurrentBeats->getBpm() == 0.0; - if (m_bPreferencesReanalyzeOldBpm || zeroCurrentBpm) { - if (zeroCurrentBpm) { - qDebug() << "Replacing 0-BPM beatgrid with a" << pBeats->getBpm() - << "beatgrid."; - } - pTrack->setBeats(pBeats); - return; - } - - // If we got here then the user doesn't want to replace the beatgrid but - // since the first beat is zero we'll apply the offset we just detected. - double currentFirstBeat = pCurrentBeats->findNextBeat(0); - double newFirstBeat = pBeats->findNextBeat(0); - if (currentFirstBeat == 0.0 && newFirstBeat > 0) { - pTrack->setBeats(pCurrentBeats->translate(newFirstBeat)); - } + pTrack->trySetBeats(pBeats); } // static |