From 36e9cfebfe96ae3761ce6c9345a05712e3624a00 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 19 Sep 2016 20:22:45 +0200 Subject: [PATCH] src/effects/pitchshift.c: simplify _do, calling available after process --- src/effects/pitchshift.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/effects/pitchshift.c b/src/effects/pitchshift.c index 8aa7d87a..4e22c04e 100644 --- a/src/effects/pitchshift.c +++ b/src/effects/pitchshift.c @@ -173,13 +173,15 @@ void aubio_pitchshift_do (aubio_pitchshift_t * p, const fvec_t * in, fvec_t * out) { int output = 0; - // this may occur when RubberBandStretcher initialPitchScale is changed - while (rubberband_available(p->rb) <= (int)p->hopsize) { - //AUBIO_WRN("pitchshift: catching up, only %d available\n", rubberband_available(p->rb)); - rubberband_process(p->rb, (const float* const*)&(in->data), 0, output); - } rubberband_process(p->rb, (const float* const*)&(in->data), p->hopsize, output); - rubberband_retrieve(p->rb, (float* const*)&(out->data), p->hopsize); + if (rubberband_available(p->rb) >= (int)p->hopsize) { + rubberband_retrieve(p->rb, (float* const*)&(out->data), p->hopsize); + } else { + AUBIO_WRN("pitchshift: catching up with zeros, only %d available, needed: %d, " + "current pitchscale: %f\n", + rubberband_available(p->rb), p->hopsize, p->pitchscale); + fvec_zeros(out); + } } #else -- 2.11.0