From 4d7ced925f1eaeaf8d77ae83e6aa744d250ff25b Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sun, 13 Jul 2008 21:56:02 +0200 Subject: [PATCH] plugins/puredata/aubiopitch~.c: add optional creation argument to select pitch method, fix buffer size --- plugins/puredata/aubiopitch~.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/plugins/puredata/aubiopitch~.c b/plugins/puredata/aubiopitch~.c index 13df51f1..96ef9452 100644 --- a/plugins/puredata/aubiopitch~.c +++ b/plugins/puredata/aubiopitch~.c @@ -9,6 +9,7 @@ #include #include +#include char aubiopitch_version[] = "aubiopitch~ version 0.1"; @@ -69,7 +70,7 @@ static void aubiopitch_tilde_debug(t_aubiopitch_tilde *x) } //static void *aubiopitch_tilde_new (t_floatarg f) -static void *aubiopitch_tilde_new (void) +static void *aubiopitch_tilde_new (t_symbol * s) { t_aubiopitch_tilde *x = (t_aubiopitch_tilde *)pd_new(aubiopitch_tilde_class); @@ -77,8 +78,22 @@ static void *aubiopitch_tilde_new (void) x->bufsize = 2048; x->hopsize = x->bufsize / 2; + if (strcmp(s->s_name,"mcomb") == 0) + type_pitch = aubio_pitch_mcomb; + else if (strcmp(s->s_name,"yinfft") == 0) + type_pitch = aubio_pitch_yin; + else if (strcmp(s->s_name,"yin") == 0) + type_pitch = aubio_pitch_yin; + else if (strcmp(s->s_name,"schmitt") == 0) + type_pitch = aubio_pitch_schmitt; + else if (strcmp(s->s_name,"fcomb") == 0) + type_pitch = aubio_pitch_fcomb; + else { + post("unknown pitch type, using default.\n"); + } + //FIXME: get the real samplerate - x->o = new_aubio_pitchdetection(x->bufsize*4, + x->o = new_aubio_pitchdetection(x->bufsize, x->hopsize, 1, 44100., type_pitch, mode_pitch); aubio_pitchdetection_set_yinthresh(x->o, 0.7); x->vec = (fvec_t *)new_fvec(x->hopsize,1); @@ -103,7 +118,7 @@ void aubiopitch_tilde_setup (void) (t_newmethod)aubiopitch_tilde_new, (t_method)aubiopitch_tilde_del, sizeof (t_aubiopitch_tilde), - CLASS_DEFAULT, A_DEFFLOAT, 0); + CLASS_DEFAULT, A_DEFSYMBOL, 0); class_addmethod(aubiopitch_tilde_class, (t_method)aubiopitch_tilde_dsp, gensym("dsp"), 0); -- 2.26.2