examples plugins: update to latest pitch prototypes
authorPaul Brossier <piem@piem.org>
Thu, 8 Oct 2009 18:54:49 +0000 (20:54 +0200)
committerPaul Brossier <piem@piem.org>
Thu, 8 Oct 2009 18:54:49 +0000 (20:54 +0200)
examples/aubionotes.c
examples/utils.c
examples/utils.h
plugins/puredata/aubiopitch~.c

index 43e9da6d5c0a93106e0ae3dd6c8e6ad7e7eaa86a..39af51b82ec6295f41761444e46aab899b8da016 100644 (file)
@@ -45,7 +45,8 @@ int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
       }
       isonset = aubio_peakpicker_do(parms, onset);
       
-      pitch = aubio_pitchdetection_do (pitchdet,ibuf);
+      aubio_pitchdetection_do (pitchdet, ibuf, pitch_obuf);
+      pitch = fvec_read_sample(pitch_obuf, 0, 0);
       if(median){
               note_append(note_buffer, pitch);
       }
index 8b9e9b6498b2cbe9d8f6632012834100f16342b5..3800e4cae47ce3ae187460b5d911dd630af21f36 100644 (file)
@@ -61,6 +61,7 @@ aubio_sndfile_t *fileout = NULL;
 aubio_pvoc_t *pv;
 fvec_t *ibuf;
 fvec_t *obuf;
+fvec_t *pitch_obuf;
 cvec_t *fftgrain;
 fvec_t *woodblock;
 aubio_onsetdetection_t *o;
@@ -318,7 +319,8 @@ examples_common_init (int argc, char **argv)
   if (usepitch) {
     pitchdet = new_aubio_pitchdetection (buffer_size * 4,
         overlap_size, channels, samplerate, type_pitch, mode_pitch);
-    aubio_pitchdetection_set_yinthresh (pitchdet, 0.7);
+    aubio_pitchdetection_set_tolerance (pitchdet, 0.7);
+    pitch_obuf = new_fvec (1, channels);
 
     if (median) {
       note_buffer = new_fvec (median, 1);
@@ -349,6 +351,7 @@ examples_common_del (void)
       del_fvec (note_buffer);
       del_fvec (note_buffer2);
     }
+    del_fvec (pitch_obuf);
   }
   if (usedoubled) {
     del_aubio_onsetdetection (o2);
index b01defcb1bdc8f16b0223218b5cd5de4f1b32cb6..4bf51204c61f9767fd088e30b2eaaf21a2b0fdec 100644 (file)
@@ -94,6 +94,7 @@ extern aubio_sndfile_t *fileout;
 extern aubio_pvoc_t *pv;
 extern fvec_t *ibuf;
 extern fvec_t *obuf;
+extern fvec_t *pitch_obuf;
 extern cvec_t *fftgrain;
 extern fvec_t *woodblock;
 extern aubio_onsetdetection_t *o;
index 96ef9452fe2ca47680acc6abdc37c90af84afc75..fad8882b14e5b5493f8aa79a27c2cb7c1adae510 100644 (file)
@@ -30,6 +30,7 @@ typedef struct _aubiopitch_tilde
        t_int hopsize;
        aubio_pitchdetection_t *o;
        fvec_t *vec;
+       fvec_t *pitchvec;
        t_outlet *pitch;
 } t_aubiopitch_tilde;
 
@@ -39,15 +40,14 @@ static t_int *aubiopitch_tilde_perform(t_int *w)
        t_sample *in          = (t_sample *)(w[2]);
        int n                 = (int)(w[3]);
        int j;
-       smpl_t pitch;
        for (j=0;j<n;j++) {
                /* write input to datanew */
                fvec_write_sample(x->vec, in[j], 0, x->pos);
                /*time for fft*/
                if (x->pos == x->hopsize-1) {         
                        /* block loop */
-                       pitch = aubio_pitchdetection(x->o,x->vec);
-                       outlet_float(x->pitch, pitch);
+                       aubio_pitchdetection_do(x->o,x->vec, x->pitchvec);
+                       outlet_float(x->pitch, x->pitchvec->data[0][0]);
                        /* end of block loop */
                        x->pos = -1; /* so it will be zero next j loop */
                }
@@ -95,8 +95,9 @@ static void *aubiopitch_tilde_new (t_symbol * s)
        //FIXME: get the real samplerate
        x->o = new_aubio_pitchdetection(x->bufsize, 
                     x->hopsize, 1, 44100., type_pitch, mode_pitch);
-       aubio_pitchdetection_set_yinthresh(x->o, 0.7);
+       aubio_pitchdetection_set_tolerance (x->o, 0.7);
        x->vec = (fvec_t *)new_fvec(x->hopsize,1);
+       x->pitchvec = (fvec_t *)new_fvec(1,1);
 
        //floatinlet_new (&x->x_obj, &x->threshold);
        x->pitch = outlet_new (&x->x_obj, &s_float);
@@ -109,6 +110,7 @@ static void *aubiopitch_tilde_del(t_aubiopitch_tilde *x)
 {
        del_aubio_pitchdetection(x->o);
        del_fvec(x->vec);
+       del_fvec(x->pitchvec);
        return 0;
 }