ref: 283a619ac024af5cc6f0ab6f75807adc6434d5b0
parent: 633400de7313737941a2d3d3e61ba37d8e7e02ea
author: Paul Brossier <piem@piem.org>
date: Thu Dec 6 06:30:54 EST 2018
[pitchshift] check if hopsize and samplerate are valid, use _set_transpose in new_, comment about final always 0
--- a/src/effects/pitchshift_rubberband.c
+++ b/src/effects/pitchshift_rubberband.c
@@ -49,12 +49,14 @@
p->samplerate = samplerate;
p->hopsize = hopsize;
p->pitchscale = 1.;
- if (transpose >= -24. && transpose <= 24.) {
- p->pitchscale = POW(2., transpose / 12.);
- } else {
- AUBIO_ERR("pitchshift: transpose should be in the range [-24, 24], got %f\n", transpose);
+ if ((sint_t)hopsize <= 0) {
+ AUBIO_ERR("pitchshift: hop_size should be >= 0, got %d\n", hopsize);
goto beach;
}
+ if ((sint_t)samplerate <= 0) {
+ AUBIO_ERR("pitchshift: samplerate should be >= 0, got %d\n", samplerate);
+ goto beach;
+ }
p->rboptions = aubio_get_rubberband_opts(mode);
if (p->rboptions < 0) {
@@ -61,6 +63,7 @@
AUBIO_ERR("pitchshift: unknown pitch shifting method %s\n", mode);
goto beach;
}
+
//AUBIO_MSG("pitchshift: using pitch shifting method %s\n", mode);
p->rb = rubberband_new(samplerate, 1, p->rboptions, 1., p->pitchscale);
@@ -67,6 +70,8 @@
rubberband_set_max_process_size(p->rb, p->hopsize);
//rubberband_set_debug_level(p->rb, 10);
+ if (aubio_pitchshift_set_transpose(p, transpose)) goto beach;
+
#if 1
// warm up rubber band
unsigned int latency = MAX(p->hopsize, rubberband_get_latency(p->rb));
@@ -139,8 +144,8 @@
void
aubio_pitchshift_do (aubio_pitchshift_t * p, const fvec_t * in, fvec_t * out)
{
- int output = 0;
- rubberband_process(p->rb, (const float* const*)&(in->data), p->hopsize, output);
+ // third parameter is always 0 since we are never expecting a final frame
+ rubberband_process(p->rb, (const float* const*)&(in->data), p->hopsize, 0);
if (rubberband_available(p->rb) >= (int)p->hopsize) {
rubberband_retrieve(p->rb, (float* const*)&(out->data), p->hopsize);
} else {