Ignore:
Timestamp:
Oct 16, 2009, 9:53:17 PM (15 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
68b8233
Parents:
67d0a8b
Message:

plugins/puredata/aubioonset~.c: use onset driver

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/puredata/aubioonset~.c

    r67d0a8b r970bced  
    1111#include <aubio.h>
    1212
    13 char aubioonset_version[] = "aubioonset~ version 0.2";
     13char aubioonset_version[] = "aubioonset~ version 0.3";
    1414
    1515static t_class *aubioonset_tilde_class;
     
    2121        t_object x_obj;
    2222        t_float threshold;     
    23         t_float threshold2;     
    2423        t_int pos; /*frames%dspblocksize*/
    2524        t_int bufsize;
    2625        t_int hopsize;
    27         aubio_onsetdetection_t *o;
    28         aubio_pvoc_t * pv;
    29         aubio_peakpicker_t * parms;
    30         fvec_t *vec;
    31         fvec_t *onset;
    32         cvec_t *fftgrain;
     26        aubio_onset_t *o;
     27        fvec_t *in;
     28        fvec_t *out;
    3329        t_outlet *onsetbang;
    3430} t_aubioonset_tilde;
     
    3935        t_sample *in          = (t_sample *)(w[2]);
    4036        int n                 = (int)(w[3]);
    41         int j,isonset;
     37        int j;
    4238        for (j=0;j<n;j++) {
    4339                /* write input to datanew */
    44                 fvec_write_sample(x->vec, in[j], 0, x->pos);
    45                 /*time for fft*/
     40                fvec_write_sample(x->in, in[j], 0, x->pos);
     41                /*time to do something */
    4642                if (x->pos == x->hopsize-1) {         
    4743                        /* block loop */
    48                         aubio_pvoc_do (x->pv,x->vec, x->fftgrain);
    49                         aubio_onsetdetection_do (x->o,x->fftgrain, x->onset);
    50                         isonset = aubio_peakpicker_do (x->parms, x->onset);
    51                         if (isonset) {
    52                                 /* test for silence */
    53                                 if (aubio_silence_detection(x->vec, x->threshold2)==1)
    54                                         isonset=0;
    55                                 else
    56                                         outlet_bang(x->onsetbang);
     44                        aubio_onset_do (x->o, x->in, x->out);
     45                        if (fvec_read_sample(x->out, 0, 0) > 0.) {
     46                outlet_bang(x->onsetbang);
    5747                        }
    5848                        /* end of block loop */
     
    7464        post("aubioonset~ hopsize:\t%d", x->hopsize);
    7565        post("aubioonset~ threshold:\t%f", x->threshold);
    76         post("aubioonset~ audio in:\t%f", x->vec->data[0][0]);
    77         post("aubioonset~ onset:\t%f", x->onset->data[0][0]);
     66        post("aubioonset~ audio in:\t%f", x->in->data[0][0]);
     67        post("aubioonset~ onset:\t%f", x->out->data[0][0]);
    7868}
    7969
     
    8474
    8575        x->threshold = (f < 1e-5) ? 0.1 : (f > 10.) ? 10. : f;
    86         x->threshold2 = -70.;
    8776        x->bufsize   = 1024;
    8877        x->hopsize   = x->bufsize / 2;
    8978
    90         x->o = new_aubio_onsetdetection("complex", x->bufsize, 1);
    91         x->vec = (fvec_t *)new_fvec(x->hopsize,1);
    92         x->pv = (aubio_pvoc_t *)new_aubio_pvoc(x->bufsize, x->hopsize, 1);
    93         x->fftgrain  = (cvec_t *)new_cvec(x->bufsize,1);
    94         x->onset = (fvec_t *)new_fvec(1,1);
    95         x->parms = new_aubio_peakpicker(x->threshold);
     79        x->o = new_aubio_onset ("complex",
     80            x->bufsize, x->hopsize, 1, (uint_t)sys_getsr());
     81        x->in = (fvec_t *)new_fvec(x->hopsize,1);
     82        x->out = (fvec_t *)new_fvec(1,1);
    9683
    9784        floatinlet_new (&x->x_obj, &x->threshold);
Note: See TracChangeset for help on using the changeset viewer.