From 71034df70e37ccce785c9fb95bcd6b31caeb977a Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sun, 25 Oct 2015 00:51:02 +0200 Subject: [PATCH] src/ofxAubioPitch.*: fix audioIn blocking loop --- src/ofxAubioPitch.cpp | 10 +++++----- src/ofxAubioPitch.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ofxAubioPitch.cpp b/src/ofxAubioPitch.cpp index 3a25426..1511456 100644 --- a/src/ofxAubioPitch.cpp +++ b/src/ofxAubioPitch.cpp @@ -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; } } diff --git a/src/ofxAubioPitch.h b/src/ofxAubioPitch.h index 328808b..c29075a 100644 --- a/src/ofxAubioPitch.h +++ b/src/ofxAubioPitch.h @@ -47,6 +47,6 @@ class ofxAubioPitch { fvec_t * aubio_input; fvec_t * aubio_output; aubio_pitch_t * pitch; - sint_t curpos; + uint_t curpos; }; -- 2.11.0