Changeset 466dff3 for examples/aubioonset.c
- Timestamp:
- Dec 7, 2013, 4:09:00 AM (10 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:
- 3da8187
- Parents:
- 44e94f3c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/aubioonset.c
r44e94f3c r466dff3 1 1 /* 2 Copyright (C) 2003-20 09Paul Brossier <piem@aubio.org>2 Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org> 3 3 4 4 This file is part of aubio. … … 20 20 21 21 #include "utils.h" 22 #define PROG_HAS_ONSET 22 #define PROG_HAS_ONSET 1 23 23 #include "parse_args.h" 24 25 uint_t pos = 0; /*frames%dspblocksize*/26 24 27 25 aubio_onset_t *o; … … 29 27 fvec_t *onset; 30 28 31 static int aubio_process(smpl_t **input, smpl_t **output, int nframes) { 32 unsigned int j; /*frames*/ 33 for (j=0;j<(unsigned)nframes;j++) { 34 if(usejack) { 35 /* write input to datanew */ 36 fvec_write_sample(ibuf, input[0][j], pos); 37 /* put synthnew in output */ 38 output[0][j] = fvec_read_sample(obuf, pos); 39 } 40 /*time for fft*/ 41 if (pos == overlap_size-1) { 42 /* block loop */ 43 fvec_zeros(obuf); 44 aubio_onset_do (o, ibuf, onset); 45 if ( fvec_read_sample(onset, 0) ) { 46 aubio_wavetable_play ( wavetable ); 47 } else { 48 aubio_wavetable_stop ( wavetable ); 49 } 50 aubio_wavetable_do (wavetable, obuf, obuf); 51 /* end of block loop */ 52 pos = -1; /* so it will be zero next j loop */ 53 } 54 pos++; 29 void 30 process_block(fvec_t *ibuf, fvec_t *obuf) { 31 fvec_zeros(obuf); 32 aubio_onset_do (o, ibuf, onset); 33 if ( fvec_read_sample(onset, 0) ) { 34 aubio_wavetable_play ( wavetable ); 35 } else { 36 aubio_wavetable_stop ( wavetable ); 55 37 } 56 return 1;38 aubio_wavetable_do (wavetable, obuf, obuf); 57 39 } 58 40 59 staticvoid41 void 60 42 process_print (void) 61 43 { 62 /* output times in seconds, taking back some delay to ensure the label is63 * _before_ the actual onset */64 if (!verbose && usejack)65 return;66 44 smpl_t onset_found = fvec_read_sample (onset, 0); 67 45 if (onset_found) { … … 73 51 examples_common_init(argc,argv); 74 52 75 o = new_aubio_onset (onset_method, buffer_size, overlap_size, samplerate); 53 verbmsg ("using source: %s at %dHz\n", source_uri, samplerate); 54 verbmsg ("onset method: %s, ", onset_method); 55 verbmsg ("buffer_size: %d, ", buffer_size); 56 verbmsg ("hop_size: %d, ", hop_size); 57 verbmsg ("threshold: %f\n", onset_threshold); 58 59 o = new_aubio_onset (onset_method, buffer_size, hop_size, samplerate); 76 60 if (onset_threshold != 0.) aubio_onset_set_threshold (o, onset_threshold); 77 61 onset = new_fvec (1); 78 62 79 wavetable = new_aubio_wavetable (samplerate, overlap_size);63 wavetable = new_aubio_wavetable (samplerate, hop_size); 80 64 aubio_wavetable_set_freq ( wavetable, 2450.); 81 65 //aubio_sampler_load (sampler, "/archives/sounds/woodblock.aiff"); 82 66 83 examples_common_process( aubio_process,process_print);67 examples_common_process((aubio_process_func_t)process_block, process_print); 84 68 85 69 del_aubio_onset (o); … … 88 72 89 73 examples_common_del(); 90 debug("End of program.\n");91 fflush(stderr);92 74 return 0; 93 75 } 94
Note: See TracChangeset
for help on using the changeset viewer.