ref: 4d7ced925f1eaeaf8d77ae83e6aa744d250ff25b
parent: 528887420eee6e366b5af32c484ca164cfafd344
author: Paul Brossier <piem@piem.org>
date: Sun Jul 13 17:56:02 EDT 2008
plugins/puredata/aubiopitch~.c: add optional creation argument to select pitch method, fix buffer size
--- a/plugins/puredata/aubiopitch~.c
+++ b/plugins/puredata/aubiopitch~.c
@@ -9,6 +9,7 @@
#include <m_pd.h>
#include <aubio.h>
+#include <string.h>
char aubiopitch_version[] = "aubiopitch~ version 0.1";
@@ -69,7 +70,7 @@
}
//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 @@
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 @@
(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);