Changeset 466dff3 for examples/aubiopitch.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/aubiopitch.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 unsigned int pos = 0; /*frames%dspblocksize*/26 27 25 aubio_pitch_t *o; 28 26 aubio_wavetable_t *wavetable; 29 27 fvec_t *pitch; 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 aubio_pitch_do (o, ibuf, pitch); 44 smpl_t freq = fvec_read_sample(pitch, 0); 45 aubio_wavetable_set_amp ( wavetable, aubio_level_lin (ibuf) ); 46 if (freq != 0.0) { 47 aubio_wavetable_set_freq ( wavetable, freq ); 48 } else { 49 aubio_wavetable_set_freq ( wavetable, 0.0 ); 50 } 51 aubio_wavetable_do (wavetable, obuf, obuf); 52 /* end of block loop */ 53 pos = -1; /* so it will be zero next j loop */ 54 } 55 pos++; 29 void 30 process_block(fvec_t * ibuf, fvec_t * obuf) { 31 fvec_zeros(obuf); 32 aubio_pitch_do (o, ibuf, pitch); 33 smpl_t freq = fvec_read_sample(pitch, 0); 34 aubio_wavetable_set_amp ( wavetable, aubio_level_lin (ibuf) ); 35 if (freq != 0.0) { 36 aubio_wavetable_set_freq ( wavetable, freq ); 37 } else { 38 aubio_wavetable_set_freq ( wavetable, 0.0 ); 56 39 } 57 return 1;40 aubio_wavetable_do (wavetable, obuf, obuf); 58 41 } 59 42 60 static void process_print (void) { 61 if (!verbose && usejack) return; 62 63 outmsg("%f %f\n",(frames)64 *overlap_size/(float)samplerate, pitch_found);43 void 44 process_print (void) { 45 smpl_t pitch_found = fvec_read_sample(pitch, 0); 46 outmsg("%f %f\n",(blocks) 47 *hop_size/(float)samplerate, pitch_found); 65 48 } 66 49 … … 68 51 examples_common_init(argc,argv); 69 52 70 o = new_aubio_pitch (pitch_method, buffer_size, overlap_size, samplerate); 53 verbmsg ("using source: %s at %dHz\n", source_uri, samplerate); 54 verbmsg ("pitch method: %s, ", pitch_method); 55 verbmsg ("buffer_size: %d, ", buffer_size); 56 verbmsg ("hop_size: %d, ", hop_size); 57 verbmsg ("tolerance: %f\n", pitch_tolerance); 58 59 o = new_aubio_pitch (pitch_method, buffer_size, hop_size, samplerate); 60 if (pitch_tolerance != 0.) aubio_pitch_set_tolerance (o, pitch_tolerance); 71 61 pitch = new_fvec (1); 72 62 73 wavetable = new_aubio_wavetable (samplerate, overlap_size);63 wavetable = new_aubio_wavetable (samplerate, hop_size); 74 64 aubio_wavetable_play ( wavetable ); 75 65 76 examples_common_process( aubio_process,process_print);66 examples_common_process((aubio_process_func_t)process_block,process_print); 77 67 78 68 del_aubio_pitch (o); … … 81 71 82 72 examples_common_del(); 83 debug("End of program.\n");84 fflush(stderr);85 73 return 0; 86 74 }
Note: See TracChangeset
for help on using the changeset viewer.