From dd388c3394391589f5f522efb652832dbdf1a9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 9 Jun 2019 08:44:45 +0200 Subject: [PATCH] Show key occurrence in debug message as seconds --- src/track/keyutils.cpp | 14 +++++++------- src/track/keyutils.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/track/keyutils.cpp b/src/track/keyutils.cpp index 24f10ceb51c..295adb50104 100644 --- a/src/track/keyutils.cpp +++ b/src/track/keyutils.cpp @@ -395,25 +395,25 @@ ChromaticKey KeyUtils::scaleKeySteps(ChromaticKey key, int key_changes) { // static mixxx::track::io::key::ChromaticKey KeyUtils::calculateGlobalKey( - const KeyChangeList& key_changes, const int iTotalSamples) { + const KeyChangeList& key_changes, const int iTotalSamples, const int iSampleRate) { const int iTotalFrames = iTotalSamples / 2; - QMap key_histogram; + QMap key_occurrence; for (int i = 0; i < key_changes.size(); ++i) { mixxx::track::io::key::ChromaticKey key = key_changes[i].first; const double start_frame = key_changes[i].second; const double next_frame = (i == key_changes.size() - 1) ? iTotalFrames : key_changes[i+1].second; - key_histogram[key] += (next_frame - start_frame); + key_occurrence[key] += (next_frame - start_frame); } double max_delta = 0; mixxx::track::io::key::ChromaticKey max_key = mixxx::track::io::key::INVALID; - qDebug() << "Key Histogram"; - for (auto it = key_histogram.constBegin(); - it != key_histogram.constEnd(); ++it) { - qDebug() << it.key() << ":" << keyDebugName(it.key()) << it.value(); + qDebug() << "Key Occurrence"; + for (auto it = key_occurrence.constBegin(); + it != key_occurrence.constEnd(); ++it) { + qDebug() << it.key() << ":" << keyDebugName(it.key()) << it.value() / iSampleRate; if (it.value() > max_delta) { max_key = it.key(); max_delta = it.value(); diff --git a/src/track/keyutils.h b/src/track/keyutils.h index 43e1f27384e..18b0352ad7b 100644 --- a/src/track/keyutils.h +++ b/src/track/keyutils.h @@ -78,7 +78,7 @@ class KeyUtils { static mixxx::track::io::key::ChromaticKey guessKeyFromText(const QString& text); static mixxx::track::io::key::ChromaticKey calculateGlobalKey( - const KeyChangeList& key_changes, int iTotalSamples); + const KeyChangeList& key_changes, int iTotalSamples, const int iSampleRate); static void setNotation( const QMap& notation);