Changeset d4c5de7 for examples/aubioonset.c
- Timestamp:
- Oct 16, 2009, 11:03:08 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:
- 6107f4c
- Parents:
- 2828382
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/aubioonset.c
r2828382 rd4c5de7 20 20 21 21 unsigned int pos = 0; /*frames%dspblocksize*/ 22 uint_t usepitch = 0;23 22 24 int aubio_process(smpl_t **input, smpl_t **output, int nframes); 25 int aubio_process(smpl_t **input, smpl_t **output, int nframes) { 23 aubio_onset_t *o; 24 fvec_t *onset; 25 26 static int aubio_process(smpl_t **input, smpl_t **output, int nframes) { 26 27 unsigned int i; /*channels*/ 27 28 unsigned int j; /*frames*/ … … 38 39 if (pos == overlap_size-1) { 39 40 /* block loop */ 40 aubio_pvoc_do (pv,ibuf, fftgrain); 41 aubio_onsetdetection_do (o,fftgrain, onset); 42 isonset = aubio_peakpicker_do(parms, onset); 43 if (isonset) { 44 /* test for silence */ 45 if (aubio_silence_detection(ibuf, silence)==1) 46 isonset=0.; 47 else 48 for (pos = 0; pos < overlap_size; pos++){ 49 obuf->data[0][pos] = woodblock->data[0][pos]; 50 } 41 aubio_onset_do (o, ibuf, onset); 42 if (fvec_read_sample(onset, 0, 0)) { 43 for (pos = 0; pos < overlap_size; pos++){ 44 obuf->data[0][pos] = woodblock->data[0][pos]; 45 } 51 46 } else { 52 for (pos = 0; pos < overlap_size; pos++) 47 for (pos = 0; pos < overlap_size; pos++) { 53 48 obuf->data[0][pos] = 0.; 49 } 54 50 } 55 51 /* end of block loop */ … … 61 57 } 62 58 63 void process_print (void); 64 void process_print (void) { 59 static void process_print (void) { 65 60 /* output times in seconds, taking back some 66 61 * delay to ensure the label is _before_ the 67 62 * actual onset */ 68 if (isonset && output_filename == NULL) { 63 if (!verbose && usejack) return; 64 smpl_t onset_found = fvec_read_sample(onset, 0, 0); 65 if (onset_found) { 69 66 if(frames >= 4) { 70 outmsg("%f\n",(frames - frames_delay + isonset)*overlap_size/(float)samplerate); 67 outmsg("%f\n",(frames - frames_delay + onset_found) 68 *overlap_size/(float)samplerate); 71 69 } else if (frames < frames_delay) { 72 70 outmsg("%f\n",0.); … … 78 76 frames_delay = 3; 79 77 examples_common_init(argc,argv); 78 79 o = new_aubio_onset (onset_mode, buffer_size, overlap_size, channels, 80 samplerate); 81 onset = new_fvec (1, channels); 82 80 83 examples_common_process(aubio_process,process_print); 84 85 del_aubio_onset (o); 86 del_fvec (onset); 87 81 88 examples_common_del(); 82 89 debug("End of program.\n");
Note: See TracChangeset
for help on using the changeset viewer.