Changeset 466dff3 for examples/aubiotrack.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/aubiotrack.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. … … 23 23 #include "parse_args.h" 24 24 25 uint_t pos = 0; /* frames%dspblocksize */ 26 aubio_tempo_t * bt = NULL; 25 aubio_tempo_t * tempo; 27 26 aubio_wavetable_t *wavetable; 28 fvec_t * tempo_out = NULL;27 fvec_t * tempo_out; 29 28 smpl_t istactus = 0; 30 29 smpl_t isonset = 0; 31 30 32 static int aubio_process(smpl_t **input, smpl_t **output, int nframes) { 33 unsigned int j; /*frames*/ 34 for (j=0;j<(unsigned)nframes;j++) { 35 if(usejack) { 36 /* write input to datanew */ 37 fvec_write_sample(ibuf, input[0][j], pos); 38 /* put synthnew in output */ 39 output[0][j] = fvec_read_sample(obuf, pos); 40 } 41 /*time for fft*/ 42 if (pos == overlap_size-1) { 43 /* block loop */ 44 aubio_tempo_do (bt,ibuf,tempo_out); 45 istactus = fvec_read_sample (tempo_out, 0); 46 isonset = fvec_read_sample (tempo_out, 1); 47 fvec_zeros (obuf); 48 if (istactus > 0.) { 49 aubio_wavetable_play ( wavetable ); 50 } else { 51 aubio_wavetable_stop ( wavetable ); 52 } 53 aubio_wavetable_do (wavetable, obuf, obuf); 54 /* end of block loop */ 55 pos = -1; /* so it will be zero next j loop */ 56 } 57 pos++; 31 void process_block(fvec_t * ibuf, fvec_t *obuf) { 32 aubio_tempo_do (tempo, ibuf, tempo_out); 33 istactus = fvec_read_sample (tempo_out, 0); 34 isonset = fvec_read_sample (tempo_out, 1); 35 fvec_zeros (obuf); 36 if (istactus > 0.) { 37 aubio_wavetable_play ( wavetable ); 38 } else { 39 aubio_wavetable_stop ( wavetable ); 58 40 } 59 return 1;41 aubio_wavetable_do (wavetable, obuf, obuf); 60 42 } 61 43 62 static void process_print (void) { 63 if (sink_uri == NULL) { 64 if (istactus) { 65 outmsg("%f\n",((smpl_t)(frames*overlap_size)+(istactus-1.)*overlap_size)/(smpl_t)samplerate); 66 } 67 if (isonset && verbose) 68 outmsg(" \t \t%f\n",(frames)*overlap_size/(float)samplerate); 44 void process_print (void) { 45 if (istactus) { 46 outmsg("%f\n", aubio_tempo_get_last_s(tempo) ); 69 47 } 48 //if (isonset && verbose) 49 // outmsg(" \t \t%f\n",(blocks)*hop_size/(float)samplerate); 70 50 } 71 51 72 52 int main(int argc, char **argv) { 73 53 // override general settings from utils.c 74 54 buffer_size = 1024; 75 overlap_size = 512;76 /* override default settings */ 55 hop_size = 512; 56 77 57 examples_common_init(argc,argv); 78 58 59 verbmsg ("using source: %s at %dHz\n", source_uri, samplerate); 60 61 verbmsg ("tempo method: %s, ", tempo_method); 62 verbmsg ("buffer_size: %d, ", buffer_size); 63 verbmsg ("hop_size: %d, ", hop_size); 64 verbmsg ("threshold: %f\n", onset_threshold); 65 79 66 tempo_out = new_fvec(2); 80 bt = new_aubio_tempo(tempo_method,buffer_size,overlap_size, samplerate);81 if (onset_threshold != 0.) aubio_tempo_set_threshold ( bt, onset_threshold);67 tempo = new_aubio_tempo(tempo_method, buffer_size, hop_size, samplerate); 68 if (onset_threshold != 0.) aubio_tempo_set_threshold (tempo, onset_threshold); 82 69 83 wavetable = new_aubio_wavetable (samplerate, overlap_size);70 wavetable = new_aubio_wavetable (samplerate, hop_size); 84 71 aubio_wavetable_set_freq ( wavetable, 2450.); 85 72 //aubio_sampler_load (sampler, "/archives/sounds/woodblock.aiff"); 86 73 87 examples_common_process( aubio_process,process_print);74 examples_common_process((aubio_process_func_t)process_block,process_print); 88 75 89 del_aubio_tempo( bt);76 del_aubio_tempo(tempo); 90 77 del_aubio_wavetable (wavetable); 91 78 del_fvec(tempo_out); 92 79 93 80 examples_common_del(); 94 95 debug("End of program.\n");96 97 fflush(stderr);98 99 81 return 0; 100 82 }
Note: See TracChangeset
for help on using the changeset viewer.