changeset 247:e6abd6e99051

This is not actually a tonic-strength output - it's a key-strength output in which the relative major and minor (which have different tonics but the same key signatures) have been summed into a single bin
author Chris Cannam <cannam@all-day-breakfast.com>
date Thu, 26 Sep 2019 15:44:47 +0100
parents 2426f4d30cad
children 6e62926e0be3
files plugins/KeyDetect.cpp plugins/KeyDetect.h
diffstat 2 files changed, 33 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/KeyDetect.cpp	Wed Aug 14 14:53:48 2019 +0100
+++ b/plugins/KeyDetect.cpp	Thu Sep 26 15:44:47 2019 +0100
@@ -298,10 +298,10 @@
     }
     list.push_back(d);
 
-    d.identifier = "tonicstrength";
-    d.name = "Tonic Strength Plot";
+    d.identifier = "mergedkeystrength";
+    d.name = "Merged Key Strength Plot";
     d.unit = "";
-    d.description = "Correlation of the chroma vector with stored key profile for each tonic pitch across both major and minor mode";
+    d.description = "Correlation of the chroma vector with stored key profile for each key, with major and minor alternatives merged";
     d.hasFixedBinCount = true;
     d.binCount = 12;
     d.hasKnownExtents = false;
@@ -310,9 +310,7 @@
     d.binNames.clear();
     for (int i = 0; i < 12; ++i) {
         int idx = conversion[i];
-        std::string label = getKeyName(idx > 12 ? idx-12 : idx, 
-                                       i >= 12,
-                                       false);
+        std::string label = getBothKeyNames(idx > 12 ? idx-12 : idx);
         d.binNames.push_back(label);
     }
     list.push_back(d);
@@ -464,3 +462,31 @@
     else return base + " major";
 }
 
+std::string
+KeyDetector::getBothKeyNames(int index) const
+{
+    // Keys are numbered with 1 => C, 12 => B
+
+    static const char *names[] = {
+        "C maj / A min",
+        "Db maj / Bb min",
+        "D maj / B min",
+        "Eb maj / C min",
+        "E maj / C# min",
+        "F maj / D min",
+        "F#/Gb maj / Eb/D# min",
+        "G maj / E min",
+        "Ab maj / F min",
+        "A maj / F# min",
+        "Bb maj / G min",
+        "B maj / G# min"
+    };
+
+    if (index < 1 || index > 12) {
+        return "(unknown)";
+    }
+
+    return names[index - 1];
+}
+    
+
--- a/plugins/KeyDetect.h	Wed Aug 14 14:53:48 2019 +0100
+++ b/plugins/KeyDetect.h	Thu Sep 26 15:44:47 2019 +0100
@@ -60,6 +60,7 @@
 
     GetKeyMode::Config getConfig() const;
     std::string getKeyName(int index, bool minor, bool includeMajMin) const;
+    std::string getBothKeyNames(int index) const;
 
     GetKeyMode* m_getKeyMode;
     double* m_inputFrame;