From: Paul Brossier Date: Sun, 13 Jul 2008 19:56:02 +0000 (+0200) Subject: plugins/puredata/aubiopitch~.c: add optional creation argument to select pitch method... X-Git-Tag: bzr2git~380 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4d7ced925f1eaeaf8d77ae83e6aa744d250ff25b;p=aubio.git plugins/puredata/aubiopitch~.c: add optional creation argument to select pitch method, fix buffer size --- 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);