- Timestamp:
- Apr 11, 2005, 6:37:51 PM (20 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:
- dc27a81
- Parents:
- 84941cb
- Location:
- examples
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/aubionotes.c
r84941cb rbd2f2ab 17 17 */ 18 18 19 #include <stdio.h>20 #include <stdlib.h>21 #include <stdarg.h>22 #include <getopt.h>23 #include <unistd.h>24 #include <math.h>25 #include "aubio.h"26 #include "aubioext.h"27 19 #include "utils.h" 28 20 29 /* settings */30 const char * output_filename = NULL;31 const char * input_filename = NULL;32 const char * onset_filename = "/usr/share/sounds/aubio/woodblock.aiff";33 int verbose = 0;34 int usejack = 0;35 int usedoubled = 1;36 int usemidi = 1;37 int median = 0;38 39 /* energy,specdiff,hfc,complexdomain,phase */40 aubio_onsetdetection_type type_onset = hfc;41 aubio_onsetdetection_type type_onset2 = complexdomain;42 smpl_t threshold = 0.3;43 smpl_t threshold2 = -90.;44 uint_t buffer_size = 1024;45 uint_t overlap_size = 512;46 uint_t channels = 1;47 uint_t samplerate = 44100;48 49 /* global objects */50 int frames;51 aubio_pvoc_t * pv;52 fvec_t * ibuf;53 fvec_t * obuf;54 cvec_t * fftgrain;55 fvec_t * woodblock;56 aubio_onsetdetection_t *o;57 aubio_onsetdetection_t *o2;58 fvec_t *onset;59 fvec_t *onset2;60 int isonset = 0;61 aubio_pickpeak_t * parms;62 63 /* pitch objects */64 smpl_t pitch = 0.;65 aubio_pitchdetection_t * pitchdet;66 67 fvec_t * note_buffer = NULL;68 fvec_t * note_buffer2 = NULL;69 uint_t medianfiltlen = 6;70 smpl_t curlevel = 0.;71 smpl_t maxonset = 0.;72 73 /* midi objects */74 aubio_midi_player_t * mplay;75 aubio_midi_driver_t * mdriver;76 aubio_midi_event_t * event;77 78 21 unsigned int pos = 0; /*frames%dspblocksize*/ 79 80 void send_noteon(aubio_midi_driver_t * d, int pitch, int velo); 81 void send_noteon(aubio_midi_driver_t * d, int pitch, int velo) 82 { 83 /* we should check if we use midi here, not jack */ 84 #if ALSA_SUPPORT 85 if (usejack) { 86 if (velo==0) { 87 aubio_midi_event_set_type(event,NOTE_OFF); 88 } else { 89 aubio_midi_event_set_type(event,NOTE_ON); 90 } 91 aubio_midi_event_set_channel(event,0); 92 aubio_midi_event_set_pitch(event,pitch); 93 aubio_midi_event_set_velocity(event,velo); 94 aubio_midi_direct_output(mdriver,event); 95 } else 96 #endif 97 { 98 if (velo==0) { 99 outmsg("%f\n",frames*overlap_size/(float)samplerate); 100 } else { 101 outmsg("%d\t%f\t",pitch,frames*overlap_size/(float)samplerate); 102 } 103 } 104 } 105 106 107 /** append new note candidate to the note_buffer and return filtered value. we 108 * need to copy the input array as vec_median destroy its input data.*/ 109 110 void note_append(fvec_t * note_buffer, smpl_t curnote); 111 void note_append(fvec_t * note_buffer, smpl_t curnote) { 112 uint_t i = 0; 113 for (i = 0; i < note_buffer->length - 1; i++) { 114 note_buffer->data[0][i] = note_buffer->data[0][i+1]; 115 } 116 note_buffer->data[0][note_buffer->length - 1] = curnote; 117 return; 118 } 119 120 uint_t get_note(fvec_t *note_buffer, fvec_t *note_buffer2); 121 uint_t get_note(fvec_t *note_buffer, fvec_t *note_buffer2){ 122 uint_t i = 0; 123 for (i = 0; i < note_buffer->length; i++) { 124 note_buffer2->data[0][i] = note_buffer->data[0][i]; 125 } 126 return vec_median(note_buffer2); 127 } 128 129 130 smpl_t curnote = 0.; 131 smpl_t newnote = 0.; 132 uint_t isready = 0; 22 uint_t usepitch = 1; 133 23 134 24 int aubio_process(float **input, float **output, int nframes); … … 158 48 pitch = aubio_pitchdetection(pitchdet,ibuf); 159 49 if(median){ 160 newnote = (FLOOR)(bintomidi(pitch,samplerate,buffer_size*4)+.5); 161 note_append(note_buffer, newnote); 50 note_append(note_buffer, pitch); 162 51 } 163 52 … … 165 54 curlevel = aubio_level_detection(ibuf, threshold2); 166 55 if (isonset) { 167 /* test for silence */ 168 if (curlevel == 1.) { 169 isonset=0; 170 if (median) isready = 0; 171 /* send note off */ 172 send_noteon(mdriver,curnote,0); 173 } else { 174 if (median) { 175 isready = 1; 176 } else { 177 /* kill old note */ 178 send_noteon(mdriver,curnote,0); 179 //curnote = (int)FLOOR(bintomidi(pitch,samplerate,buffer_size*4) + .5); 180 curnote = (int)FLOOR(freqtomidi(pitch) + .5); 181 /* get and send new one */ 182 /*if (curnote<45){ 183 send_noteon(mdriver,curnote,0); 184 } else {*/ 185 if (curnote>45){ 186 send_noteon(mdriver,curnote,127+(int)FLOOR(curlevel)); 187 } 188 } 189 190 for (pos = 0; pos < overlap_size; pos++){ 191 obuf->data[0][pos] = woodblock->data[0][pos]; 192 } 193 } 56 /* test for silence */ 57 if (curlevel == 1.) { 58 isonset=0; 59 if (median) isready = 0; 60 /* send note off */ 61 send_noteon(curnote,0); 62 } else { 63 if (median) { 64 isready = 1; 65 } else { 66 /* kill old note */ 67 send_noteon(curnote,0); 68 /* get and send new one */ 69 send_noteon(pitch,127+(int)FLOOR(curlevel)); 70 curnote = pitch; 71 } 72 73 for (pos = 0; pos < overlap_size; pos++){ 74 obuf->data[0][pos] = woodblock->data[0][pos]; 75 } 76 } 194 77 } else { 195 78 if (median) { 196 // if (curlevel != 1) { 197 // if (bufpos == note_buffer->length) 198 // curnote = aubio_getnote(note_buffer); 199 // } 200 // 201 if (isready > 0) 202 isready++; 203 if (isready == note_buffer->length) 204 { 205 //outmsg("%d, %f\n", isready, curnote); 206 send_noteon(mdriver,curnote,0); 207 /* kill old note */ 208 newnote = get_note(note_buffer, note_buffer2); 209 curnote = newnote; 210 /* get and send new one */ 211 /*if (curnote<45){ 212 send_noteon(mdriver,curnote,0); 213 } else {*/ 214 if (curnote>45){ 215 send_noteon(mdriver,curnote,127+(int)FLOOR(curlevel)); 216 } 217 } 218 } // if median 79 if (isready > 0) 80 isready++; 81 if (isready == median) 82 { 83 /* kill old note */ 84 send_noteon(curnote,0); 85 newnote = get_note(note_buffer, note_buffer2); 86 curnote = newnote; 87 /* get and send new one */ 88 if (curnote>45){ 89 send_noteon(curnote,127+(int)FLOOR(curlevel)); 90 } 91 } 92 } // if median 219 93 for (pos = 0; pos < overlap_size; pos++) 220 94 obuf->data[0][pos] = 0.; … … 228 102 } 229 103 104 void process_print (void); 105 void process_print (void) { 106 if (verbose) outmsg("%f\n",pitch); 107 } 108 230 109 int main(int argc, char **argv) { 231 232 aubio_file_t * file = NULL; 233 aubio_file_t * fileout = NULL; 234 235 aubio_file_t * onsetfile = new_file_ro(onset_filename); 236 /* parse command line arguments */ 237 parse_args(argc, argv); 238 239 if(!usejack) 240 { 241 debug("Opening files ...\n"); 242 file = new_file_ro (input_filename); 243 file_info(file); 244 samplerate = aubio_file_samplerate(file); 245 channels = aubio_file_channels(file); 246 if (output_filename != NULL) 247 fileout = new_file_wo(file, output_filename); 248 } 249 250 ibuf = new_fvec(overlap_size, channels); 251 obuf = new_fvec(overlap_size, channels); 252 woodblock = new_fvec(buffer_size,1); 253 fftgrain = new_cvec(buffer_size, channels); 254 255 aubio_pitchdetection_type mode = yin; // mcomb 256 pitchdet = new_aubio_pitchdetection(buffer_size*4, overlap_size, channels, samplerate, mode, freq); 257 258 if (median) { 259 note_buffer = new_fvec(medianfiltlen, 1); 260 note_buffer2= new_fvec(medianfiltlen, 1); 261 } 262 /* read the output sound once */ 263 file_read(onsetfile, overlap_size, woodblock); 264 /* phase vocoder */ 265 pv = new_aubio_pvoc(buffer_size, overlap_size, channels); 266 /* onsets */ 267 parms = new_aubio_peakpicker(threshold); 268 o = new_aubio_onsetdetection(type_onset,buffer_size,channels); 269 onset = new_fvec(1, channels); 270 if (usedoubled) { 271 o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels); 272 onset2 = new_fvec(1 , channels); 273 } 274 275 if(usejack) { 276 #ifdef JACK_SUPPORT 277 aubio_jack_t * jack_setup; 278 debug("Midi init ...\n"); 279 debug("Jack init ...\n"); 280 jack_setup = new_aubio_jack(channels, channels, 281 (aubio_process_func_t)aubio_process); 282 283 mplay = new_aubio_midi_player(); 284 285 mdriver = new_aubio_midi_driver("alsa_seq", 286 (handle_midi_event_func_t)aubio_midi_send_event, mplay); 287 288 event = new_aubio_midi_event(); 289 290 debug("Jack activation ...\n"); 291 aubio_jack_activate(jack_setup); 292 debug("Processing (Ctrl+C to quit) ...\n"); 293 pause(); 294 send_noteon(mdriver,curnote,0); 295 aubio_jack_close(jack_setup); 296 del_aubio_midi_driver(mdriver); 297 #else 298 usage(stderr, 1); 299 outmsg("Compiled without jack output, exiting.\n"); 300 #endif 301 302 } else { 303 /* phasevoc */ 304 debug("Processing ...\n"); 305 306 frames = 0; 307 308 while (overlap_size == file_read(file, overlap_size, ibuf)) 309 { 310 isonset=0; 311 aubio_process(ibuf->data, obuf->data, overlap_size); 312 if (output_filename != NULL) { 313 file_write(fileout,overlap_size,obuf); 314 } 315 frames++; 316 } 317 send_noteon(mdriver,curnote,0); 318 319 debug("Processed %d frames of %d samples.\n", frames, buffer_size); 320 del_file(file); 321 322 if (output_filename != NULL) 323 del_file(fileout); 324 325 } 326 327 del_aubio_pvoc(pv); 328 del_fvec(obuf); 329 del_fvec(ibuf); 330 del_cvec(fftgrain); 331 del_aubio_pitchdetection(pitchdet); 332 del_fvec(onset); 333 if (median) { 334 del_fvec(note_buffer); 335 del_fvec(note_buffer2); 336 } 337 110 examples_common_init(argc,argv); 111 examples_common_process(aubio_process, process_print); 112 examples_common_del(); 338 113 debug("End of program.\n"); 339 114 fflush(stderr); -
examples/aubioonset.c
r84941cb rbd2f2ab 17 17 */ 18 18 19 #include <stdio.h>20 #include <stdlib.h>21 #include <stdarg.h>22 #include <getopt.h>23 #include <unistd.h>24 #include "aubio.h"25 #include "aubioext.h"26 19 #include "utils.h" 27 20 21 unsigned int pos = 0; /*frames%dspblocksize*/ 22 uint_t usepitch = 0; 23 28 24 int aubio_process(float **input, float **output, int nframes); 29 30 const char * output_filename = NULL;31 const char * input_filename = NULL;32 const char * onset_filename = "/usr/share/sounds/aubio/woodblock.aiff";33 34 /* settings */35 int verbose = 0;36 int usejack = 0;37 int usedoubled = 1;38 39 40 /* energy,specdiff,hfc,complexdomain,phase */41 aubio_onsetdetection_type type_onset = hfc;42 aubio_onsetdetection_type type_onset2 = complexdomain;43 smpl_t threshold = 0.1;44 smpl_t threshold2 = -90.;45 uint_t buffer_size = 1024;46 uint_t overlap_size = 512;47 uint_t channels = 1;48 uint_t samplerate = 44100;49 50 /* global objects */51 aubio_pvoc_t * pv;52 fvec_t * ibuf;53 fvec_t * obuf;54 cvec_t * fftgrain;55 fvec_t * woodblock;56 aubio_onsetdetection_t *o;57 aubio_onsetdetection_t *o2;58 fvec_t *onset;59 fvec_t *onset2;60 int isonset = 0;61 aubio_pickpeak_t * parms;62 unsigned int pos = 0; /*frames%dspblocksize*/63 64 25 int aubio_process(float **input, float **output, int nframes) { 65 26 unsigned int i; /*channels*/ … … 96 57 obuf->data[0][pos] = 0.; 97 58 } 98 //aubio_pvoc_rdo(pv,fftgrain, obuf);99 59 /* end of block loop */ 100 60 pos = -1; /* so it will be zero next j loop */ … … 105 65 } 106 66 107 int main(int argc, char **argv) { 108 int frames; 109 110 aubio_file_t * file = NULL; 111 aubio_file_t * fileout = NULL; 112 113 aubio_file_t * onsetfile = new_file_ro(onset_filename); 114 parse_args(argc, argv); 115 116 if(!usejack) 117 { 118 debug("Opening files ...\n"); 119 file = new_file_ro (input_filename); 120 if (verbose) file_info(file); 121 channels = aubio_file_channels(file); 122 samplerate = aubio_file_samplerate(file); 123 if (output_filename != NULL) 124 fileout = new_file_wo(file, output_filename); 125 } 126 127 ibuf = new_fvec(overlap_size, channels); 128 obuf = new_fvec(overlap_size, channels); 129 woodblock = new_fvec(buffer_size,1); 130 fftgrain = new_cvec(buffer_size, channels); 131 132 /* read the output sound once */ 133 file_read(onsetfile, overlap_size, woodblock); 134 135 /* phase vocoder */ 136 debug("Phase voc init ... \n"); 137 pv = new_aubio_pvoc(buffer_size, overlap_size, channels); 138 139 /* onsets */ 140 parms = new_aubio_peakpicker(threshold); 141 o = new_aubio_onsetdetection(type_onset,buffer_size,channels); 142 onset = new_fvec(1, channels); 143 if (usedoubled) { 144 o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels); 145 onset2 = new_fvec(1 , channels); 146 } 147 148 if(usejack) { 149 #ifdef JACK_SUPPORT 150 aubio_jack_t * jack_setup; 151 debug("Jack init ...\n"); 152 jack_setup = new_aubio_jack(channels, channels, 153 (aubio_process_func_t)aubio_process); 154 debug("Jack activation ...\n"); 155 aubio_jack_activate(jack_setup); 156 debug("Processing (Ctrl+C to quit) ...\n"); 157 pause(); 158 aubio_jack_close(jack_setup); 159 #else 160 outmsg("Compiled without jack output, exiting."); 161 #endif 162 163 } else { 164 /* phasevoc */ 165 debug("Processing ...\n"); 166 167 frames = 0; 168 169 while (overlap_size == file_read(file, overlap_size, ibuf)) 170 { 171 isonset=0; 172 aubio_process(ibuf->data, obuf->data, overlap_size); 67 void process_print (void); 68 void process_print (void) { 173 69 /* output times in seconds, taking back some 174 70 * delay to ensure the label is _before_ the … … 181 77 } 182 78 } 183 if (output_filename != NULL) { 184 file_write(fileout,overlap_size,obuf); 185 } 186 frames++; 187 } 79 } 188 80 189 debug("Processed %d frames of %d samples.\n", frames, buffer_size); 190 del_file(file); 191 192 if (output_filename != NULL) 193 del_file(fileout); 194 195 } 196 197 del_aubio_pvoc(pv); 198 del_fvec(obuf); 199 del_fvec(ibuf); 200 del_cvec(fftgrain); 201 del_fvec(onset); 202 81 int main(int argc, char **argv) { 82 examples_common_init(argc,argv); 83 examples_common_process(aubio_process,process_print); 84 examples_common_del(); 203 85 debug("End of program.\n"); 204 86 fflush(stderr); -
examples/utils.c
r84941cb rbd2f2ab 18 18 cca_client_t * aubio_cca_client; 19 19 #endif /* LADCCA_SUPPORT */ 20 21 /* settings */ 22 const char * output_filename = NULL; 23 const char * input_filename = NULL; 24 const char * onset_filename = "/usr/share/sounds/aubio/woodblock.aiff"; 25 int frames = 0; 26 int verbose = 0; 27 int usejack = 0; 28 int usedoubled = 1; 29 30 31 /* energy,specdiff,hfc,complexdomain,phase */ 32 aubio_onsetdetection_type type_onset = hfc; 33 aubio_onsetdetection_type type_onset2 = complexdomain; 34 smpl_t threshold = 0.3; 35 smpl_t threshold2 = -90.; 36 uint_t buffer_size = 1024; 37 uint_t overlap_size = 512; 38 uint_t channels = 1; 39 uint_t samplerate = 44100; 40 41 42 aubio_file_t * file = NULL; 43 aubio_file_t * fileout = NULL; 44 45 aubio_pvoc_t * pv; 46 fvec_t * ibuf; 47 fvec_t * obuf; 48 cvec_t * fftgrain; 49 fvec_t * woodblock; 50 aubio_onsetdetection_t *o; 51 aubio_onsetdetection_t *o2; 52 fvec_t *onset; 53 fvec_t *onset2; 54 int isonset = 0; 55 aubio_pickpeak_t * parms; 56 57 58 /* pitch objects */ 59 smpl_t pitch = 0.; 60 aubio_pitchdetection_t * pitchdet; 61 aubio_pitchdetection_type mode = yin; // mcomb 62 uint_t median = 6; 63 64 fvec_t * note_buffer = NULL; 65 fvec_t * note_buffer2 = NULL; 66 smpl_t curlevel = 0.; 67 smpl_t maxonset = 0.; 68 69 /* midi objects */ 70 aubio_midi_player_t * mplay; 71 aubio_midi_driver_t * mdriver; 72 aubio_midi_event_t * event; 73 74 smpl_t curnote = 0.; 75 smpl_t newnote = 0.; 76 uint_t isready = 0; 77 20 78 21 79 … … 136 194 } 137 195 196 void examples_common_init(int argc,char ** argv) { 197 198 199 aubio_file_t * onsetfile = new_file_ro(onset_filename); 200 /* parse command line arguments */ 201 parse_args(argc, argv); 202 203 if(!usejack) 204 { 205 debug("Opening files ...\n"); 206 file = new_file_ro (input_filename); 207 if (verbose) file_info(file); 208 channels = aubio_file_channels(file); 209 samplerate = aubio_file_samplerate(file); 210 if (output_filename != NULL) 211 fileout = new_file_wo(file, output_filename); 212 } 213 214 ibuf = new_fvec(overlap_size, channels); 215 obuf = new_fvec(overlap_size, channels); 216 woodblock = new_fvec(buffer_size,1); 217 fftgrain = new_cvec(buffer_size, channels); 218 219 if (usepitch) { 220 pitchdet = new_aubio_pitchdetection(buffer_size*4, overlap_size, channels, samplerate, mode, freq); 221 222 if (median) { 223 note_buffer = new_fvec(median, 1); 224 note_buffer2= new_fvec(median, 1); 225 } 226 } 227 /* read the output sound once */ 228 file_read(onsetfile, overlap_size, woodblock); 229 /* phase vocoder */ 230 pv = new_aubio_pvoc(buffer_size, overlap_size, channels); 231 /* onsets */ 232 parms = new_aubio_peakpicker(threshold); 233 o = new_aubio_onsetdetection(type_onset,buffer_size,channels); 234 onset = new_fvec(1, channels); 235 if (usedoubled) { 236 o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels); 237 onset2 = new_fvec(1 , channels); 238 } 239 240 } 241 242 243 void examples_common_del(void){ 244 if (usepitch) { 245 send_noteon(curnote,0); 246 del_aubio_pitchdetection(pitchdet); 247 if (median) { 248 del_fvec(note_buffer); 249 del_fvec(note_buffer2); 250 } 251 } 252 del_aubio_pvoc(pv); 253 del_fvec(obuf); 254 del_fvec(ibuf); 255 del_cvec(fftgrain); 256 del_fvec(onset); 257 } 258 259 void examples_common_process(aubio_process_func_t process_func, aubio_print_func_t print ){ 260 if(usejack) { 261 #ifdef JACK_SUPPORT 262 aubio_jack_t * jack_setup; 263 debug("Jack init ...\n"); 264 jack_setup = new_aubio_jack(channels, channels, 265 (aubio_process_func_t)process_func); 266 if (usepitch) { 267 debug("Midi init ...\n"); 268 mplay = new_aubio_midi_player(); 269 mdriver = new_aubio_midi_driver("alsa_seq", 270 (handle_midi_event_func_t)aubio_midi_send_event, mplay); 271 event = new_aubio_midi_event(); 272 } 273 debug("Jack activation ...\n"); 274 aubio_jack_activate(jack_setup); 275 debug("Processing (Ctrl+C to quit) ...\n"); 276 pause(); 277 aubio_jack_close(jack_setup); 278 if (usepitch) { 279 send_noteon(curnote,0); 280 del_aubio_midi_driver(mdriver); 281 } 282 #else 283 usage(stderr, 1); 284 outmsg("Compiled without jack output, exiting.\n"); 285 #endif 286 287 } else { 288 /* phasevoc */ 289 debug("Processing ...\n"); 290 291 frames = 0; 292 293 while (overlap_size == file_read(file, overlap_size, ibuf)) 294 { 295 isonset=0; 296 process_func(ibuf->data, obuf->data, overlap_size); 297 print(); 298 if (output_filename != NULL) { 299 file_write(fileout,overlap_size,obuf); 300 } 301 frames++; 302 } 303 304 debug("Processed %d frames of %d samples.\n", frames, buffer_size); 305 del_file(file); 306 307 if (output_filename != NULL) 308 del_file(fileout); 309 310 } 311 } 312 313 314 315 void send_noteon(int pitch, int velo) 316 { 317 smpl_t mpitch = (FLOOR)(freqtomidi(pitch)+.5); 318 /* we should check if we use midi here, not jack */ 319 #if ALSA_SUPPORT 320 if (usejack) { 321 if (velo==0) { 322 aubio_midi_event_set_type(event,NOTE_OFF); 323 } else { 324 aubio_midi_event_set_type(event,NOTE_ON); 325 } 326 aubio_midi_event_set_channel(event,0); 327 aubio_midi_event_set_pitch(event,mpitch); 328 aubio_midi_event_set_velocity(event,velo); 329 aubio_midi_direct_output(mdriver,event); 330 } else 331 #endif 332 if (!verbose) 333 { 334 if (velo==0) { 335 outmsg("%f\n",frames*overlap_size/(float)samplerate); 336 } else { 337 outmsg("%f\t%f\t", mpitch, 338 frames*overlap_size/(float)samplerate); 339 } 340 } 341 } 342 343 344 void note_append(fvec_t * note_buffer, smpl_t curnote) { 345 uint_t i = 0; 346 for (i = 0; i < note_buffer->length - 1; i++) { 347 note_buffer->data[0][i] = note_buffer->data[0][i+1]; 348 } 349 note_buffer->data[0][note_buffer->length - 1] = curnote; 350 return; 351 } 352 353 uint_t get_note(fvec_t *note_buffer, fvec_t *note_buffer2){ 354 uint_t i = 0; 355 for (i = 0; i < note_buffer->length; i++) { 356 note_buffer2->data[0][i] = note_buffer->data[0][i]; 357 } 358 return vec_median(note_buffer2); 359 } 360 -
examples/utils.h
r84941cb rbd2f2ab 18 18 */ 19 19 20 #include <stdio.h> 21 #include <stdlib.h> 22 #include <stdarg.h> 23 #include <getopt.h> 24 #include <unistd.h> 25 #include <math.h> 26 #include <aubio.h> 27 #include <aubioext.h> 28 20 29 #define debug(...) if (verbose) fprintf (stderr, __VA_ARGS__) 21 30 #define errmsg(...) fprintf (stderr, __VA_ARGS__) 22 31 #define outmsg(...) fprintf (stdout, __VA_ARGS__) 23 32 33 extern int frames; 24 34 extern int verbose; 25 35 extern int usejack; 26 36 extern int usedoubled; 27 extern int median;37 extern unsigned int median; 28 38 extern const char * output_filename; 29 39 extern const char * input_filename; … … 31 41 void usage (FILE * stream, int exit_code); 32 42 int parse_args (int argc, char **argv); 43 void examples_common_init(int argc, char **argv); 44 void examples_common_del(void); 45 typedef void (aubio_print_func_t)(void); 46 void examples_common_process(aubio_process_func_t process_func, aubio_print_func_t print); 33 47 48 49 void send_noteon(int pitch, int velo); 50 /** append new note candidate to the note_buffer and return filtered value. we 51 * need to copy the input array as vec_median destroy its input data.*/ 52 void note_append(fvec_t * note_buffer, smpl_t curnote); 53 uint_t get_note(fvec_t *note_buffer, fvec_t *note_buffer2); 54 55 extern const char * output_filename; 56 extern const char * input_filename; 57 extern const char * onset_filename; 58 extern int verbose; 59 extern int usejack; 60 extern int usedoubled; 61 62 63 /* energy,specdiff,hfc,complexdomain,phase */ 64 extern aubio_onsetdetection_type type_onset; 65 extern aubio_onsetdetection_type type_onset2; 66 extern smpl_t threshold; 67 extern smpl_t threshold2; 68 extern uint_t buffer_size; 69 extern uint_t overlap_size; 70 extern uint_t channels; 71 extern uint_t samplerate; 72 73 74 extern aubio_file_t * file; 75 extern aubio_file_t * fileout; 76 77 extern aubio_pvoc_t * pv; 78 extern fvec_t * ibuf; 79 extern fvec_t * obuf; 80 extern cvec_t * fftgrain; 81 extern fvec_t * woodblock; 82 extern aubio_onsetdetection_t *o; 83 extern aubio_onsetdetection_t *o2; 84 extern fvec_t *onset; 85 extern fvec_t *onset2; 86 extern int isonset; 87 extern aubio_pickpeak_t * parms; 88 89 90 /* pitch objects */ 91 extern smpl_t pitch; 92 extern aubio_pitchdetection_t * pitchdet; 93 extern aubio_pitchdetection_type mode; 94 extern uint_t median; 95 96 extern fvec_t * note_buffer; 97 extern fvec_t * note_buffer2; 98 extern smpl_t curlevel; 99 extern smpl_t maxonset; 100 101 /* midi objects */ 102 extern aubio_midi_player_t * mplay; 103 extern aubio_midi_driver_t * mdriver; 104 extern aubio_midi_event_t * event; 105 106 extern smpl_t curnote; 107 extern smpl_t newnote; 108 extern uint_t isready; 109 110 /* per example param */ 111 extern uint_t usepitch; 112
Note: See TracChangeset
for help on using the changeset viewer.