changeset 122:21181297da99 monophonicness

replacing unsigned/size_t iterators by int and casting others to int
author matthiasm
date Fri, 15 Apr 2011 11:31:37 +0000
parents 072327bbb1a2
children b115fa66c695
files Chordino.cpp NNLSBase.cpp NNLSChroma.cpp chromamethods.cpp viterbi.cpp
diffstat 5 files changed, 35 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/Chordino.cpp	Fri Apr 15 10:21:07 2011 +0000
+++ b/Chordino.cpp	Fri Apr 15 11:31:37 2011 +0000
@@ -495,11 +495,11 @@
             }
         }
 
-//		if (*max_element(origchroma.begin(), origchroma.end()) == 0) {
-//			for (int i = 0; i < (int)chroma.size(); i++) {
-//                chroma[i] = 1;
-//           }
-//		}
+		if (*max_element(origchroma.begin(), origchroma.end()) == 0) {
+			for (int i = 0; i < (int)chroma.size(); i++) {
+                chroma[i] = 1;
+            }
+		}
 
         chromaList.push_back(currentChromas);
 
--- a/NNLSBase.cpp	Fri Apr 15 10:21:07 2011 +0000
+++ b/NNLSBase.cpp	Fri Apr 15 11:31:37 2011 +0000
@@ -26,7 +26,7 @@
 
 #include <algorithm>
 
-const bool debug_on = false;
+static bool debug_on = false;
 
 NNLSBase::NNLSBase(float inputSampleRate) :
     Plugin(inputSampleRate),
@@ -58,7 +58,7 @@
     if (debug_on) cerr << "--> NNLSBase" << endl;
     // make the *note* dictionary matrix
     m_dict = new float[nNote * 84];
-    for (unsigned i = 0; i < nNote * 84; ++i) m_dict[i] = 0.0;    
+    for (int i = 0; i < nNote * 84; ++i) m_dict[i] = 0.0;    
 }
 
 
