import c files from aubio r920, using <aubio/aubio.h> include
authorPaul Brossier <piem@piem.org>
Thu, 5 Nov 2009 14:10:15 +0000 (15:10 +0100)
committerPaul Brossier <piem@piem.org>
Thu, 5 Nov 2009 14:10:15 +0000 (15:10 +0100)
14 files changed:
aubio_setup.c [new file with mode: 0644]
aubioonset~.c [new file with mode: 0644]
aubiopitch~.c [new file with mode: 0644]
aubioquiet~.c [new file with mode: 0644]
aubiotempo~.c [new file with mode: 0644]
aubiotss~.c [new file with mode: 0644]
aubiozcr~.c [new file with mode: 0644]
examples/onset-cam.pd [new file with mode: 0644]
help/aubioonset~-help.pd [new file with mode: 0644]
help/aubiopitch~-help.pd [new file with mode: 0644]
help/aubioquiet~-help.pd [new file with mode: 0644]
help/aubiotempo~-help.pd [new file with mode: 0644]
help/aubiotss~-help.pd [new file with mode: 0644]
help/aubiozcr~-help.pd [new file with mode: 0644]

diff --git a/aubio_setup.c b/aubio_setup.c
new file mode 100644 (file)
index 0000000..31c1a2b
--- /dev/null
@@ -0,0 +1,39 @@
+
+#include <m_pd.h>
+
+char aubio_version[] = "aubio external for pd, version 0.2";
+
+static t_class *aubio_class;
+
+typedef struct aubio
+{
+    t_object x_ob;
+} t_aubio;
+
+void *aubio_new (void);
+void aubio_setup (void);
+extern void aubioonset_tilde_setup (void);
+extern void aubiotempo_tilde_setup (void);
+extern void aubiotss_tilde_setup (void);
+extern void aubioquiet_tilde_setup (void);
+extern void aubiopitch_tilde_setup (void);
+extern void aubiozcr_tilde_setup (void);
+
+void *aubio_new (void)
+{
+    t_aubio *x = (t_aubio *)pd_new(aubio_class);
+    return (void *)x;
+}
+
+void aubio_setup (void)
+{
+    post(aubio_version);
+    aubioonset_tilde_setup();
+    aubiotempo_tilde_setup();
+    aubiotss_tilde_setup();
+    aubioquiet_tilde_setup();
+    aubiopitch_tilde_setup();
+    aubiozcr_tilde_setup();
+    aubio_class = class_new(gensym("aubio"), (t_newmethod)aubio_new, 0,
+            sizeof(t_aubio), 0, 0);
+}
diff --git a/aubioonset~.c b/aubioonset~.c
new file mode 100644 (file)
index 0000000..2b0b7d3
--- /dev/null
@@ -0,0 +1,105 @@
+/**
+ *
+ * a puredata wrapper for aubio onset detection functions 
+ *
+ * Thanks to Johannes M Zmolnig for writing the excellent HOWTO:
+ *       http://iem.kug.ac.at/pd/externals-HOWTO/  
+ *
+ * */
+
+#include <m_pd.h>
+#include <aubio/aubio.h>
+
+char aubioonset_version[] = "aubioonset~ version 0.3";
+
+static t_class *aubioonset_tilde_class;
+
+void aubioonset_tilde_setup (void);
+
+typedef struct _aubioonset_tilde
+{
+  t_object x_obj;
+  t_float threshold;
+  t_int pos;                    /*frames%dspblocksize */
+  t_int bufsize;
+  t_int hopsize;
+  aubio_onset_t *o;
+  fvec_t *in;
+  fvec_t *out;
+  t_outlet *onsetbang;
+} t_aubioonset_tilde;
+
+static t_int *
+aubioonset_tilde_perform (t_int * w)
+{
+  t_aubioonset_tilde *x = (t_aubioonset_tilde *) (w[1]);
+  t_sample *in = (t_sample *) (w[2]);
+  int n = (int) (w[3]);
+  int j;
+  for (j = 0; j < n; j++) {
+    /* write input to datanew */
+    fvec_write_sample (x->in, in[j], 0, x->pos);
+    /*time to do something */
+    if (x->pos == x->hopsize - 1) {
+      /* block loop */
+      aubio_onset_do (x->o, x->in, x->out);
+      if (fvec_read_sample (x->out, 0, 0) > 0.) {
+        outlet_bang (x->onsetbang);
+      }
+      /* end of block loop */
+      x->pos = -1;              /* so it will be zero next j loop */
+    }
+    x->pos++;
+  }
+  return (w + 4);
+}
+
+static void
+aubioonset_tilde_dsp (t_aubioonset_tilde * x, t_signal ** sp)
+{
+  dsp_add (aubioonset_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
+}
+
+static void
+aubioonset_tilde_debug (t_aubioonset_tilde * x)
+{
+  post ("aubioonset~ bufsize:\t%d", x->bufsize);
+  post ("aubioonset~ hopsize:\t%d", x->hopsize);
+  post ("aubioonset~ threshold:\t%f", x->threshold);
+  post ("aubioonset~ audio in:\t%f", x->in->data[0][0]);
+  post ("aubioonset~ onset:\t%f", x->out->data[0][0]);
+}
+
+static void *
+aubioonset_tilde_new (t_floatarg f)
+{
+  t_aubioonset_tilde *x =
+      (t_aubioonset_tilde *) pd_new (aubioonset_tilde_class);
+
+  x->threshold = (f < 1e-5) ? 0.1 : (f > 10.) ? 10. : f;
+  x->bufsize = 1024;
+  x->hopsize = x->bufsize / 2;
+
+  x->o = new_aubio_onset ("complex",
+      x->bufsize, x->hopsize, 1, (uint_t) sys_getsr ());
+  x->in = (fvec_t *) new_fvec (x->hopsize, 1);
+  x->out = (fvec_t *) new_fvec (1, 1);
+
+  floatinlet_new (&x->x_obj, &x->threshold);
+  x->onsetbang = outlet_new (&x->x_obj, &s_bang);
+  post (aubioonset_version);
+  return (void *) x;
+}
+
+void
+aubioonset_tilde_setup (void)
+{
+  aubioonset_tilde_class = class_new (gensym ("aubioonset~"),
+      (t_newmethod) aubioonset_tilde_new,
+      0, sizeof (t_aubioonset_tilde), CLASS_DEFAULT, A_DEFFLOAT, 0);
+  class_addmethod (aubioonset_tilde_class,
+      (t_method) aubioonset_tilde_dsp, gensym ("dsp"), 0);
+  class_addmethod (aubioonset_tilde_class,
+      (t_method) aubioonset_tilde_debug, gensym ("debug"), 0);
+  CLASS_MAINSIGNALIN (aubioonset_tilde_class, t_aubioonset_tilde, threshold);
+}
diff --git a/aubiopitch~.c b/aubiopitch~.c
new file mode 100644 (file)
index 0000000..43b7581
--- /dev/null
@@ -0,0 +1,116 @@
+/**
+ *
+ * a puredata wrapper for aubio pitch detection functions 
+ *
+ * Thanks to Johannes M Zmolnig for writing the excellent HOWTO:
+ *       http://iem.kug.ac.at/pd/externals-HOWTO/  
+ *
+ * */
+
+#include <m_pd.h>
+#include <aubio/aubio.h>
+#include <string.h>
+
+char aubiopitch_version[] = "aubiopitch~ version 0.1";
+
+static t_class *aubiopitch_tilde_class;
+
+void aubiopitch_tilde_setup (void);
+
+typedef struct _aubiopitch_tilde 
+{
+       t_object x_obj;
+       t_float threshold;      
+       t_float threshold2;     
+       t_int pos; /*frames%dspblocksize*/
+       t_int bufsize;
+       t_int hopsize;
+       aubio_pitch_t *o;
+       fvec_t *vec;
+       fvec_t *pitchvec;
+       t_outlet *pitch;
+} t_aubiopitch_tilde;
+
+static t_int *aubiopitch_tilde_perform(t_int *w) 
+{
+       t_aubiopitch_tilde *x = (t_aubiopitch_tilde *)(w[1]);
+       t_sample *in          = (t_sample *)(w[2]);
+       int n                 = (int)(w[3]);
+       int j;
+       for (j=0;j<n;j++) {
+               /* write input to datanew */
+               fvec_write_sample(x->vec, in[j], 0, x->pos);
+               /*time for fft*/
+               if (x->pos == x->hopsize-1) {         
+                       /* block loop */
+                       aubio_pitch_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 */
+               }
+               x->pos++;
+       }
+       return (w+4);
+}
+
+static void aubiopitch_tilde_dsp(t_aubiopitch_tilde *x, t_signal **sp)
+{
+       dsp_add(aubiopitch_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
+}
+
+static void aubiopitch_tilde_debug(t_aubiopitch_tilde *x)
+{
+       post("aubiopitch~ bufsize:\t%d", x->bufsize);
+       post("aubiopitch~ hopsize:\t%d", x->hopsize);
+       post("aubiopitch~ threshold:\t%f", x->threshold);
+       post("aubiopitch~ audio in:\t%f", x->vec->data[0][0]);
+}
+
+//static void *aubiopitch_tilde_new (t_floatarg f)
+static void *aubiopitch_tilde_new (t_symbol * s)
+{
+       t_aubiopitch_tilde *x = 
+               (t_aubiopitch_tilde *)pd_new(aubiopitch_tilde_class);
+
+       x->bufsize   = 2048;
+       x->hopsize   = x->bufsize / 2;
+
+       //FIXME: get the real samplerate
+    x->o = new_aubio_pitch(s->s_name, x->bufsize, 
+            x->hopsize, 1, 44100.);
+       aubio_pitch_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);
+
+       post(aubiopitch_version);
+       return (void *)x;
+}
+
+static void *aubiopitch_tilde_del(t_aubiopitch_tilde *x)
+{
+       del_aubio_pitch(x->o);
+       del_fvec(x->vec);
+       del_fvec(x->pitchvec);
+       return 0;
+}
+
+void aubiopitch_tilde_setup (void)
+{
+       aubiopitch_tilde_class = class_new (gensym ("aubiopitch~"),
+                       (t_newmethod)aubiopitch_tilde_new,
+                       (t_method)aubiopitch_tilde_del,
+                       sizeof (t_aubiopitch_tilde),
+                       CLASS_DEFAULT, A_DEFSYMBOL, 0);
+       class_addmethod(aubiopitch_tilde_class, 
+                       (t_method)aubiopitch_tilde_dsp, 
+                       gensym("dsp"), 0);
+       class_addmethod(aubiopitch_tilde_class, 
+                       (t_method)aubiopitch_tilde_debug,
+                       gensym("debug"), 0);
+       CLASS_MAINSIGNALIN(aubiopitch_tilde_class, 
+                       t_aubiopitch_tilde, threshold);
+}
+
diff --git a/aubioquiet~.c b/aubioquiet~.c
new file mode 100644 (file)
index 0000000..547534b
--- /dev/null
@@ -0,0 +1,117 @@
+/**
+ *
+ * a puredata wrapper for aubioquiet
+ *
+ * Thanks to Johannes M Zmolnig for writing the excellent HOWTO:
+ *       http://iem.kug.ac.at/pd/externals-HOWTO/  
+ *
+ * */
+
+#include <m_pd.h>
+#include <aubio/aubio.h>
+
+char aubioquiet_version[] = "aubioquiet~ version 0.1";
+
+static t_class *aubioquiet_tilde_class;
+
+void aubioquiet_tilde_setup (void);
+
+typedef struct _aubioquiet_tilde 
+{
+       t_object x_obj;
+       t_float threshold;
+       t_int pos; /*frames%dspblocksize*/
+       t_int bufsize;
+       t_int hopsize;
+       t_int wassilence;
+       t_int issilence;
+       fvec_t *vec;
+       t_outlet *quietbang;
+       t_outlet *noisybang;
+} t_aubioquiet_tilde;
+
+static t_int *aubioquiet_tilde_perform(t_int *w) 
+{
+       t_aubioquiet_tilde *x = (t_aubioquiet_tilde *)(w[1]);
+       t_sample *in          = (t_sample *)(w[2]);
+       int n                 = (int)(w[3]);
+       int j;
+       for (j=0;j<n;j++) {
+               /* write input to datanew */
+               fvec_write_sample(x->vec, in[j], 0, x->pos);
+               /*time for fft*/
+               if (x->pos == x->hopsize-1) {         
+                       /* block loop */
+                       if (aubio_silence_detection(x->vec, x->threshold)==1) {
+                               if (x->wassilence==1) {
+                                       x->issilence = 1;
+                               } else {
+                                       x->issilence = 2;
+                                       outlet_bang(x->quietbang);
+                               }
+                               x->wassilence=1;
+                       } else { 
+                               if (x->wassilence<=0) {
+                                       x->issilence = 0;
+                               } else {
+                                       x->issilence = -1;
+                                       outlet_bang(x->noisybang);
+                               }
+                               x->wassilence=0;
+                       }
+                       /* end of block loop */
+                       x->pos = -1; /* so it will be zero next j loop */
+               }
+               x->pos++;
+       }
+       return (w+4);
+}
+
+static void aubioquiet_tilde_dsp(t_aubioquiet_tilde *x, t_signal **sp)
+{
+       dsp_add(aubioquiet_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
+}
+
+static void aubioquiet_tilde_debug(t_aubioquiet_tilde *x)
+{
+       post("aubioquiet~ bufsize:\t%d", x->bufsize);
+       post("aubioquiet~ hopsize:\t%d", x->hopsize);
+       post("aubioquiet~ threshold:\t%f", x->threshold);
+       post("aubioquiet~ audio in:\t%f", x->vec->data[0][0]);
+}
+
+static void *aubioquiet_tilde_new (t_floatarg f)
+{
+       t_aubioquiet_tilde *x = 
+               (t_aubioquiet_tilde *)pd_new(aubioquiet_tilde_class);
+
+       x->threshold = (f < -1000.) ? -70 : (f >= 0.) ? -70. : f;
+       x->bufsize   = 1024;
+       x->hopsize   = x->bufsize / 2;
+
+       x->vec = (fvec_t *)new_fvec(x->hopsize,1);
+       x->wassilence = 1;
+
+       floatinlet_new (&x->x_obj, &x->threshold);
+       x->quietbang = outlet_new (&x->x_obj, &s_bang);
+       x->noisybang = outlet_new (&x->x_obj, &s_bang);
+       post(aubioquiet_version);
+       return (void *)x;
+}
+
+void aubioquiet_tilde_setup (void)
+{
+       aubioquiet_tilde_class = class_new (gensym ("aubioquiet~"),
+                       (t_newmethod)aubioquiet_tilde_new,
+                       0, sizeof (t_aubioquiet_tilde),
+                       CLASS_DEFAULT, A_DEFFLOAT, 0);
+       class_addmethod(aubioquiet_tilde_class, 
+                       (t_method)aubioquiet_tilde_dsp, 
+                       gensym("dsp"), 0);
+       class_addmethod(aubioquiet_tilde_class, 
+                       (t_method)aubioquiet_tilde_debug,
+                       gensym("debug"), 0);
+       CLASS_MAINSIGNALIN(aubioquiet_tilde_class, 
+                       t_aubioquiet_tilde, threshold);
+}
+
diff --git a/aubiotempo~.c b/aubiotempo~.c
new file mode 100644 (file)
index 0000000..94f85d5
--- /dev/null
@@ -0,0 +1,123 @@
+/**
+ *
+ * a puredata wrapper for aubio tempo detection functions 
+ *
+ * Thanks to Johannes M Zmolnig for writing the excellent HOWTO:
+ *       http://iem.kug.ac.at/pd/externals-HOWTO/  
+ *
+ * */
+
+#include <m_pd.h>
+#include <aubio/aubio.h>
+
+char aubiotempo_version[] = "aubiotempo~ version 0.2";
+
+static t_class *aubiotempo_tilde_class;
+
+void aubiotempo_tilde_setup (void);
+
+typedef struct _aubiotempo_tilde 
+{
+  t_object x_obj;
+  t_float threshold;
+  t_float silence;
+  t_int pos; /*frames%dspblocksize*/
+  t_int bufsize;
+  t_int hopsize;
+  aubio_tempo_t * t;
+  fvec_t *vec;
+  fvec_t *output;
+  t_outlet *tempobang;
+  t_outlet *onsetbang;
+} t_aubiotempo_tilde;
+
+static t_int *aubiotempo_tilde_perform(t_int *w) 
+{
+  t_aubiotempo_tilde *x = (t_aubiotempo_tilde *)(w[1]);
+  t_sample *in          = (t_sample *)(w[2]);
+  int n                 = (int)(w[3]);
+  int j;
+  for (j=0;j<n;j++) {
+    /* write input to datanew */
+    fvec_write_sample(x->vec, in[j], 0, x->pos);
+    /*time for fft*/
+    if (x->pos == x->hopsize-1) {         
+      /* block loop */
+      aubio_tempo_do (x->t, x->vec, x->output);
+      if (x->output->data[0][0]) {
+        outlet_bang(x->tempobang);
+      }
+      if (x->output->data[0][1]) {
+        outlet_bang(x->onsetbang);
+      }
+      /* end of block loop */
+      x->pos = -1; /* so it will be zero next j loop */
+    }
+    x->pos++;
+  }
+  return (w+4);
+}
+
+static void aubiotempo_tilde_dsp(t_aubiotempo_tilde *x, t_signal **sp)
+{
+  dsp_add(aubiotempo_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
+}
+
+static void aubiotempo_tilde_debug(t_aubiotempo_tilde *x)
+{
+  post("aubiotempo~ bufsize:\t%d", x->bufsize);
+  post("aubiotempo~ hopsize:\t%d", x->hopsize);
+  post("aubiotempo~ threshold:\t%f", x->threshold);
+  post("aubiotempo~ audio in:\t%f", x->vec->data[0][0]);
+}
+
+static void *aubiotempo_tilde_new (t_floatarg f)
+{
+  t_aubiotempo_tilde *x = 
+    (t_aubiotempo_tilde *)pd_new(aubiotempo_tilde_class);
+
+  x->threshold = (f < 1e-5) ? 0.1 : (f > 10.) ? 10. : f;
+  x->silence = -70.;
+  /* should get from block~ size */
+  x->bufsize   = 1024;
+  x->hopsize   = x->bufsize / 2;
+
+  x->t = new_aubio_tempo ("complex", x->bufsize, x->hopsize, 1,
+          (uint_t) sys_getsr ());
+  aubio_tempo_set_silence(x->t,x->silence);
+  aubio_tempo_set_threshold(x->t,x->threshold);
+  x->output = (fvec_t *)new_fvec(2,1);
+  x->vec = (fvec_t *)new_fvec(x->hopsize,1);
+
+  floatinlet_new (&x->x_obj, &x->threshold);
+  x->tempobang = outlet_new (&x->x_obj, &s_bang);
+  x->onsetbang = outlet_new (&x->x_obj, &s_bang);
+  post(aubiotempo_version);
+  return (void *)x;
+}
+
+static void *aubiotempo_tilde_del(t_aubiotempo_tilde *x)
+{
+  if(x->t)      del_aubio_tempo(x->t);
+  if(x->output) del_fvec(x->output);
+  if(x->vec)    del_fvec(x->vec);
+  return 0;
+}
+
+void aubiotempo_tilde_setup (void)
+{
+  aubiotempo_tilde_class = class_new (gensym ("aubiotempo~"),
+      (t_newmethod)aubiotempo_tilde_new,
+      (t_method)aubiotempo_tilde_del,
+      sizeof (t_aubiotempo_tilde),
+      CLASS_DEFAULT, A_DEFFLOAT, 0);
+  class_addmethod(aubiotempo_tilde_class, 
+      (t_method)aubiotempo_tilde_dsp, 
+      gensym("dsp"), 0);
+  class_addmethod(aubiotempo_tilde_class, 
+      (t_method)aubiotempo_tilde_debug,
+      gensym("debug"), 0);
+  CLASS_MAINSIGNALIN(aubiotempo_tilde_class, 
+      t_aubiotempo_tilde, threshold);
+}
+
diff --git a/aubiotss~.c b/aubiotss~.c
new file mode 100644 (file)
index 0000000..b3e8800
--- /dev/null
@@ -0,0 +1,132 @@
+/**
+ *
+ * a puredata wrapper for aubio tss detection functions 
+ *
+ * Thanks to Johannes M Zmolnig for writing the excellent HOWTO:
+ *       http://iem.kug.ac.at/pd/externals-HOWTO/  
+ *
+ * */
+
+#include <m_pd.h>
+#define AUBIO_UNSTABLE 1
+#include <aubio/aubio.h>
+
+char aubiotss_version[] = "aubiotss~ version 0.1";
+
+static t_class *aubiotss_tilde_class;
+
+void aubiotss_tilde_setup (void);
+
+typedef struct _aubiotss_tilde 
+{
+       t_object x_obj;
+       t_float thres;  
+       t_int pos; /*frames%dspblocksize*/
+       t_int bufsize;
+       t_int hopsize;
+       aubio_pvoc_t * pv;
+       aubio_pvoc_t * pvt;
+       aubio_pvoc_t * pvs;
+       aubio_tss_t * tss;
+       fvec_t *vec;
+       cvec_t *fftgrain;
+       cvec_t *cstead;
+       cvec_t *ctrans;
+       fvec_t *trans;
+       fvec_t *stead;
+} t_aubiotss_tilde;
+
+static t_int *aubiotss_tilde_perform(t_int *w) 
+{
+       t_aubiotss_tilde *x = (t_aubiotss_tilde *)(w[1]);
+       t_sample *in          = (t_sample *)(w[2]);
+       t_sample *outtrans    = (t_sample *)(w[3]);
+       t_sample *outstead    = (t_sample *)(w[4]);
+       int n                 = (int)(w[5]);
+       int j;
+       for (j=0;j<n;j++) {
+               /* write input to datanew */
+               fvec_write_sample(x->vec, in[j], 0, x->pos);
+               /*time for fft*/
+               if (x->pos == x->hopsize-1) {         
+                       /* block loop */
+                       /* test for silence */
+                       //if (!aubio_silence_detection(x->vec, x->threshold2))
+                       aubio_pvoc_do  (x->pv,  x->vec, x->fftgrain);
+                       aubio_tss_set_threshold ( x->tss, x->thres);
+                       aubio_tss_do   (x->tss, x->fftgrain, x->ctrans, x->cstead);
+                       aubio_pvoc_rdo (x->pvt, x->ctrans, x->trans);
+                       aubio_pvoc_rdo (x->pvs, x->cstead, x->stead);
+                       //}
+                       /* end of block loop */
+                       x->pos = -1; /* so it will be zero next j loop */
+               }
+               x->pos++;
+               *outtrans++ = x->trans->data[0][x->pos];
+               *outstead++ = x->stead->data[0][x->pos];
+       }
+       return (w+6);
+}
+
+static void aubiotss_tilde_dsp(t_aubiotss_tilde *x, t_signal **sp)
+{
+       dsp_add(aubiotss_tilde_perform, 5, x, 
+                       sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
+}
+
+static void aubiotss_tilde_debug(t_aubiotss_tilde *x)
+{
+       post("aubiotss~ bufsize:\t%d", x->bufsize);
+       post("aubiotss~ hopsize:\t%d", x->hopsize);
+       post("aubiotss~ threshold:\t%f", x->thres);
+       post("aubiotss~ audio in:\t%f", x->vec->data[0][0]);
+       post("aubiotss~ audio out:\t%f", x->stead->data[0][0]);
+}
+
+static void *aubiotss_tilde_new (t_floatarg f)
+       //, t_floatarg bufsize)
+{
+       t_aubiotss_tilde *x = 
+               (t_aubiotss_tilde *)pd_new(aubiotss_tilde_class);
+
+       x->thres    = (f < 1e-5) ? 0.01 : (f > 1.) ? 1. : f;
+       x->bufsize  = 1024; //(bufsize < 64) ? 1024: (bufsize > 16385) ? 16385: bufsize;
+       x->hopsize  = x->bufsize / 4;
+
+       x->vec = (fvec_t *)new_fvec(x->hopsize,1);
+
+       x->fftgrain  = (cvec_t *)new_cvec(x->bufsize,1);
+       x->ctrans = (cvec_t *)new_cvec(x->bufsize,1);
+       x->cstead = (cvec_t *)new_cvec(x->bufsize,1);
+
+       x->trans = (fvec_t *)new_fvec(x->hopsize,1);
+       x->stead = (fvec_t *)new_fvec(x->hopsize,1);
+
+       x->pv  = (aubio_pvoc_t *)new_aubio_pvoc(x->bufsize, x->hopsize, 1);
+       x->pvt = (aubio_pvoc_t *)new_aubio_pvoc(x->bufsize, x->hopsize, 1);
+       x->pvs = (aubio_pvoc_t *)new_aubio_pvoc(x->bufsize, x->hopsize, 1);
+
+       x->tss = (aubio_tss_t *)new_aubio_tss(x->bufsize, x->hopsize, 1);
+
+       floatinlet_new (&x->x_obj, &x->thres);
+       outlet_new(&x->x_obj, gensym("signal"));
+       outlet_new(&x->x_obj, gensym("signal"));
+       post(aubiotss_version);
+       return (void *)x;
+}
+
+void aubiotss_tilde_setup (void)
+{
+       aubiotss_tilde_class = class_new (gensym ("aubiotss~"),
+                       (t_newmethod)aubiotss_tilde_new,
+                       0, sizeof (t_aubiotss_tilde),
+                       CLASS_DEFAULT, A_DEFFLOAT, 0);
+       class_addmethod(aubiotss_tilde_class, 
+                       (t_method)aubiotss_tilde_dsp, 
+                       gensym("dsp"), 0);
+       class_addmethod(aubiotss_tilde_class, 
+                       (t_method)aubiotss_tilde_debug,
+                       gensym("debug"), 0);
+       CLASS_MAINSIGNALIN(aubiotss_tilde_class, 
+                       t_aubiotss_tilde, thres);
+}
diff --git a/aubiozcr~.c b/aubiozcr~.c
new file mode 100644 (file)
index 0000000..43c297a
--- /dev/null
@@ -0,0 +1,91 @@
+
+/**
+ *
+ * a puredata wrapper for aubio zero crossing rate function 
+ *
+ * Thanks to Johannes M Zmolnig for writing the excellent HOWTO:
+ *       http://iem.kug.ac.at/pd/externals-HOWTO/  
+ *
+ * */
+
+#include <m_pd.h>
+#include <aubio/aubio.h>
+
+char aubiozcr_version[] = "aubiozcr~ version 0.1";
+
+static t_class *aubiozcr_tilde_class;
+
+void aubiozcr_tilde_setup (void);
+
+typedef struct _aubiozcr_tilde 
+{
+       t_object x_obj;
+       t_int pos; /*frames%dspblocksize*/
+       t_int bufsize;
+       t_float f;
+       fvec_t *vec;
+       t_outlet *zcr;
+} t_aubiozcr_tilde;
+
+static t_int *aubiozcr_tilde_perform(t_int *w) 
+{
+       t_aubiozcr_tilde *x = (t_aubiozcr_tilde *)(w[1]);
+       t_sample *in        = (t_sample *)(w[2]);
+       int n               = (int)(w[3]);
+       int j;
+       for (j=0;j<n;j++) {
+               /* write input to datanew */
+               fvec_write_sample(x->vec, in[j], 0, x->pos);
+               /*time for fft*/
+               if (x->pos == x->bufsize-1) {         
+                       /* block loop */
+                       outlet_float(x->zcr, aubio_zero_crossing_rate(x->vec));
+                       /* end of block loop */
+                       x->pos = -1; /* so it will be zero next j loop */
+               }
+               x->pos++;
+       }
+       return (w+4);
+}
+
+static void aubiozcr_tilde_dsp(t_aubiozcr_tilde *x, t_signal **sp)
+{
+       dsp_add(aubiozcr_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
+}
+
+static void aubiozcr_tilde_debug(t_aubiozcr_tilde *x)
+{
+       post("aubiozcr~ bufsize:\t%d", x->bufsize);
+       post("aubiozcr~ audio in:\t%f", x->vec->data[0][0]);
+}
+
+static void *aubiozcr_tilde_new (void)
+{
+       t_aubiozcr_tilde *x = 
+               (t_aubiozcr_tilde *)pd_new(aubiozcr_tilde_class);
+
+       x->bufsize   = 1024;
+
+       x->vec = (fvec_t *)new_fvec(x->bufsize,1);
+
+       x->zcr = outlet_new (&x->x_obj, &s_float);
+       post(aubiozcr_version);
+       return (void *)x;
+}
+
+void aubiozcr_tilde_setup (void)
+{
+       aubiozcr_tilde_class = class_new (gensym ("aubiozcr~"),
+                       (t_newmethod)aubiozcr_tilde_new,
+                       0, sizeof (t_aubiozcr_tilde),
+                       CLASS_DEFAULT, 0);
+       class_addmethod(aubiozcr_tilde_class, 
+                       (t_method)aubiozcr_tilde_dsp, 
+                       gensym("dsp"), 0);
+       class_addmethod(aubiozcr_tilde_class, 
+                       (t_method)aubiozcr_tilde_debug,
+                       gensym("debug"), 0);
+       CLASS_MAINSIGNALIN(aubiozcr_tilde_class, 
+                       t_aubiozcr_tilde, f);
+}
+
diff --git a/examples/onset-cam.pd b/examples/onset-cam.pd
new file mode 100644 (file)
index 0000000..13b3bc4
--- /dev/null
@@ -0,0 +1,13 @@
+#N canvas 331 521 567 331 10;
+#X obj 23 8 adc~;
+#X obj 24 46 aubioonset~;
+#X obj 24 81 pdp_v4l;
+#X obj 24 116 pdp_xv;
+#X text 110 10 audio input;
+#X text 111 46 onset detection;
+#X text 113 82 video camera;
+#X text 113 121 video screen;
+#X connect 0 0 1 0;
+#X connect 0 1 1 0;
+#X connect 1 0 2 0;
+#X connect 2 0 3 0;
diff --git a/help/aubioonset~-help.pd b/help/aubioonset~-help.pd
new file mode 100644 (file)
index 0000000..5c2fb9d
--- /dev/null
@@ -0,0 +1,18 @@
+#N canvas 245 501 672 291 10;
+#X obj 50 33 adc~;
+#X text 181 26 aubioonset~ takes an input signal and outputs a bang
+when an onset has been detected;
+#X text 180 64 this is somewhat similar to the bonk~ object \, except
+it should work on non-percussive attacks too.;
+#X obj 50 97 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 182 111 the creation argument and right input can be used to
+set the detection threshold. values between 0 and 10 are accepted.
+low values favorise over-detection. higher values will reduce the number
+of onset detected.;
+#X obj 50 65 aubioonset~ 0.3;
+#X floatatom 128 29 5 0 0 0 - - -;
+#X connect 0 0 5 0;
+#X connect 0 1 5 0;
+#X connect 5 0 3 0;
+#X connect 6 0 5 1;
diff --git a/help/aubiopitch~-help.pd b/help/aubiopitch~-help.pd
new file mode 100644 (file)
index 0000000..3948ce9
--- /dev/null
@@ -0,0 +1,18 @@
+#N canvas 254 165 450 425 10;
+#X floatatom 126 230 5 0 0 0 - - -;
+#X obj 125 168 osc~ 440;
+#X obj 128 111 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 8100 1;
+#X obj 125 131 mtof;
+#X floatatom 125 151 5 0 0 0 - - -;
+#X obj 141 200 aubiopitch~;
+#X obj 103 274 dac~;
+#X obj 126 250 osc~;
+#X connect 0 0 7 0;
+#X connect 1 0 5 0;
+#X connect 1 0 6 0;
+#X connect 2 0 3 0;
+#X connect 3 0 4 0;
+#X connect 4 0 1 0;
+#X connect 5 0 0 0;
+#X connect 7 0 6 1;
diff --git a/help/aubioquiet~-help.pd b/help/aubioquiet~-help.pd
new file mode 100644 (file)
index 0000000..9837043
--- /dev/null
@@ -0,0 +1,20 @@
+#N canvas 225 643 515 246 10;
+#X obj 20 28 adc~;
+#X obj 19 192 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 119 192 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 19 156 aubioquiet~ -90;
+#X text 140 193 noisy;
+#X text 38 192 quiet;
+#X text 60 26 aubioquiet~ outputs bangs: - on its left input when a
+change to silence is detected - on its right output when a change to
+loudness is detected;
+#X text 59 82 object creation argument and right input can be used
+to set the noise threshold \, in dB. default value is -90;
+#X text 182 138 this object was written as an exercise and test. note
+that it could also easily be rewritten as a patch.;
+#X connect 0 0 3 0;
+#X connect 0 1 3 0;
+#X connect 3 0 1 0;
+#X connect 3 1 2 0;
diff --git a/help/aubiotempo~-help.pd b/help/aubiotempo~-help.pd
new file mode 100644 (file)
index 0000000..500c90a
--- /dev/null
@@ -0,0 +1,16 @@
+#N canvas 245 501 672 291 10;
+#X obj 50 33 adc~;
+#X obj 50 97 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X floatatom 128 29 5 0 0 0 - - -;
+#X text 180 71 the creation argument and right input can be used to
+set the detection threshold of the onset detection function. see the
+documentation for aubioonset~;
+#X obj 50 65 aubiotempo~ 0.3;
+#X text 181 26 aubiotempo~ takes an input signal and outputs a bang
+when at each detected beat location.;
+#X text 416 45;
+#X connect 0 0 4 0;
+#X connect 0 1 4 0;
+#X connect 2 0 4 1;
+#X connect 4 0 1 0;
diff --git a/help/aubiotss~-help.pd b/help/aubiotss~-help.pd
new file mode 100644 (file)
index 0000000..ebf1443
--- /dev/null
@@ -0,0 +1,70 @@
+#N canvas 332 424 550 443 10;
+#X msg 173 64 debug;
+#X obj 138 11 adc~;
+#X obj 183 421 dac~;
+#X floatatom 244 74 5 0 0 0 - - -;
+#X obj 221 12 hsl 256 15 0 256 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 25200 1;
+#X obj 167 182 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
+1;
+#X obj 267 185 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
+1;
+#X text 265 161 play steady states components;
+#X text 8 160 play transients;
+#X floatatom 10 226 5 0 0 0 - - -;
+#X obj 13 182 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 11700 1;
+#X floatatom 285 225 5 0 0 0 - - -;
+#X obj 301 186 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 4100 1;
+#X text 236 -1 separation threshold;
+#X obj 144 96 aubiotss~ 0.015;
+#X text 265 99 transient and steady state separation;
+#X obj 244 239 *~ 1;
+#X obj 244 267 *~ 1;
+#X obj 144 240 *~ 1;
+#X obj 144 265 *~ 1;
+#X obj 285 204 / 68;
+#X obj 10 203 / 68;
+#X obj 244 51 / 256;
+#X obj 172 350 *~;
+#X obj 222 334 *~;
+#X obj 199 219 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X text 185 204 stereo;
+#X obj 311 139 aubiotss~ 0.015;
+#X obj 299 68 * -1;
+#X obj 353 63 + 1;
+#X floatatom 412 63 5 0 0 0 - - -;
+#X connect 0 0 14 0;
+#X connect 1 0 14 0;
+#X connect 1 0 27 0;
+#X connect 1 1 14 0;
+#X connect 1 1 27 0;
+#X connect 3 0 14 1;
+#X connect 3 0 28 0;
+#X connect 4 0 22 0;
+#X connect 5 0 19 1;
+#X connect 6 0 17 1;
+#X connect 9 0 18 1;
+#X connect 10 0 21 0;
+#X connect 11 0 16 1;
+#X connect 12 0 20 0;
+#X connect 14 0 18 0;
+#X connect 16 0 17 0;
+#X connect 17 0 2 1;
+#X connect 17 0 24 0;
+#X connect 18 0 19 0;
+#X connect 19 0 2 0;
+#X connect 19 0 23 0;
+#X connect 20 0 11 0;
+#X connect 21 0 9 0;
+#X connect 22 0 3 0;
+#X connect 23 0 2 1;
+#X connect 24 0 2 0;
+#X connect 25 0 23 0;
+#X connect 25 0 24 1;
+#X connect 27 1 16 0;
+#X connect 28 0 29 0;
+#X connect 29 0 30 0;
+#X connect 30 0 27 1;
diff --git a/help/aubiozcr~-help.pd b/help/aubiozcr~-help.pd
new file mode 100644 (file)
index 0000000..70f4118
--- /dev/null
@@ -0,0 +1,11 @@
+#N canvas 0 22 580 309 10;
+#X obj 37 71 aubiozcr~;
+#X obj 37 43 osc~ 441;
+#X floatatom 36 98 5 0 0 0 - - -;
+#X text 153 36 aubiozcr~ computes the zero-crossing rate;
+#X text 152 95 For a sine tone at 441Hz sampled at 44100Hz signal \,
+the ZCR is 0.02.;
+#X text 153 59 This value represents the number of times where the
+signal changes sign.;
+#X connect 0 0 2 0;
+#X connect 1 0 0 0;