From a9eb93e0d739f917ca432d8b189547d210b5ffe8 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Wed, 21 Sep 2016 15:55:21 +0200 Subject: [PATCH] src/effects/pitchshift.h: use transpose, not pitchscale --- python/lib/gen_code.py | 2 +- src/effects/pitchshift.c | 11 ++++++++--- src/effects/pitchshift.h | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/python/lib/gen_code.py b/python/lib/gen_code.py index 2042fa64..872e1e81 100644 --- a/python/lib/gen_code.py +++ b/python/lib/gen_code.py @@ -19,7 +19,7 @@ aubiodefvalue = { 'ratio': '0.5', 'method': '"default"', 'uri': '"none"', - 'pitchscale': '1.', + 'transpose': '0.', } member_types = { diff --git a/src/effects/pitchshift.c b/src/effects/pitchshift.c index f5b6acfb..48e6ec96 100644 --- a/src/effects/pitchshift.c +++ b/src/effects/pitchshift.c @@ -48,13 +48,18 @@ struct _aubio_pitchshift_t aubio_pitchshift_t * new_aubio_pitchshift (const char_t * mode, - smpl_t pitchscale, uint_t hopsize, uint_t samplerate) + smpl_t transpose, uint_t hopsize, uint_t samplerate) { aubio_pitchshift_t *p = AUBIO_NEW (aubio_pitchshift_t); p->samplerate = samplerate; p->hopsize = hopsize; - p->timeratio = 1.; - p->pitchscale = pitchscale; + 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); + goto beach; + } p->rboptions = RubberBandOptionProcessRealTime; diff --git a/src/effects/pitchshift.h b/src/effects/pitchshift.h index cd9ac83e..e1252731 100644 --- a/src/effects/pitchshift.h +++ b/src/effects/pitchshift.h @@ -57,7 +57,7 @@ void del_aubio_pitchshift (aubio_pitchshift_t * o); /** creation of the pitch shifting object \param method set pitch shifting algorithm ("default") - \param pitchscale initial pitch scaling factor + \param transpose initial pitch transposition \param hop_size step size between two consecutive analysis instant \param samplerate sampling rate of the signal @@ -65,7 +65,7 @@ void del_aubio_pitchshift (aubio_pitchshift_t * o); */ aubio_pitchshift_t *new_aubio_pitchshift (const char_t * method, - smpl_t pitchscale, uint_t hop_size, uint_t samplerate); + smpl_t transpose, uint_t hop_size, uint_t samplerate); /** get the latency of the pitch shifting object, in samples -- 2.11.0