@@ -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 (size_t iFFT = 0; iFFT < blockSize/2; ++iFFT) {
+        for (int iFFT = 0; iFFT < static_cast<int>(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) {
@@ -455,7 +455,7 @@
     float energysum = 0;
     // make magnitude
     float maxmag = -10000;
-    for (size_t iBin = 0; iBin < m_blockSize/2; iBin++) {
+    for (int iBin = 0; iBin < static_cast<int>(m_blockSize/2); iBin++) {
         magnitude[iBin] = sqrt(fbuf[2 * iBin] * fbuf[2 * iBin] + 
                                fbuf[2 * iBin + 1] * fbuf[2 * iBin + 1]);
         if (magnitude[iBin]>m_blockSize*1.0) magnitude[iBin] = m_blockSize; // a valid audio signal (between -1 and 1) should not be limited here.
@@ -467,7 +467,7 @@
 	
     float cumenergy = 0;
     if (m_rollon > 0) {
-        for (size_t iBin = 2; iBin < m_blockSize/2; iBin++) {
+        for (int iBin = 2; iBin < static_cast<int>(m_blockSize/2); iBin++) {
             cumenergy +=  pow(magnitude[iBin],2);
             if (cumenergy < energysum * m_rollon / 100) magnitude[iBin-2] = 0;
             else break;
@@ -476,7 +476,7 @@
 	
     if (maxmag < 2) {
         // cerr << "timestamp " << timestamp << ": very low magnitude, setting magnitude to all zeros" << endl;
-        for (size_t iBin = 0; iBin < m_blockSize/2; iBin++) {
+        for (int iBin = 0; iBin < static_cast<int>(m_blockSize/2); iBin++) {
             magnitude[iBin] = 0;
         }
     }
--- a/NNLSChroma.cpp	Fri Apr 15 10:21:07 2011 +0000
+++ b/NNLSChroma.cpp	Fri Apr 15 11:31:37 2011 +0000
@@ -309,7 +309,7 @@
 		        
         // cerr << intShift << " " << floatShift << endl;
 		        
-        for (unsigned k = 2; k < f1.values.size() - 3; ++k) { // interpolate all inner bins
+        for (int k = 2; k < (int)f1.values.size() - 3; ++k) { // interpolate all inner bins
             tempValue = f1.values[k + intShift] * (1-floatShift) + f1.values[k+intShift+1] * floatShift;
             f2.values.push_back(tempValue);
         }
@@ -401,11 +401,11 @@
         vector<float> chroma = vector<float>(12, 0);
         vector<float> basschroma = vector<float>(12, 0);
         float currval;
-        unsigned iSemitone = 0;
+        int iSemitone = 0;
 			
         if (some_b_greater_zero) {
             if (m_useNNLS == 0) {
-                for (unsigned iNote = nBPS/2 + 2; iNote < nNote - nBPS/2; iNote += nBPS) {
+                for (int iNote = nBPS/2 + 2; iNote < nNote - nBPS/2; iNote += nBPS) {
                     currval = 0;
                     for (int iBPS = -nBPS/2; iBPS < nBPS/2+1; ++iBPS) {
                         currval += b[iNote + iBPS] * (1-abs(iBPS*1.0/(nBPS/2+1)));						
@@ -422,7 +422,7 @@
                 vector<int> signifIndex;
                 int index=0;
                 sumb /= 84.0;
-                for (unsigned iNote = nBPS/2 + 2; iNote < nNote - nBPS/2; iNote += nBPS) {
+                for (int iNote = nBPS/2 + 2; iNote < nNote - nBPS/2; iNote += nBPS) {
                     float currval = 0;
                     for (int iBPS = -nBPS/2; iBPS < nBPS/2+1; ++iBPS) {
                         currval += b[iNote + iBPS]; 
@@ -540,17 +540,17 @@
                 break;
             }
             if (chromanorm[0] > 0) {
-                for (size_t i = 0; i < f4.values.size(); i++) {
+                for (int i = 0; i < (int)f4.values.size(); i++) {
                     f4.values[i] /= chromanorm[0];
                 }
             }
             if (chromanorm[1] > 0) {
-                for (size_t i = 0; i < f5.values.size(); i++) {
+                for (int i = 0; i < (int)f5.values.size(); i++) {
                     f5.values[i] /= chromanorm[1];
                 }
             }
             if (chromanorm[2] > 0) {
-                for (size_t i = 0; i < f6.values.size(); i++) {
+                for (int i = 0; i < (int)f6.values.size(); i++) {
                     f6.values[i] /= chromanorm[2];
                 }
             }
--- a/chromamethods.cpp	Fri Apr 15 10:21:07 2011 +0000
+++ b/chromamethods.cpp	Fri Apr 15 11:31:37 2011 +0000
@@ -150,7 +150,7 @@
         int curr_start = oversampling * iFFT - oversampling;
         int curr_end = oversampling * iFFT + oversampling; // don't know if I should add "+1" here
         // cerr << oversampled_f[curr_start] << " " << fft_f[iFFT] << " " << oversampled_f[curr_end] << endl;
-        for (unsigned iCQ = 0; iCQ < cq_f.size(); ++iCQ) {
+        for (int iCQ = 0; iCQ < (int)cq_f.size(); ++iCQ) {
             outmatrix[iFFT + nFFT * iCQ] = 0;
             if (cq_f[iCQ] * pow(2.0, 0.084) + fft_width > fft_f[iFFT] && cq_f[iCQ] * pow(2.0, -0.084 * 2) - fft_width < fft_f[iFFT]) { // within a generous neighbourhood
                 for (int iOS = curr_start; iOS < curr_end; ++iOS) {
@@ -370,8 +370,8 @@
 	};
 
     bool hasExternalDictinoary = true;
-    
-    for (size_t i = 0; i < ppath.size(); ++i) {
+	int ppathsize = static_cast<int>(ppath.size());
+    for (int i = 0; i < ppathsize; ++i) {
     	chordDictFilename = ppath[i] + "/" + chordDictBase;
     	cerr << "Looking for chord.dict in " << chordDictFilename << "..." ;
     	fstream fin;
@@ -382,7 +382,7 @@
     	    cerr << " success." << endl;
     	    break;
         } else {
-            if (i+1 < ppath.size()) cerr << " (not found yet) ..." << endl;
+            if (i+1 < ppathsize) cerr << " (not found yet) ..." << endl;
             else {
                 cerr << "* WARNING: failed to find chord dictionary, using default chord dictionary." << endl;
                 hasExternalDictinoary = false;                
@@ -487,8 +487,8 @@
 
     // N type
     loadedChordNames.push_back("N");
-    for (unsigned kSemitone = 0; kSemitone < 12; kSemitone++) loadedChordDict.push_back(0.5);
-    for (unsigned kSemitone = 0; kSemitone < 12; kSemitone++) loadedChordDict.push_back(1.0);
+    for (int kSemitone = 0; kSemitone < 12; kSemitone++) loadedChordDict.push_back(0.5);
+    for (int kSemitone = 0; kSemitone < 12; kSemitone++) loadedChordDict.push_back(1.0);
     vector<int> tempchordvector;
     m_chordnotes->push_back(tempchordvector);
     float exponent = 2.0;
--- a/viterbi.cpp	Fri Apr 15 10:21:07 2011 +0000
+++ b/viterbi.cpp	Fri Apr 15 11:31:37 2011 +0000
@@ -4,11 +4,11 @@
 
 std::vector<int> ViterbiPath(std::vector<double> init, std::vector<vector<double> > trans, std::vector<vector<double> > obs, double *delta, vector<double> *scale) {
     
-    unsigned nState = init.size();
-    unsigned nFrame = obs.size();
+    int nState = init.size();
+    int nFrame = obs.size();
     
     // check for consistency
-    if (trans[0].size() != nState || trans.size() != nState || obs[0].size() != nState) {
+    if ((int)trans[0].size() != nState || (int)trans.size() != nState || (int)obs[0].size() != nState) {
         cerr << "ERROR: matrix sizes inconsistent." << endl;
     }
 
@@ -18,24 +18,24 @@
     double deltasum = 0;
     
     /* initialise first frame */
-    for (unsigned iState = 0; iState < nState; ++iState) {
+    for (int iState = 0; iState < nState; ++iState) {
         delta[iState] = init[iState] * obs[0][iState];
         deltasum += delta[iState];
     }
-    for (unsigned iState = 0; iState < nState; ++iState) delta[iState] /= deltasum; // normalise (scale)
+    for (int 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 (unsigned iFrame = 1; iFrame < nFrame; ++iFrame) {
+    for (int 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 (unsigned jState = 0; jState < nState; ++jState) {            
+        for (int jState = 0; jState < nState; ++jState) {            
             int bestState = nState - 1;
             double bestValue = 0;
             if (obs[iFrame][jState] > 0) {
-                for (unsigned iState = 0; iState < nState; ++iState) {
+                for (int 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 (unsigned iState = 0; iState < nState; ++iState) {            
+            for (int iState = 0; iState < nState; ++iState) {            
                 delta[iFrame * nState + iState] /= deltasum; // normalise (scale)
             }
             scale->push_back(1.0/deltasum);
         } else {
-            for (unsigned iState = 0; iState < nState; ++iState) {            
+            for (int 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 (unsigned iState = 0; iState < nState; ++iState) {
+    for (int iState = 0; iState < nState; ++iState) {
         double currentValue = delta[(nFrame-1) * nState + iState];
         if (currentValue > bestValue) {
             bestValue = currentValue;