changeset 89:7af5312e66f8 matthiasm-plugin

new boost N parameter in chordino, chord dictionary loaded on initialisation (not construction) of plugin
author Matthias Mauch <mail@matthiasmauch.net>
date Wed, 01 Dec 2010 23:08:55 +0900
parents fc28c50caace
children b095d83585c9
files Chordino.cpp NNLSBase.cpp NNLSBase.h NNLSChroma.cpp chromamethods.cpp chromamethods.h
diffstat 6 files changed, 37 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/Chordino.cpp	Wed Dec 01 21:18:49 2010 +0900
+++ b/Chordino.cpp	Wed Dec 01 23:08:55 2010 +0900
@@ -37,7 +37,6 @@
 {
     if (debug_on) cerr << "--> Chordino" << endl;
     // get the *chord* dictionary from file (if the file exists)
-    m_chordnames = chordDictionary(&m_chorddict, &m_chordnotes);
     
 }
 
@@ -146,21 +145,16 @@
     d3.isQuantized = false;
     list.push_back(d3);
 
-    // ParameterDescriptor d4;
-    // d4.identifier = "chromanormalize";
-    // d4.name = "chroma normalization";
-    // d4.description = "How shall the chroma vector be normalized?";
-    // d4.unit = "";
-    // d4.minValue = 0;
-    // d4.maxValue = 3;
-    // d4.defaultValue = 0;
-    // d4.isQuantized = true;
-    // d4.valueNames.push_back("none");
-    // d4.valueNames.push_back("maximum norm");
-    // d4.valueNames.push_back("L1 norm");
-    // d4.valueNames.push_back("L2 norm");
-    // d4.quantizeStep = 1.0;
-    // list.push_back(d4);
+    ParameterDescriptor boostn;
+    boostn.identifier = "boostn";
+    boostn.name = "boost N";
+    boostn.description = "Relative weight of the N label.";
+    boostn.unit = "";
+    boostn.minValue = 1.0;
+    boostn.maxValue = 2.0;
+    boostn.defaultValue = 1.0;
+    boostn.isQuantized = false;
+    list.push_back(boostn);
 
     return list;
 }
@@ -236,7 +230,7 @@
     if (!NNLSBase::initialise(channels, stepSize, blockSize)) {
         return false;
     }
-
+    m_chordnames = chordDictionary(&m_chorddict, &m_chordnotes, m_boostN);
     return true;
 }
 
