From: Paul Brossier Date: Thu, 8 Oct 2009 18:54:49 +0000 (+0200) Subject: examples plugins: update to latest pitch prototypes X-Git-Tag: bzr2git~151 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=61316a6f46a4313d6e200a11211cbd37e0155fd6;p=aubio.git examples plugins: update to latest pitch prototypes --- diff --git a/examples/aubionotes.c b/examples/aubionotes.c index 43e9da6d..39af51b8 100644 --- a/examples/aubionotes.c +++ b/examples/aubionotes.c @@ -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); } diff --git a/examples/utils.c b/examples/utils.c index 8b9e9b64..3800e4ca 100644 --- a/examples/utils.c +++ b/examples/utils.c @@ -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); diff --git a/examples/utils.h b/examples/utils.h index b01defcb..4bf51204 100644 --- a/examples/utils.h +++ b/examples/utils.h @@ -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; diff --git a/plugins/puredata/aubiopitch~.c b/plugins/puredata/aubiopitch~.c index 96ef9452..fad8882b 100644 --- a/plugins/puredata/aubiopitch~.c +++ b/plugins/puredata/aubiopitch~.c @@ -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;jvec, 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; }