src/effects/pitchshift.h: use transpose, not pitchscale
authorPaul Brossier <piem@piem.org>
Wed, 21 Sep 2016 13:55:21 +0000 (15:55 +0200)
committerPaul Brossier <piem@piem.org>
Wed, 21 Sep 2016 13:55:21 +0000 (15:55 +0200)
python/lib/gen_code.py
src/effects/pitchshift.c
src/effects/pitchshift.h

index 2042fa6..872e1e8 100644 (file)
@@ -19,7 +19,7 @@ aubiodefvalue = {
     'ratio': '0.5',
     'method': '"default"',
     'uri': '"none"',
-    'pitchscale': '1.',
+    'transpose': '0.',
     }
 
 member_types = {
index f5b6acf..48e6ec9 100644 (file)
@@ -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;
 
index cd9ac83..e125273 100644 (file)
@@ -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