Changeset cf83555 for plugins/puredata/aubioonset~.c
- Timestamp:
- Nov 6, 2005, 1:10:41 PM (19 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:
- 091b171
- Parents:
- f41f5c4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/puredata/aubioonset~.c
rf41f5c4 rcf83555 21 21 t_object x_obj; 22 22 t_float threshold; 23 t_float threshold2; 24 t_int pos; /*frames%dspblocksize*/ 23 25 t_int bufsize; 24 26 t_int hopsize; 25 27 aubio_onsetdetection_t *o; 26 28 aubio_pvoc_t * pv; 29 aubio_pickpeak_t * parms; 27 30 fvec_t *vec; 28 31 fvec_t *onset; 29 32 cvec_t *fftgrain; 30 t_outlet *onset val;33 t_outlet *onsetbang; 31 34 } t_aubioonset_tilde; 32 35 … … 36 39 t_sample *in = (t_sample *)(w[2]); 37 40 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 } 45 63 return (w+4); 46 64 } … … 58 76 post("aubioonset~ audio in:\t%f", x->vec->data[0][0]); 59 77 post("aubioonset~ onset:\t%f", x->onset->data[0][0]); 60 outlet_float(x->onsetval, x->threshold);61 78 } 62 79 … … 67 84 68 85 x->threshold = (f < 1e-5) ? 0.1 : (f > 10.) ? 10. : f; 69 /* should get from block~ size */86 x->threshold2 = -70.; 70 87 x->bufsize = 1024; 71 88 x->hopsize = x->bufsize / 2; … … 73 90 x->o = new_aubio_onsetdetection(aubio_onset_complex, x->bufsize, 1); 74 91 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); 77 94 x->onset = (fvec_t *)new_fvec(1,1); 95 x->parms = new_aubio_peakpicker(x->threshold); 78 96 79 97 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); 81 100 return (void *)x; 82 101 } … … 98 117 CLASS_MAINSIGNALIN(aubioonset_tilde_class, 99 118 t_aubioonset_tilde, threshold); 100 post("aubioonset~ v0.1 for puredata");101 119 } 102 120
Note: See TracChangeset
for help on using the changeset viewer.