changeset 120:7a8956e903e1 monophonicness

minor changes for fewer warnings
author matthiasm
date Fri, 15 Apr 2011 10:01:53 +0000
parents c4d1208e5ea9
children 072327bbb1a2
files NNLSBase.cpp NNLSChroma.cpp chromamethods.cpp chromamethods.h viterbi.cpp
diffstat 5 files changed, 40 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/NNLSBase.cpp	Thu Mar 31 14:59:11 2011 +0100
+++ b/NNLSBase.cpp	Fri Apr 15 10:01:53 2011 +0000
@@ -404,7 +404,7 @@
     m_kernelNoteIndex.clear();
     int countNonzero = 0;
     for (int iNote = 0; iNote < nNote; ++iNote) { // I don't know if this is wise: manually making a sparse matrix
-        for (int iFFT = 0; iFFT < blockSize/2; ++iFFT) {
+        for (size_t iFFT = 0; iFFT < blockSize/2; ++iFFT) {
             if (tempkernel[iFFT + blockSize/2 * iNote] > 0) {
                 m_kernelValue.push_back(tempkernel[iFFT + blockSize/2 * iNote]);
                 if (tempkernel[iFFT + blockSize/2 * iNote] > 0) {
--- a/NNLSChroma.cpp	Thu Mar 31 14:59:11 2011 +0100
+++ b/NNLSChroma.cpp	Fri Apr 15 10:01:53 2011 +0000
@@ -67,6 +67,12 @@
     OutputList list;
     
     // Make chroma names for the binNames property
+
+	const char* notenames[24] = {
+	    "A  (bass)","Bb (bass)","B  (bass)","C  (bass)","C# (bass)","D  (bass)","Eb (bass)","E  (bass)","F  (bass)","F# (bass)","G  (bass)","Ab (bass)",
+	    "A","Bb","B","C","C#","D","Eb","E","F","F#","G","Ab"};
+
+	
     vector<string> chromanames;
     vector<string> bothchromanames;
     for (int iNote = 0; iNote < 24; iNote++) {
@@ -284,8 +290,7 @@
     cerr << endl << "[NNLS Chroma Plugin] Tuning Log-Frequency Spectrogram ... ";
 					
     float tempValue = 0;
-    float dbThreshold = 0; // relative to the background spectrum
-    float thresh = pow(10,dbThreshold/20);
+
     int count = 0;
 
 		
--- a/chromamethods.cpp	Thu Mar 31 14:59:11 2011 +0100
+++ b/chromamethods.cpp	Fri Apr 15 10:01:53 2011 +0000
@@ -274,8 +274,8 @@
     chordnames.push_back("");// =0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
     chordnames.push_back("m");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
     chordnames.push_back("m");//=0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
-    chordnames.push_back("hdim7");//=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0
-    chordnames.push_back("hdim7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0
+    chordnames.push_back("m7b5");//=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0
+    chordnames.push_back("m7b5");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0
     chordnames.push_back("6");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0
     chordnames.push_back("7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0
     chordnames.push_back("maj7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1
@@ -349,6 +349,26 @@
 
     vector<string> ppath = getPluginPath();
     
+	const char* notenames[24] = {
+	    "A  (bass)","Bb (bass)","B  (bass)","C  (bass)","C# (bass)","D  (bass)","Eb (bass)","E  (bass)","F  (bass)","F# (bass)","G  (bass)","Ab (bass)",
+	    "A","Bb","B","C","C#","D","Eb","E","F","F#","G","Ab"};
+
+	const char* bassnames[13][12] ={
+	    {"A","","B","C","C#","D","","E","","F#","G","G#"},
+	    {"Bb","","C","Db","D","Eb","","F","","G","Ab","A"},
+	    {"B","","C#","D","D#","E","","F#","","G#","A","A#"},
+	    {"C","","D","Eb","E","F","","G","","A","Bb","B"},
+	    {"C#","","D#","E","E#","F#","","G#","","A#","B","B#"},
+	    {"D","","E","F","F#","G","","A","","B","C","C#"},
+	    {"Eb","","F","Gb","G","Ab","","Bb","","C","Db","D"},
+	    {"E","","F#","G","G#","A","","B","","C#","D","D#"},
+	    {"F","","G","Ab","A","Bb","","C","","D","Eb","E"},
+	    {"F#","","G#","A","A#","B","","C#","","D#","E","E#"},
+	    {"G","","A","Bb","B","C","","D","","E","F","F#"},
+	    {"Ab","","Bb","Cb","C","Db","","Eb","","F","Gb","G"},
+		{"1","","2","b3","3","4","","5","","6","b7","7"}
+	};
+
     bool hasExternalDictinoary = true;
     
     for (size_t i = 0; i < ppath.size(); ++i) {
--- a/chromamethods.h	Thu Mar 31 14:59:11 2011 +0100
+++ b/chromamethods.h	Fri Apr 15 10:01:53 2011 +0000
@@ -32,26 +32,6 @@
 extern std::vector<std::string> chordDictionary(std::vector<float> *mchorddict, std::vector<std::vector<int> > *m_chordnotes, float boostN, float harte_syntax);
 extern bool logFreqMatrix(int fs, int blocksize, float *outmatrix);
 
-static const char* notenames[24] = {
-    "A  (bass)","Bb (bass)","B  (bass)","C  (bass)","C# (bass)","D  (bass)","Eb (bass)","E  (bass)","F  (bass)","F# (bass)","G  (bass)","Ab (bass)",
-    "A","Bb","B","C","C#","D","Eb","E","F","F#","G","Ab"};
-
-static const char* bassnames[13][12] ={
-    {"A","","B","C","C#","D","","E","","F#","G","G#"},
-    {"Bb","","C","Db","D","Eb","","F","","G","Ab","A"},
-    {"B","","C#","D","D#","E","","F#","","G#","A","A#"},
-    {"C","","D","Eb","E","F","","G","","A","Bb","B"},
-    {"C#","","D#","E","E#","F#","","G#","","A#","B","B#"},
-    {"D","","E","F","F#","G","","A","","B","C","C#"},
-    {"Eb","","F","Gb","G","Ab","","Bb","","C","Db","D"},
-    {"E","","F#","G","G#","A","","B","","C#","D","D#"},
-    {"F","","G","Ab","A","Bb","","C","","D","Eb","E"},
-    {"F#","","G#","A","A#","B","","C#","","D#","E","E#"},
-    {"G","","A","Bb","B","C","","D","","E","F","F#"},
-    {"Ab","","Bb","Cb","C","Db","","Eb","","F","Gb","G"},
-	{"1","","2","b3","3","4","","5","","6","b7","7"}
-};
-
 static const float basswindow[] = {0.001769, 0.015848, 0.043608, 0.084265, 0.136670, 0.199341, 0.270509, 0.348162, 0.430105, 0.514023, 0.597545, 0.678311, 0.754038, 0.822586, 0.882019, 0.930656, 0.967124, 0.990393, 0.999803, 0.995091, 0.976388, 0.944223, 0.899505, 0.843498, 0.777785, 0.704222, 0.624888, 0.542025, 0.457975, 0.375112, 0.295778, 0.222215, 0.156502, 0.100495, 0.055777, 0.023612, 0.004909, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000};
 static const float treblewindow[] = {0.000350, 0.003144, 0.008717, 0.017037, 0.028058, 0.041719, 0.057942, 0.076638, 0.097701, 0.121014, 0.146447, 0.173856, 0.203090, 0.233984, 0.266366, 0.300054, 0.334860, 0.370590, 0.407044, 0.444018, 0.481304, 0.518696, 0.555982, 0.592956, 0.629410, 0.665140, 0.699946, 0.733634, 0.766016, 0.796910, 0.826144, 0.853553, 0.878986, 0.902299, 0.923362, 0.942058, 0.958281, 0.971942, 0.982963, 0.991283, 0.996856, 0.999650, 0.999650, 0.996856, 0.991283, 0.982963, 0.971942, 0.958281, 0.942058, 0.923362, 0.902299, 0.878986, 0.853553, 0.826144, 0.796910, 0.766016, 0.733634, 0.699946, 0.665140, 0.629410, 0.592956, 0.555982, 0.518696, 0.481304, 0.444018, 0.407044, 0.370590, 0.334860, 0.300054, 0.266366, 0.233984, 0.203090, 0.173856, 0.146447, 0.121014, 0.097701, 0.076638, 0.057942, 0.041719, 0.028058, 0.017037, 0.008717, 0.003144, 0.000350};
 
--- a/viterbi.cpp	Thu Mar 31 14:59:11 2011 +0100
+++ b/viterbi.cpp	Fri Apr 15 10:01:53 2011 +0000
@@ -4,8 +4,8 @@
 
 std::vector<int> ViterbiPath(std::vector<double> init, std::vector<vector<double> > trans, std::vector<vector<double> > obs, double *delta, vector<double> *scale) {
     
-    int nState = init.size();
-    int nFrame = obs.size();
+    unsigned nState = init.size();
+    unsigned nFrame = obs.size();
     
     // check for consistency
     if (trans[0].size() != nState || trans.size() != nState || obs[0].size() != nState) {
@@ -18,24 +18,24 @@
     double deltasum = 0;
     
     /* initialise first frame */
-    for (int iState = 0; iState < nState; ++iState) {
+    for (unsigned iState = 0; iState < nState; ++iState) {
         delta[iState] = init[iState] * obs[0][iState];
         deltasum += delta[iState];
     }
-    for (int iState = 0; iState < nState; ++iState) delta[iState] /= deltasum; // normalise (scale)
+    for (unsigned iState = 0; iState < nState; ++iState) delta[iState] /= deltasum; // normalise (scale)
     scale->push_back(1.0/deltasum);
     psi.push_back(vector<int>(nState,0));
     
     /* rest of the forward step */
-    for (int iFrame = 1; iFrame < nFrame; ++iFrame) {
+    for (unsigned iFrame = 1; iFrame < nFrame; ++iFrame) {
         deltasum = 0;
         psi.push_back(vector<int>(nState,0));
         /* every state wants to know which previous state suits it best */
-        for (int jState = 0; jState < nState; ++jState) {            
+        for (unsigned jState = 0; jState < nState; ++jState) {            
             int bestState = nState - 1;
             double bestValue = 0;
             if (obs[iFrame][jState] > 0) {
-                for (int iState = 0; iState < nState; ++iState) {
+                for (unsigned iState = 0; iState < nState; ++iState) {
                     double currentValue = delta[(iFrame-1) * nState + iState] * trans[iState][jState];
                     if (currentValue > bestValue) {
                         bestValue = currentValue;
@@ -49,12 +49,12 @@
             psi[iFrame][jState] = bestState;
         }
         if (deltasum > 0) {
-            for (int iState = 0; iState < nState; ++iState) {            
+            for (unsigned iState = 0; iState < nState; ++iState) {            
                 delta[iFrame * nState + iState] /= deltasum; // normalise (scale)
             }
             scale->push_back(1.0/deltasum);
         } else {
-            for (int iState = 0; iState < nState; ++iState) {            
+            for (unsigned iState = 0; iState < nState; ++iState) {            
                 delta[iFrame * nState + iState] = 1.0/nState;
             }
             scale->push_back(1.0);
@@ -64,7 +64,7 @@
     
     /* initialise backward step */
     double bestValue = 0;
-    for (int iState = 0; iState < nState; ++iState) {
+    for (unsigned iState = 0; iState < nState; ++iState) {
         double currentValue = delta[(nFrame-1) * nState + iState];
         if (currentValue > bestValue) {
             bestValue = currentValue;