src/ofxAubioPitch.*: fix audioIn blocking loop
authorPaul Brossier <piem@piem.org>
Sat, 24 Oct 2015 22:51:02 +0000 (00:51 +0200)
committerPaul Brossier <piem@piem.org>
Sat, 24 Oct 2015 22:51:02 +0000 (00:51 +0200)
src/ofxAubioPitch.cpp
src/ofxAubioPitch.h

index 3a25426..1511456 100644 (file)
@@ -61,16 +61,16 @@ void ofxAubioPitch::audioIn(float * input, int bufferSize, int nChannels)
         // downmix into aubio_input
         aubio_input->data[curpos] = 0.;
         for (j = 0; j < nChannels; j++) {
-            aubio_input->data[curpos] += input[ (curpos + i) * nChannels + j];
+            aubio_input->data[curpos] += input[i * nChannels + j];
         }
-        aubio_input->data[curpos] /= nChannels;
+        aubio_input->data[curpos] /= (smpl_t)nChannels;
         // run aubio block when appropriate
-        if (curpos == hop_size - 1)
+        curpos += 1;
+        if (curpos == hop_size)
         {
             blockAudioIn();
-            curpos = -1;
+            curpos = 0;
         }
-        curpos += 1;
     }
 }
 
index 328808b..c29075a 100644 (file)
@@ -47,6 +47,6 @@ class ofxAubioPitch {
        fvec_t * aubio_input;
        fvec_t * aubio_output;
        aubio_pitch_t * pitch;
-       sint_t curpos;
+       uint_t curpos;
 
 };