@@ -260,8 +254,8 @@
 Chordino::FeatureSet
 Chordino::getRemainingFeatures()
 {
-    cerr << hw[0] << hw[1] << endl;
-    if (debug_on) cerr << "--> getRemainingFeatures" << endl;
+    // cerr << hw[0] << hw[1] << endl;
+    if (debug_on) cerr << "--> getRemainingFeatures" << endl;    
     FeatureSet fsOut;
     if (m_logSpectrum.size() == 0) return fsOut;
     int nChord = m_chordnames.size();
--- a/NNLSBase.cpp	Wed Dec 01 21:18:49 2010 +0900
+++ b/NNLSBase.cpp	Wed Dec 01 23:08:55 2010 +0900
@@ -30,6 +30,7 @@
 
 NNLSBase::NNLSBase(float inputSampleRate) :
     Plugin(inputSampleRate),
+    m_frameCount(0),
     m_logSpectrum(0),
     m_blockSize(0),
     m_stepSize(0),
@@ -38,6 +39,8 @@
     m_localTunings(0),
     m_whitening(1.0),
     m_preset(0.0),
+    m_useNNLS(1),
+	m_useHMM(1),
     m_localTuning(0),
     m_kernelValue(0),
     m_kernelFftIndex(0),
@@ -46,9 +49,8 @@
     m_tuneLocal(0),
     m_doNormalizeChroma(0),
     m_rollon(0),
+    m_boostN(1.1),
 	m_s(0.7),
-	m_useNNLS(1),
-	m_useHMM(1),
 	sinvalues(0),
 	cosvalues(0)
 {
@@ -238,6 +240,10 @@
         return m_rollon; 
     }
     
+    if (identifier == "boostn") {
+        return m_boostN; 
+    }
+    
     if (identifier == "tuningmode") {
         if (m_tuneLocal) {
             return 1.0;
@@ -280,6 +286,10 @@
         m_useHMM = value;
     }
     
+    if (identifier == "boostn") {
+        m_boostN = value;
+    }
+    
     if (identifier == "tuningmode") {
         // m_tuneLocal = (value > 0) ? true : false;
         m_tuneLocal = value;
--- a/NNLSBase.h	Wed Dec 01 21:18:49 2010 +0900
+++ b/NNLSBase.h	Wed Dec 01 23:08:55 2010 +0900
@@ -64,7 +64,6 @@
     vector<float> m_localTunings;
     float m_whitening;
     float m_preset;
-	float m_s;
 	float m_useNNLS;
     float m_useHMM;
     vector<float> m_localTuning;
@@ -75,6 +74,8 @@
     bool m_tuneLocal;
     float m_doNormalizeChroma;
     float m_rollon;
+    float m_boostN;
+    float m_s;
     vector<float> hw;
     vector<float> sinvalues;
     vector<float> cosvalues;
--- a/NNLSChroma.cpp	Wed Dec 01 21:18:49 2010 +0900
+++ b/NNLSChroma.cpp	Wed Dec 01 23:08:55 2010 +0900
@@ -228,7 +228,7 @@
 {
     
     float consonancepattern[24] = {0,-1,-1,1,1,1,-1,1,1,1,-1,-1,1,-1,-1,1,1,1,-1,1,1,1,-1,-1};
-    for (int i = 0; i< 12; ++i) cerr << consonancepattern[i]<< endl; 
+    // for (int i = 0; i< 12; ++i) cerr << consonancepattern[i]<< endl; 
     if (debug_on) cerr << "--> getRemainingFeatures" << endl;
     FeatureSet fsOut;
     if (m_logSpectrum.size() == 0) return fsOut;
--- a/chromamethods.cpp	Wed Dec 01 21:18:49 2010 +0900
+++ b/chromamethods.cpp	Wed Dec 01 23:08:55 2010 +0900
@@ -277,7 +277,7 @@
     return path;
 }
 
-vector<string> chordDictionary(vector<float> *mchorddict, vector<vector<int> > *m_chordnotes) {    
+vector<string> chordDictionary(vector<float> *mchorddict, vector<vector<int> > *m_chordnotes, float boostN) {    
     
     typedef tokenizer<char_separator<char> > Tok;
     char_separator<char> sep(",; ","=");
@@ -304,7 +304,7 @@
 
     iostreams::stream<iostreams::file_source> chordDictFile(chordDictFilename);
     string line;
-    int iElement = 0;
+    // int iElement = 0;
     int nChord = 0;
 	
     vector<string> loadedChordNames;
@@ -368,10 +368,10 @@
                     loadedChordNames.push_back(os.str());                
                     
                     m_chordnotes->push_back(tempchordnotes);
-                    for (int iNote = 0; iNote < tempchordnotes.size(); ++iNote) {
-                        cerr << tempchordnotes[iNote] << " ";
-                    }
-                    cerr << endl;
+                    // for (int iNote = 0; iNote < tempchordnotes.size(); ++iNote) {
+                    //     cerr << tempchordnotes[iNote] << " ";
+                    // }
+                    // cerr << endl;
                 }
             }
         }
@@ -382,8 +382,8 @@
         vector<int> tempchordvector;
         m_chordnotes->push_back(tempchordvector);
         float exponent = 2.0;
-        float boostN = 1.1;
-        
+        // float m_boostN = 1.1;
+        // cerr << " N BOOST : " << boostN << endl << endl;
         for (int iChord = 0; iChord < loadedChordDict.size()/24; iChord++) {
             float sum = 0;
             float stand = 0;
--- a/chromamethods.h	Wed Dec 01 21:18:49 2010 +0900
+++ b/chromamethods.h	Wed Dec 01 23:08:55 2010 +0900
@@ -29,7 +29,7 @@
 
 extern std::vector<float> SpecialConvolution(std::vector<float> convolvee, std::vector<float> kernel);
 extern void dictionaryMatrix(float* dm, float s_param);
-extern std::vector<std::string> chordDictionary(std::vector<float> *mchorddict, std::vector<std::vector<int> > *m_chordnotes);
+extern std::vector<std::string> chordDictionary(std::vector<float> *mchorddict, std::vector<std::vector<int> > *m_chordnotes, float boostN);
 extern bool logFreqMatrix(int fs, int blocksize, float *outmatrix);
 
 static const char* notenames[24] = {