*.c: move to src/
authorPaul Brossier <piem@piem.org>
Fri, 20 Dec 2013 04:27:37 +0000 (23:27 -0500)
committerPaul Brossier <piem@piem.org>
Fri, 20 Dec 2013 04:27:37 +0000 (23:27 -0500)
15 files changed:
aubio_setup.c [deleted file]
aubioonset~.c [deleted file]
aubiopitch~.c [deleted file]
aubioquiet~.c [deleted file]
aubiotempo~.c [deleted file]
aubiotss~.c [deleted file]
aubiozcr~.c [deleted file]
src/aubio_setup.c [new file with mode: 0644]
src/aubioonset~.c [new file with mode: 0644]
src/aubiopitch~.c [new file with mode: 0644]
src/aubioquiet~.c [new file with mode: 0644]
src/aubiotempo~.c [new file with mode: 0644]
src/aubiotss~.c [new file with mode: 0644]
src/aubiozcr~.c [new file with mode: 0644]
wscript

diff --git a/aubio_setup.c b/aubio_setup.c
deleted file mode 100644 (file)
index f56be15..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-
-#include <m_pd.h>
-
-char aubio_version[] = "aubio external for pd, version " PACKAGE_VERSION;
-
-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
deleted file mode 100644 (file)
index f5efd03..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- *
- * 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 " PACKAGE_VERSION;
-
-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_set_sample (x->in, in[j], 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_get_sample (x->out, 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]);
-  post ("aubioonset~ onset:\t%f", x->out->data[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, (uint_t) sys_getsr ());
-  x->in = (fvec_t *) new_fvec (x->hopsize);
-  x->out = (fvec_t *) new_fvec (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
deleted file mode 100644 (file)
index d591aa2..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- *
- * 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 " PACKAGE_VERSION;
-
-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_set_sample(x->vec, in[j], 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]);
-      /* 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]);
-}
-
-//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;
-
-  x->o = new_aubio_pitch(s->s_name, x->bufsize,
-      x->hopsize, (uint_t)sys_getsr() );
-  aubio_pitch_set_tolerance (x->o, 0.7);
-  x->vec = (fvec_t *)new_fvec(x->hopsize);
-  x->pitchvec = (fvec_t *)new_fvec(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
deleted file mode 100644 (file)
index d477cc2..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- *
- * 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 " PACKAGE_VERSION;
-
-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_set_sample(x->vec, in[j], 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]);
-}
-
-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);
-       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
deleted file mode 100644 (file)
index 64e58af..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- *
- * 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 " PACKAGE_VERSION;
-
-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_set_sample(x->vec, in[j], 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]) {
-        outlet_bang(x->tempobang);
-      }
-      if (x->output->data[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]);
-}
-
-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 ("specdiff", x->bufsize, x->hopsize,
-          (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);
-  x->vec = (fvec_t *)new_fvec(x->hopsize);
-
-  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
deleted file mode 100644 (file)
index 71dd53a..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- *
- * 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 " PACKAGE_VERSION;
-
-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_set_sample(x->vec, in[j], 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[x->pos];
-    *outstead++ = x->stead->data[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]);
-  post("aubiotss~ audio out:\t%f", x->stead->data[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);
-
-  x->fftgrain  = (cvec_t *)new_cvec(x->bufsize);
-  x->ctrans = (cvec_t *)new_cvec(x->bufsize);
-  x->cstead = (cvec_t *)new_cvec(x->bufsize);
-
-  x->trans = (fvec_t *)new_fvec(x->hopsize);
-  x->stead = (fvec_t *)new_fvec(x->hopsize);
-
-  x->pv  = (aubio_pvoc_t *)new_aubio_pvoc(x->bufsize, x->hopsize);
-  x->pvt = (aubio_pvoc_t *)new_aubio_pvoc(x->bufsize, x->hopsize);
-  x->pvs = (aubio_pvoc_t *)new_aubio_pvoc(x->bufsize, x->hopsize);
-
-  x->tss = (aubio_tss_t *)new_aubio_tss(x->bufsize, x->hopsize);
-
-    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
deleted file mode 100644 (file)
index 874a266..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-
-/**
- *
- * 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 " PACKAGE_VERSION;
-
-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_set_sample(x->vec, in[j], 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]);
-}
-
-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);
-
-  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/src/aubio_setup.c b/src/aubio_setup.c
new file mode 100644 (file)
index 0000000..f56be15
--- /dev/null
@@ -0,0 +1,39 @@
+
+#include <m_pd.h>
+
+char aubio_version[] = "aubio external for pd, version " PACKAGE_VERSION;
+
+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/src/aubioonset~.c b/src/aubioonset~.c
new file mode 100644 (file)
index 0000000..f5efd03
--- /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 " PACKAGE_VERSION;
+
+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_set_sample (x->in, in[j], 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_get_sample (x->out, 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]);
+  post ("aubioonset~ onset:\t%f", x->out->data[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, (uint_t) sys_getsr ());
+  x->in = (fvec_t *) new_fvec (x->hopsize);
+  x->out = (fvec_t *) new_fvec (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/src/aubiopitch~.c b/src/aubiopitch~.c
new file mode 100644 (file)
index 0000000..d591aa2
--- /dev/null
@@ -0,0 +1,114 @@
+/**
+ *
+ * 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 " PACKAGE_VERSION;
+
+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_set_sample(x->vec, in[j], 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]);
+      /* 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]);
+}
+
+//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;
+
+  x->o = new_aubio_pitch(s->s_name, x->bufsize,
+      x->hopsize, (uint_t)sys_getsr() );
+  aubio_pitch_set_tolerance (x->o, 0.7);
+  x->vec = (fvec_t *)new_fvec(x->hopsize);
+  x->pitchvec = (fvec_t *)new_fvec(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/src/aubioquiet~.c b/src/aubioquiet~.c
new file mode 100644 (file)
index 0000000..d477cc2
--- /dev/null
@@ -0,0 +1,116 @@
+/**
+ *
+ * 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 " PACKAGE_VERSION;
+
+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_set_sample(x->vec, in[j], 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]);
+}
+
+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);
+       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/src/aubiotempo~.c b/src/aubiotempo~.c
new file mode 100644 (file)
index 0000000..64e58af
--- /dev/null
@@ -0,0 +1,122 @@
+/**
+ *
+ * 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 " PACKAGE_VERSION;
+
+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_set_sample(x->vec, in[j], 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]) {
+        outlet_bang(x->tempobang);
+      }
+      if (x->output->data[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]);
+}
+
+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 ("specdiff", x->bufsize, x->hopsize,
+          (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);
+  x->vec = (fvec_t *)new_fvec(x->hopsize);
+
+  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/src/aubiotss~.c b/src/aubiotss~.c
new file mode 100644 (file)
index 0000000..71dd53a
--- /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 " PACKAGE_VERSION;
+
+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_set_sample(x->vec, in[j], 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[x->pos];
+    *outstead++ = x->stead->data[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]);
+  post("aubiotss~ audio out:\t%f", x->stead->data[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);
+
+  x->fftgrain  = (cvec_t *)new_cvec(x->bufsize);
+  x->ctrans = (cvec_t *)new_cvec(x->bufsize);
+  x->cstead = (cvec_t *)new_cvec(x->bufsize);
+
+  x->trans = (fvec_t *)new_fvec(x->hopsize);
+  x->stead = (fvec_t *)new_fvec(x->hopsize);
+
+  x->pv  = (aubio_pvoc_t *)new_aubio_pvoc(x->bufsize, x->hopsize);
+  x->pvt = (aubio_pvoc_t *)new_aubio_pvoc(x->bufsize, x->hopsize);
+  x->pvs = (aubio_pvoc_t *)new_aubio_pvoc(x->bufsize, x->hopsize);
+
+  x->tss = (aubio_tss_t *)new_aubio_tss(x->bufsize, x->hopsize);
+
+    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/src/aubiozcr~.c b/src/aubiozcr~.c
new file mode 100644 (file)
index 0000000..874a266
--- /dev/null
@@ -0,0 +1,90 @@
+
+/**
+ *
+ * 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 " PACKAGE_VERSION;
+
+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_set_sample(x->vec, in[j], 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]);
+}
+
+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);
+
+  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/wscript b/wscript
index 928218b..f53cf27 100644 (file)
--- a/wscript
+++ b/wscript
@@ -48,7 +48,7 @@ def configure(ctx):
 def build(bld):
 
     bld(features = 'c cshlib',
-        source = bld.path.ant_glob('*.c'),
+        source = bld.path.ant_glob('src/*.c'),
         uselib = ['AUBIO'],
         target = 'aubio',
         defines = ['PD', 'PACKAGE_VERSION=\"'+repr(VERSION)+"\""],