Ignore:
Timestamp:
Nov 6, 2005, 1:10:41 PM (19 years ago)
Author:
Paul Brossier <piem@altern.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:
091b171
Parents:
f41f5c4
Message:

rewrite of the puredata external
rewrite of the puredata external

File:
1 edited

Legend:

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

    rf41f5c4 rcf83555  
    2121        t_object x_obj;
    2222        t_float threshold;     
     23        t_float threshold2;     
     24        t_int pos; /*frames%dspblocksize*/
    2325        t_int bufsize;
    2426        t_int hopsize;
    2527        aubio_onsetdetection_t *o;
    2628        aubio_pvoc_t * pv;
     29        aubio_pickpeak_t * parms;
    2730        fvec_t *vec;
    2831        fvec_t *onset;
    2932        cvec_t *fftgrain;
    30         t_outlet *onsetval;
     33        t_outlet *onsetbang;
    3134} t_aubioonset_tilde;
    3235
     
    3639        t_sample *in          = (t_sample *)(w[2]);
    3740        int n                 = (int)(w[3]);
    38         //t_sample f = (x->threshold < 0.) ? 0.2 :
    39         //      (x->threshold > 10.) ? 10. : x->threshold;
    40         while (n--) //*(x->vec->data[0])++ = (*in++);
    41                 x->vec->data[0][n] = in[n];
    42         aubio_pvoc_do (x->pv, x->vec, x->fftgrain);
    43         aubio_onsetdetection(x->o, x->fftgrain, x->onset);
    44         outlet_float(x->onsetval, x->onset->data[0][0]);
     41        int j,isonset;
     42        for (j=0;j<n;j++) {
     43                /* write input to datanew */
     44                fvec_write_sample(x->vec, in[j], 0, x->pos);
     45                /*time for fft*/
     46                if (x->pos == x->hopsize-1) {         
     47                        /* block loop */
     48                        aubio_pvoc_do (x->pv,x->vec, x->fftgrain);
     49                        aubio_onsetdetection(x->o,x->fftgrain, x->onset);
     50                        isonset = aubio_peakpick_pimrt(x->onset,x->parms);
     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);
     57                        }
     58                        /* end of block loop */
     59                        x->pos = -1; /* so it will be zero next j loop */
     60                }
     61                x->pos++;
     62        }
    4563        return (w+4);
    4664}
     
    5876        post("aubioonset~ audio in:\t%f", x->vec->data[0][0]);
    5977        post("aubioonset~ onset:\t%f", x->onset->data[0][0]);
    60         outlet_float(x->onsetval, x->threshold);
    6178}
    6279
     
    6784
    6885        x->threshold = (f < 1e-5) ? 0.1 : (f > 10.) ? 10. : f;
    69         /* should get from block~ size */
     86        x->threshold2 = -70.;
    7087        x->bufsize   = 1024;
    7188        x->hopsize   = x->bufsize / 2;
     
    7390        x->o = new_aubio_onsetdetection(aubio_onset_complex, x->bufsize, 1);
    7491        x->vec = (fvec_t *)new_fvec(x->hopsize,1);
    75         x->pv = new_aubio_pvoc(x->bufsize, x->hopsize, 1);
    76         x->fftgrain  = new_cvec(x->bufsize,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);
    7794        x->onset = (fvec_t *)new_fvec(1,1);
     95        x->parms = new_aubio_peakpicker(x->threshold);
    7896
    7997        floatinlet_new (&x->x_obj, &x->threshold);
    80         x->onsetval = outlet_new (&x->x_obj, &s_float);
     98        x->onsetbang = outlet_new (&x->x_obj, &s_bang);
     99        post(aubioonset_version);
    81100        return (void *)x;
    82101}
     
    98117        CLASS_MAINSIGNALIN(aubioonset_tilde_class,
    99118                        t_aubioonset_tilde, threshold);
    100         post("aubioonset~ v0.1 for puredata");
    101119}
    102120
Note: See TracChangeset for help on using the changeset viewer.