changeset 42:d01f94d58ef0 matthiasm-plugin

* added new parameter that toggles NNLS
author matthiasm
date Sun, 24 Oct 2010 20:43:11 +0900
parents d6bb9b43ac1c
children 131801714118
files Chordino.cpp NNLSBase.cpp NNLSBase.h NNLSChroma.cpp chord.dict
diffstat 5 files changed, 45 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/Chordino.cpp	Fri Oct 22 21:43:57 2010 +0900
+++ b/Chordino.cpp	Sun Oct 24 20:43:11 2010 +0900
@@ -223,7 +223,7 @@
         Three different kinds of chromagram are calculated, "treble", "bass", and "both" (which means 
         bass and treble stacked onto each other).
     **/
-    if (m_dictID == 1) {
+    if (m_useNNLS == 0) {
         cerr << "[Chordino Plugin] Mapping to semitone spectrum and chroma ... ";
     } else {
         cerr << "[Chordino Plugin] Performing NNLS and mapping to chroma ... ";
@@ -265,7 +265,7 @@
         unsigned iSemitone = 0;
 			
         if (some_b_greater_zero) {
-            if (m_dictID == 1) {
+            if (m_useNNLS == 0) {
                 for (unsigned iNote = 2; iNote < nNote - 2; iNote += 3) {
                     currval = 0;
                     currval += b[iNote + 1 + -1] * 0.5;
--- a/NNLSBase.cpp	Fri Oct 22 21:43:57 2010 +0900
+++ b/NNLSBase.cpp	Sun Oct 24 20:43:11 2010 +0900
@@ -50,12 +50,12 @@
     m_kernelNoteIndex(0),
     m_dict(0),
     m_tuneLocal(false),
-    m_dictID(0),
     m_chorddict(0),
     m_chordnames(0),
     m_doNormalizeChroma(0),
     m_rollon(0.0),
-	m_s(0.7)
+	m_s(0.7),
+	m_useNNLS(1)
 {
     if (debug_on) cerr << "--> NNLSBase" << endl;
 
@@ -146,6 +146,18 @@
     if (debug_on) cerr << "--> getParameterDescriptors" << endl;
     ParameterList list;
 
+    ParameterDescriptor d;
+    d.identifier = "useNNLS";
+    d.name = "use approximate transcription (NNLS)";
+    d.description = "Toggles approximate transcription (NNLS).";
+    d.unit = "";
+    d.minValue = 0.0;
+    d.maxValue = 1.0;
+    d.defaultValue = 1.0;
+    d.isQuantized = true;
+	d.quantizeStep = 1.0;
+    list.push_back(d);
+
     ParameterDescriptor d0;
     d0.identifier = "rollon";
     d0.name = "spectral roll-on";
@@ -217,8 +229,8 @@
 NNLSBase::getParameter(string identifier) const
 {
     if (debug_on) cerr << "--> getParameter" << endl;
-    if (identifier == "notedict") {
-        return m_dictID; 
+    if (identifier == "useNNLS") {
+        return m_useNNLS; 
     }
     
     if (identifier == "whitening") {
@@ -254,8 +266,8 @@
 NNLSBase::setParameter(string identifier, float value) 
 {
     if (debug_on) cerr << "--> setParameter" << endl;
-    if (identifier == "notedict") {
-        m_dictID = (int) value;
+    if (identifier == "useNNLS") {
+        m_useNNLS = (int) value;
     }
     
     if (identifier == "whitening") {
@@ -270,24 +282,24 @@
         m_tuneLocal = (value > 0) ? true : false;
         // cerr << "m_tuneLocal :" << m_tuneLocal << endl;
     }
-    if (identifier == "preset") {
-        m_preset = value;
-        if (m_preset == 0.0) {
-            m_tuneLocal = false;
-            m_whitening = 1.0;
-            m_dictID = 0.0;
-        }
-        if (m_preset == 1.0) {
-            m_tuneLocal = false;
-            m_whitening = 1.0;
-            m_dictID = 1.0;
-        }
-        if (m_preset == 2.0) {
-            m_tuneLocal = false;
-            m_whitening = 0.7;
-            m_dictID = 0.0;
-        }
-    }
+    // if (identifier == "preset") {
+    //     m_preset = value;
+    //     if (m_preset == 0.0) {
+    //         m_tuneLocal = false;
+    //         m_whitening = 1.0;
+    //         m_dictID = 0.0;
+    //     }
+    //     if (m_preset == 1.0) {
+    //         m_tuneLocal = false;
+    //         m_whitening = 1.0;
+    //         m_dictID = 1.0;
+    //     }
+    //     if (m_preset == 2.0) {
+    //         m_tuneLocal = false;
+    //         m_whitening = 0.7;
+    //         m_dictID = 0.0;
+    //     }
+    // }
     if (identifier == "chromanormalize") {
         m_doNormalizeChroma = value;
     }
@@ -379,7 +391,7 @@
 	
     // Clear buffers, reset stored values, etc
     m_frameCount = 0;
-    m_dictID = 0;
+    // m_dictID = 0;
     m_logSpectrum.clear();
     m_meanTuning0 = 0;
     m_meanTuning1 = 0;
@@ -574,7 +586,7 @@
         Three different kinds of chromagram are calculated, "treble", "bass", and "both" (which means 
         bass and treble stacked onto each other).
     **/
-    if (m_dictID == 1) {
+    if (m_useNNLS == 0) {
         cerr << "[NNLS Chroma Plugin] Mapping to semitone spectrum and chroma ... ";
     } else {
         cerr << "[NNLS Chroma Plugin] Performing NNLS and mapping to chroma ... ";
@@ -628,7 +640,7 @@
         unsigned iSemitone = 0;
 			
         if (some_b_greater_zero) {
-            if (m_dictID == 1) {
+            if (m_useNNLS == 0) {
                 for (unsigned iNote = 2; iNote < nNote - 2; iNote += 3) {
                     currval = 0;
                     currval += b[iNote + 1 + -1] * 0.5;						
--- a/NNLSBase.h	Fri Oct 22 21:43:57 2010 +0900
+++ b/NNLSBase.h	Sun Oct 24 20:43:11 2010 +0900
@@ -69,13 +69,13 @@
     float m_whitening;
     float m_preset;
 	float m_s;
+	float m_useNNLS;
     vector<float> m_localTuning;
     vector<float> m_kernelValue;
     vector<int> m_kernelFftIndex;
     vector<int> m_kernelNoteIndex;
     float *m_dict;
     bool m_tuneLocal;
-    int m_dictID;
     vector<float> m_chorddict;
     vector<string> m_chordnames;
     float m_doNormalizeChroma;
--- a/NNLSChroma.cpp	Fri Oct 22 21:43:57 2010 +0900
+++ b/NNLSChroma.cpp	Sun Oct 24 20:43:11 2010 +0900
@@ -295,7 +295,7 @@
         Three different kinds of chromagram are calculated, "treble", "bass", and "both" (which means 
         bass and treble stacked onto each other).
     **/
-    if (m_dictID == 1) {
+    if (m_useNNLS == 0) {
         cerr << "[NNLS Chroma Plugin] Mapping to semitone spectrum and chroma ... ";
     } else {
         cerr << "[NNLS Chroma Plugin] Performing NNLS and mapping to chroma ... ";
@@ -346,7 +346,7 @@
         unsigned iSemitone = 0;
 			
         if (some_b_greater_zero) {
-            if (m_dictID == 1) {
+            if (m_useNNLS == 0) {
                 for (unsigned iNote = 2; iNote < nNote - 2; iNote += 3) {
                     currval = 0;
                     currval += b[iNote + 1 + -1] * 0.5;						
--- a/chord.dict	Fri Oct 22 21:43:57 2010 +0900
+++ b/chord.dict	Sun Oct 24 20:43:11 2010 +0900
@@ -22,7 +22,7 @@
 aug=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0
 =0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
 =0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0
-7sus4=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,1,0
+# 7sus4=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,1,0
 
 ### Rock'n'Roll
 # :1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0