changeset 294:19fd6cb033c7

Add pitch activation matrix output
author Chris Cannam
date Wed, 15 Oct 2014 17:40:20 +0100
parents 71bef111e130
children aa7be9d8112e
files src/Silvet.cpp src/Silvet.h
diffstat 2 files changed, 38 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/Silvet.cpp	Fri Aug 08 11:54:54 2014 +0100
+++ b/src/Silvet.cpp	Wed Oct 15 17:40:20 2014 +0100
@@ -249,7 +249,7 @@
     d.binCount = m_instruments[0].templateHeight;
     d.binNames.clear();
     if (m_cq) {
-        char name[20];
+        char name[50];
         for (int i = 0; i < m_instruments[0].templateHeight; ++i) {
             // We have a 600-bin (10 oct 60-bin CQ) of which the
             // lowest-frequency 55 bins have been dropped, for a
@@ -270,6 +270,26 @@
     m_fcqOutputNo = list.size();
     list.push_back(d);
 
+    d.identifier = "pitchactivation";
+    d.name = "Pitch activation distribution";
+    d.description = "Pitch activation distribution resulting from expectation-maximisation algorithm, prior to note extraction.";
+    d.unit = "";
+    d.hasFixedBinCount = true;
+    d.binCount = m_instruments[0].templateNoteCount;
+    d.binNames.clear();
+    if (m_cq) {
+        for (int i = 0; i < m_instruments[0].templateNoteCount; ++i) {
+            d.binNames.push_back(noteName(i, 0, 1));
+        }
+    }
+    d.hasKnownExtents = false;
+    d.isQuantized = false;
+    d.sampleType = OutputDescriptor::FixedSampleRate;
+    d.sampleRate = m_colsPerSec;
+    d.hasDuration = false;
+    m_pitchOutputNo = list.size();
+    list.push_back(d);
+
     return list;
 }
 
@@ -569,7 +589,16 @@
             continue;
         }
 
-        postProcess(localPitches[i], localBestShifts[i], wantShifts);
+        vector<double> filtered = postProcess
+            (localPitches[i], localBestShifts[i], wantShifts);
+
+        Feature f;
+        for (int j = 0; j < (int)filtered.size(); ++j) {
+            float v(filtered[j]);
+            if (v < pack.levelThreshold) v = 0.f;
+            f.values.push_back(v);
+        }
+        fs[m_pitchOutputNo].push_back(f);
         
         FeatureList noteFeatures = noteTrack(shiftCount);
 
@@ -666,7 +695,7 @@
     return out;
 }
     
-void
+vector<double>
 Silvet::postProcess(const vector<double> &pitches,
                     const vector<int> &bestShifts,
                     bool wantShifts)
@@ -716,6 +745,8 @@
     if (wantShifts) {
         m_pianoRollShifts.push_back(activeShifts);
     }
+
+    return filtered;
 }
 
 Vamp::Plugin::FeatureList
--- a/src/Silvet.h	Fri Aug 08 11:54:54 2014 +0100
+++ b/src/Silvet.h	Wed Oct 15 17:40:20 2014 +0100
@@ -92,9 +92,9 @@
 
     Grid preProcess(const Grid &);
 
-    void postProcess(const vector<double> &pitches,
-                     const vector<int> &bestShifts,
-                     bool wantShifts); // -> piano roll column
+    vector<double> postProcess(const vector<double> &pitches,
+                               const vector<int> &bestShifts,
+                               bool wantShifts); // -> piano roll column
 
     FeatureList noteTrack(int shiftCount);
 
@@ -118,6 +118,7 @@
 
     mutable int m_notesOutputNo;
     mutable int m_fcqOutputNo;
+    mutable int m_pitchOutputNo;
 };
 
 #endif