plugins/puredata/aubiopitch~.c: add optional creation argument to select pitch method...
authorPaul Brossier <piem@piem.org>
Sun, 13 Jul 2008 19:56:02 +0000 (21:56 +0200)
committerPaul Brossier <piem@piem.org>
Sun, 13 Jul 2008 19:56:02 +0000 (21:56 +0200)
plugins/puredata/aubiopitch~.c

index 13df51f1b3c7c0b3ef738cf32d31c2cb1c5c1c69..96ef9452fe2ca47680acc6abdc37c90af84afc75 100644 (file)
@@ -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_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);