changeset 72:853bed2e1faa

* Use VariableSampleRate instead of OneSamplePerStep for key detector (diff from David Pastor)
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 09 Jul 2008 13:24:51 +0000
parents 1759834c6235
children ddb6dd22dac2
files plugins/KeyDetect.cpp
diffstat 1 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/KeyDetect.cpp	Thu Jul 03 14:04:01 2008 +0000
+++ b/plugins/KeyDetect.cpp	Wed Jul 09 13:24:51 2008 +0000
@@ -195,6 +195,10 @@
 {
     OutputList list;
 
+    float osr = 0.0f;
+    if (m_stepSize == 0) (void)getPreferredStepSize();
+    osr = m_inputSampleRate / m_stepSize;
+
     OutputDescriptor d;
     d.identifier = "tonic";
     d.name = "Tonic Pitch";
@@ -207,7 +211,8 @@
     d.minValue = 1;
     d.maxValue = 12;
     d.quantizeStep = 1;
-    d.sampleType = OutputDescriptor::OneSamplePerStep;
+    d.sampleRate = osr;
+    d.sampleType = OutputDescriptor::VariableSampleRate;
     list.push_back(d);
 
     d.identifier = "mode";
@@ -221,7 +226,8 @@
     d.minValue = 0;
     d.maxValue = 1;
     d.quantizeStep = 1;
-    d.sampleType = OutputDescriptor::OneSamplePerStep;
+    d.sampleRate = osr;
+    d.sampleType = OutputDescriptor::VariableSampleRate;
     list.push_back(d);
 
     d.identifier = "key";
@@ -235,7 +241,8 @@
     d.minValue = 1;
     d.maxValue = 24;
     d.quantizeStep = 1;
-    d.sampleType = OutputDescriptor::OneSamplePerStep;
+    d.sampleRate = osr;
+    d.sampleType = OutputDescriptor::VariableSampleRate;
     list.push_back(d);
 
     d.identifier = "keystrength";
@@ -245,8 +252,9 @@
     d.hasFixedBinCount = true;
     d.binCount = 25;
     d.hasKnownExtents = false;
+    d.sampleRate = osr;
     d.isQuantized = false;
-    d.sampleType = OutputDescriptor::OneSamplePerStep;
+    d.sampleType = OutputDescriptor::VariableSampleRate;
     for (int i = 0; i < 24; ++i) {
         if (i == 12) d.binNames.push_back(" ");
         int idx = conversion[i];
@@ -285,7 +293,8 @@
 
     if (tonic != prevTonic) {
         Feature feature;
-        feature.hasTimestamp = false;
+        feature.hasTimestamp = true;
+        feature.timestamp = now;
 //        feature.timestamp = now;
         feature.values.push_back((float)tonic);
         feature.label = getKeyName(tonic, minor, false);
@@ -294,7 +303,8 @@
 
     if (minor != (m_getKeyMode->isModeMinor(m_prevKey))) {
         Feature feature;
-        feature.hasTimestamp = false;
+        feature.hasTimestamp = true;
+        feature.timestamp = now;
         feature.values.push_back(minor ? 1.f : 0.f);
         feature.label = (minor ? "Minor" : "Major");
         returnFeatures[1].push_back(feature); // mode
@@ -302,7 +312,8 @@
 
     if (key != m_prevKey) {
         Feature feature;
-        feature.hasTimestamp = false;
+        feature.hasTimestamp = true;
+        feature.timestamp = now;
         feature.values.push_back((float)key);
         feature.label = getKeyName(tonic, minor, true);
         returnFeatures[2].push_back(feature); // key
@@ -317,7 +328,8 @@
         if (i == 12) ksf.values.push_back(-1);
         ksf.values.push_back(keystrengths[conversion[i]-1]);
     }
-    ksf.hasTimestamp = false;
+    ksf.hasTimestamp = true;
+    ksf.timestamp = now;
     returnFeatures[3].push_back(ksf);
 
     return returnFeatures;