changeset 44:a908a5a56267

Some unsigned -> int (while bug hunting)
author Chris Cannam
date Thu, 25 Sep 2014 15:42:15 +0100
parents 4cf2d163127b
children e6a43500629b
files AutocorrelationProcessor.cpp AutocorrelationProcessor.h TempogramPlugin.cpp
diffstat 3 files changed, 16 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/AutocorrelationProcessor.cpp	Thu Sep 25 15:13:45 2014 +0100
+++ b/AutocorrelationProcessor.cpp	Thu Sep 25 15:42:15 2014 +0100
@@ -16,7 +16,7 @@
 using namespace std;
 #include <iostream>
 
-AutocorrelationProcessor::AutocorrelationProcessor(const size_t &windowLength, const unsigned int &hopSize) :
+AutocorrelationProcessor::AutocorrelationProcessor(int windowLength, int hopSize) :
     m_windowLength(windowLength),
     m_hopSize(hopSize)
 {
@@ -28,30 +28,29 @@
 
 }
 
-AutoCorrelation AutocorrelationProcessor::process(float * input, const size_t &inputLength) const
+AutoCorrelation AutocorrelationProcessor::process(float * input, int inputLength) const
 {
     int readBlockPointerIndex = 0;
     AutoCorrelation autocorrelation;
     
-    while(readBlockPointerIndex <= (int)inputLength) {
+    while(readBlockPointerIndex <= inputLength) {
         
         vector<float> autocorrelationBlock;
         
-        for (int lag = 0; lag < (int)m_windowLength; lag++){
+        for (int lag = 0; lag < m_windowLength; lag++){
             float sum = 0;
             int readPointer = readBlockPointerIndex - m_windowLength/2;
             
             for (int n = 0; n < (int)m_windowLength; n++){
-                if (readPointer+lag >= (int)inputLength) break;
-                else if (readPointer >= 0) sum += input[readPointer]*input[readPointer+lag];
-                //else cout << readPointer << " : "<< lag << "/" << m_windowLength << endl;
-                
+                if (readPointer+lag >= inputLength) break;
+                else if (readPointer >= 0) {
+		    sum += input[readPointer]*input[readPointer+lag];
+		}
                 readPointer++;
             }
             autocorrelationBlock.push_back(sum/(2*m_windowLength + 1 - lag));
         }
         
-        //autocorrelation.push_back(processBlock());
         autocorrelation.push_back(autocorrelationBlock);
         readBlockPointerIndex += m_hopSize;
     }
--- a/AutocorrelationProcessor.h	Thu Sep 25 15:13:45 2014 +0100
+++ b/AutocorrelationProcessor.h	Thu Sep 25 15:42:15 2014 +0100
@@ -22,12 +22,12 @@
 
 class AutocorrelationProcessor{
 public:
-    AutocorrelationProcessor(const size_t &windowLength, const unsigned int &hopSize);
+    AutocorrelationProcessor(int windowLength, int hopSize);
     ~AutocorrelationProcessor();
-    AutoCorrelation process(float * input, const size_t &inputLength) const;
+    AutoCorrelation process(float * input, int inputLength) const;
 private:
-    size_t m_windowLength;
-    unsigned int m_hopSize;
+    int m_windowLength;
+    int m_hopSize;
 };
 
 #endif /* defined(__Tempogram__Autocorrelation__) */
--- a/TempogramPlugin.cpp	Thu Sep 25 15:13:45 2014 +0100
+++ b/TempogramPlugin.cpp	Thu Sep 25 15:42:15 2014 +0100
@@ -505,10 +505,14 @@
     
     for (int block = 0; block < tempogramLength; block++){
         Feature tempogramACTFeature;
+
+//	cerr << "block = " << block << ", window length = " << m_tempogramWindowLength << ", max lag = " << m_tempogramMaxLag << ", min lag = " << m_tempogramMinLag << endl;
         
         for(int k = m_tempogramMaxLag; k >= (int)m_tempogramMinLag; k--){
+//	    cerr << "(" << block << "," << k << ") ";
             tempogramACTFeature.values.push_back(tempogramACT[block][k]);
         }
+//	cerr << endl;
         tempogramACTFeature.hasTimestamp = false;
         featureSet[2].push_back(tempogramACTFeature);
     }