Changeset 970bced for plugins/puredata
- Timestamp:
- Oct 16, 2009, 9:53:17 PM (15 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/puredata/aubioonset~.c
r67d0a8b r970bced 11 11 #include <aubio.h> 12 12 13 char aubioonset_version[] = "aubioonset~ version 0. 2";13 char aubioonset_version[] = "aubioonset~ version 0.3"; 14 14 15 15 static t_class *aubioonset_tilde_class; … … 21 21 t_object x_obj; 22 22 t_float threshold; 23 t_float threshold2;24 23 t_int pos; /*frames%dspblocksize*/ 25 24 t_int bufsize; 26 25 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; 33 29 t_outlet *onsetbang; 34 30 } t_aubioonset_tilde; … … 39 35 t_sample *in = (t_sample *)(w[2]); 40 36 int n = (int)(w[3]); 41 int j ,isonset;37 int j; 42 38 for (j=0;j<n;j++) { 43 39 /* 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 */ 46 42 if (x->pos == x->hopsize-1) { 47 43 /* 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); 57 47 } 58 48 /* end of block loop */ … … 74 64 post("aubioonset~ hopsize:\t%d", x->hopsize); 75 65 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->o nset->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]); 78 68 } 79 69 … … 84 74 85 75 x->threshold = (f < 1e-5) ? 0.1 : (f > 10.) ? 10. : f; 86 x->threshold2 = -70.;87 76 x->bufsize = 1024; 88 77 x->hopsize = x->bufsize / 2; 89 78 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); 96 83 97 84 floatinlet_new (&x->x_obj, &x->threshold);
Note: See TracChangeset
for help on using the changeset viewer.