diff AutocorrelationProcessor.cpp @ 44:a908a5a56267

Some unsigned -> int (while bug hunting)
author Chris Cannam
date Thu, 25 Sep 2014 15:42:15 +0100
parents 4cf2d163127b
children
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;
     }