Changeset cf83555


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

Location:
plugins/puredata
Files:
7 added
3 edited

Legend:

Unmodified
Added
Removed
  • plugins/puredata/Makefile.am

    rf41f5c4 rcf83555  
    1212
    1313# Automake won't accept something ending in ".pd_linux" as a library
    14 pdinstall_PROGRAMS = aubioonset~.pd_linux
     14pdinstall_PROGRAMS = aubio.pd_linux
    1515
    16 aubioonset__pd_linux_SOURCES = \
    17         aubioonset~.c
     16aubio_pd_linux_SOURCES = \
     17        aubio_setup.c \
     18        aubioonset~.c \
     19        aubiotempo~.c \
     20        aubiotss~.c \
     21        aubioquiet~.c
    1822
    1923pdincludedir = $(pddir)/src
  • 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
  • plugins/puredata/help-aubioonset~.pd

    rf41f5c4 rcf83555  
    1 #N canvas 27 302 238 292 10;
     1#N canvas 245 501 672 291 10;
    22#X obj 50 33 adc~;
    3 #X obj 59 137 vu 15 120 empty empty -1 -8 0 8 -66577 -1 1 0;
    4 #X obj 58 109 scale 0 2000 -100 12;
    5 #N canvas 270 196 450 300 aubioonset 1;
    6 #X text 71 130 set blocksize to 1024 with 50% overlap;
    7 #X obj 56 90 outlet;
    8 #X obj 57 41 inlet~;
    9 #X obj 55 64 aubioonset~ 0.1;
    10 #X text 29 141 ugly. not required \, but should give better results
    11 ;
    12 #X obj 200 95 block~ 1024 2 1;
    13 #X text 129 22 aubioonset~ takes an input signal and outputs the value
    14 of the value of the onset detection function;
    15 #X connect 2 0 3 0;
    16 #X connect 3 0 1 0;
    17 #X restore 58 78 pd aubioonset;
    18 #X obj 108 141 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -6 0 10
    19 -262144 -1 -1 1310.81 256;
    20 #X connect 0 0 3 0;
    21 #X connect 0 1 3 0;
    22 #X connect 2 0 1 0;
    23 #X connect 3 0 2 0;
    24 #X connect 3 0 4 0;
     3#X text 181 26 aubioonset~ takes an input signal and outputs a bang
     4when an onset has been detected;
     5#X text 180 64 this is somewhat similar to the bonk~ object \, except
     6it should work on non-percussive attacks too.;
     7#X obj 50 97 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
     8-1;
     9#X text 182 111 the creation argument and right input can be used to
     10set the detection threshold. values between 0 and 10 are accepted.
     11low values favorise over-detection. higher values will reduce the number
     12of onset detected.;
     13#X obj 50 65 aubioonset~ 0.3;
     14#X floatatom 128 29 5 0 0 0 - - -;
     15#X connect 0 0 5 0;
     16#X connect 0 1 5 0;
     17#X connect 5 0 3 0;
     18#X connect 6 0 5 1;
Note: See TracChangeset for help on using the changeset viewer.