Changeset 466dff3 for examples/aubioquiet.c
- Timestamp:
- Dec 7, 2013, 4:09:00 AM (11 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/aubioquiet.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. … … 22 22 #include "parse_args.h" 23 23 24 unsigned int pos = 0; /*frames%dspblocksize*/25 24 sint_t wassilence = 1, issilence; 26 25 27 int aubio_process(smpl_t **input, smpl_t **output, int nframes); 28 int aubio_process(smpl_t **input, smpl_t **output, int nframes) { 29 unsigned int j; /*frames*/ 30 for (j=0;j<(unsigned)nframes;j++) { 31 if(usejack) { 32 /* write input to datanew */ 33 fvec_write_sample(ibuf, input[0][j], pos); 34 /* put synthnew in output */ 35 output[0][j] = fvec_read_sample(obuf, pos); 36 } 37 /*time for fft*/ 38 if (pos == overlap_size-1) { 39 /* test for silence */ 40 if (aubio_silence_detection(ibuf, silence)==1) { 41 if (wassilence==1) issilence = 1; 42 else issilence = 2; 43 wassilence=1; 44 } else { 45 if (wassilence<=0) issilence = 0; 46 else issilence = -1; 47 wassilence=0; 48 } 49 /* end of block loop */ 50 pos = -1; /* so it will be zero next j loop */ 51 } 52 pos++; 26 void process_block(fvec_t * ibuf, fvec_t * obuf) { 27 fvec_zeros (obuf); 28 if (aubio_silence_detection(ibuf, silence)==1) { 29 if (wassilence==1) issilence = 1; 30 else issilence = 2; 31 wassilence=1; 32 } else { 33 if (wassilence<=0) issilence = 0; 34 else issilence = -1; 35 wassilence=0; 53 36 } 54 return 1;55 37 } 56 38 57 39 static void process_print (void) { 58 int curframes = (frames - 4) > 0 ? frames -4 : 0;59 60 outmsg("NOISY: %f\n",curframes*overlap_size/(float)samplerate);61 } else if (issilence == 2) {62 outmsg("QUIET: %f\n",curframes*overlap_size/(float)samplerate);63 40 int curblocks = (blocks - 4) > 0 ? blocks - 4 : 0; 41 if (issilence == -1) { 42 outmsg("NOISY: %f\n",curblocks*hop_size/(float)samplerate); 43 } else if (issilence == 2) { 44 outmsg("QUIET: %f\n",curblocks*hop_size/(float)samplerate); 45 } 64 46 } 65 47 66 48 int main(int argc, char **argv) { 67 49 examples_common_init(argc,argv); 68 examples_common_process(aubio_process,process_print); 50 verbmsg ("using source: %s at %dHz\n", source_uri, samplerate); 51 verbmsg ("buffer_size: %d, ", buffer_size); 52 verbmsg ("hop_size: %d\n", hop_size); 53 examples_common_process((aubio_process_func_t)process_block,process_print); 69 54 examples_common_del(); 70 debug("End of program.\n");71 fflush(stderr);72 55 return 0; 73 56 }
Note: See TracChangeset
for help on using the changeset viewer.