summaryrefslogtreecommitdiffstats
path: root/src/analyzer/analyzerkey.cpp
diff options
context:
space:
mode:
authorDaniel Schürmann <daschuer@mixxx.org>2019-06-26 21:19:44 +0200
committerDaniel Schürmann <daschuer@mixxx.org>2019-06-26 21:19:44 +0200
commit967a8a98f10fda72b53a291e13e10f65c45eb4f4 (patch)
treed65abbb26d5febda2d7eaf0cf349a391db5aad56 /src/analyzer/analyzerkey.cpp
parent7b773e15e30f031770bab49d1a51da40be0682e8 (diff)
Apply the analyzerbeat changes to analyzerkey as well. Improve default vealue generation.
Diffstat (limited to 'src/analyzer/analyzerkey.cpp')
-rw-r--r--src/analyzer/analyzerkey.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/analyzer/analyzerkey.cpp b/src/analyzer/analyzerkey.cpp
index 736452b3ee..167c245d79 100644
--- a/src/analyzer/analyzerkey.cpp
+++ b/src/analyzer/analyzerkey.cpp
@@ -11,6 +11,7 @@
// static
QList<mixxx::AnalyzerPluginInfo> AnalyzerKey::availablePlugins() {
QList<mixxx::AnalyzerPluginInfo> analyzers;
+ // First one below is the default
analyzers.push_back(mixxx::AnalyzerQueenMaryKey::pluginInfo());
return analyzers;
}
@@ -39,7 +40,17 @@ bool AnalyzerKey::initialize(TrackPointer tio, int sampleRate, int totalSamples)
m_bPreferencesFastAnalysisEnabled = m_keySettings.getFastAnalysis();
m_bPreferencesReanalyzeEnabled = m_keySettings.getReanalyzeWhenSettingsChange();
- m_pluginId = m_keySettings.getKeyPluginId();
+
+ if (AnalyzerKey::availablePlugins().size() > 0) {
+ m_pluginId = AnalyzerKey::availablePlugins().at(0).id; // first is default
+ QString pluginId = m_keySettings.getKeyPluginId();
+ for (const auto& info : AnalyzerKey::availablePlugins()) {
+ if (info.id == pluginId) {
+ m_pluginId = pluginId; // configured Plug-In available
+ break;
+ }
+ }
+ }
qDebug() << "AnalyzerKey preference settings:"
<< "\nPlugin:" << m_pluginId
@@ -65,19 +76,21 @@ bool AnalyzerKey::initialize(TrackPointer tio, int sampleRate, int totalSamples)
if (m_pluginId == mixxx::AnalyzerQueenMaryKey::pluginInfo().id) {
m_pPlugin = std::make_unique<mixxx::AnalyzerQueenMaryKey>();
} else {
- // Default to our built-in key detector.
- m_pPlugin = std::make_unique<mixxx::AnalyzerQueenMaryKey>();
+ DEBUG_ASSERT(false);
}
- bShouldAnalyze = m_pPlugin->initialize(sampleRate);
- }
- if (bShouldAnalyze) {
- qDebug() << "Key calculation started with plugin" << m_pluginId;
- } else {
- qDebug() << "Key calculation will not start.";
- m_pPlugin.reset();
+ if (m_pPlugin) {
+ if (m_pPlugin->initialize(sampleRate)) {
+ qDebug() << "Key calculation started with plugin" << m_pluginId;
+ } else {
+ qDebug() << "Key calculation will not start.";
+ m_pPlugin.reset();
+ bShouldAnalyze = false;
+ }
+ } else {
+ bShouldAnalyze = false;
+ }
}
-
return bShouldAnalyze;
}