Changeset 5a66677
- Timestamp:
- Feb 10, 2013, 6:14:29 AM (12 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:
- a8752a8
- Parents:
- 87b0c03
- Location:
- examples
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/aubiomfcc.c
r87b0c03 r5a66677 66 66 67 67 uint_t coef_cnt; 68 if ( output_filename== NULL) {68 if (sink_uri == NULL) { 69 69 outmsg("%f\t",frames*overlap_size/(float)samplerate); 70 70 for (coef_cnt = 0; coef_cnt < n_coefs; coef_cnt++) { -
examples/aubiotrack.c
r87b0c03 r5a66677 57 57 58 58 static void process_print (void) { 59 if ( output_filename== NULL) {59 if (sink_uri == NULL) { 60 60 if (istactus) { 61 61 outmsg("%f\n",((smpl_t)(frames*overlap_size)+(istactus-1.)*overlap_size)/(smpl_t)samplerate); -
examples/utils.c
r87b0c03 r5a66677 42 42 43 43 /* settings */ 44 const char *output_filename = NULL; 45 const char *input_filename = NULL; 46 const char *onset_filename = 47 AUBIO_PREFIX "/share/sounds/" PACKAGE "/woodblock.aiff"; 44 const char *sink_uri = NULL; 45 const char *source_uri = NULL; 48 46 int frames = 0; 49 47 int verbose = 0; … … 64 62 65 63 66 #ifdef HAVE_SNDFILE 67 aubio_sndfile_t *file = NULL; 68 aubio_sndfile_t *fileout = NULL; 69 #else 70 void *file = NULL; 71 void *fileout = NULL; 72 #endif 64 aubio_source_t *this_source = NULL; 65 aubio_sink_t *this_sink = NULL; 73 66 74 67 fvec_t *ibuf; … … 136 129 switch (next_option) { 137 130 case 'o': 138 output_filename= optarg;131 sink_uri = optarg; 139 132 break; 140 133 case 'i': 141 input_filename= optarg;134 source_uri = optarg; 142 135 break; 143 136 case 'h': /* help */ … … 183 176 while (next_option != -1); 184 177 185 if ( input_filename!= NULL) {186 debug ("Input file : %s\n", input_filename);187 } else if ( input_filename != NULL && output_filename!= NULL) {188 debug ("Input file : %s\n", input_filename);189 debug ("Output file : %s\n", output_filename);178 if (source_uri != NULL) { 179 debug ("Input file : %s\n", source_uri); 180 } else if (source_uri != NULL && sink_uri != NULL) { 181 debug ("Input file : %s\n", source_uri); 182 debug ("Output file : %s\n", sink_uri); 190 183 } else { 191 184 #if HAVE_JACK … … 202 195 } 203 196 204 #ifdef HAVE_SNDFILE205 206 197 void 207 198 examples_common_init (int argc, char **argv) 208 199 { 209 200 210 uint_t found_wood = 0;211 212 aubio_sndfile_t *onsetfile = NULL;213 201 /* parse command line arguments */ 214 202 parse_args (argc, argv); … … 216 204 if (!usejack) { 217 205 debug ("Opening files ...\n"); 218 file = new_aubio_sndfile_ro (input_filename); 219 if (file == NULL) { 220 outmsg ("Could not open input file %s.\n", input_filename); 206 // TODO get actual samplerate 207 samplerate = 44100; 208 this_source = new_aubio_source ((char_t*)source_uri, samplerate, overlap_size); 209 if (this_source == NULL) { 210 outmsg ("Could not open input file %s.\n", source_uri); 221 211 exit (1); 222 212 } 223 if (verbose)224 aubio_sndfile_info (file);225 samplerate = aubio_sndfile_samplerate (file);226 if (output_filename != NULL)227 fileout = new_aubio_sndfile_wo (file, output_filename);213 // TODO get actual samplerate 214 //samplerate = aubio_sndfile_samplerate (this_source); 215 if (sink_uri != NULL) { 216 this_sink = new_aubio_sink ((char_t*)sink_uri, samplerate); 217 } 228 218 } 229 219 #ifdef HAVE_LASH … … 246 236 247 237 woodblock = new_fvec (overlap_size); 248 if (output_filename || usejack) { 249 /* dummy assignement to keep egcs happy */ 250 found_wood = (onsetfile = new_aubio_sndfile_ro (onset_filename)) || 251 (onsetfile = new_aubio_sndfile_ro ("sounds/woodblock.aiff")) || 252 (onsetfile = new_aubio_sndfile_ro ("../sounds/woodblock.aiff")); 253 if (onsetfile == NULL) { 254 outmsg ("Could not find woodblock.aiff\n"); 255 exit (1); 256 } 257 } 258 if (onsetfile) { 259 /* read the output sound once */ 260 aubio_sndfile_read_mono (onsetfile, overlap_size, woodblock); 261 } 238 //TODO create woodblock sound 262 239 263 240 ibuf = new_fvec (overlap_size); … … 266 243 } 267 244 268 #else /* HAVE_SNDFILE */269 270 void271 examples_common_init (int argc, char **argv)272 {273 outmsg ("Error, compiled without sndfile, nothing to do for now!\n");274 }275 276 277 #endif /* HAVE_SNDFILE */278 279 280 245 void 281 246 examples_common_del (void) 282 247 { 283 #if HAVE_SNDFILE284 248 del_fvec (ibuf); 285 249 del_fvec (obuf); 286 250 del_fvec (woodblock); 287 #endif288 251 aubio_cleanup (); 289 252 } … … 293 256 #endif 294 257 295 #if HAVE_SNDFILE296 297 258 void 298 259 examples_common_process (aubio_process_func_t process_func, 299 260 aubio_print_func_t print) 300 261 { 262 263 uint_t read = 0; 301 264 if (usejack) { 302 265 … … 321 284 frames = 0; 322 285 323 while ((signed) overlap_size ==324 aubio_sndfile_read_mono (file, overlap_size, ibuf)) {286 do { 287 aubio_source_do (this_source, ibuf, &read); 325 288 process_func (&ibuf->data, &obuf->data, overlap_size); 326 289 print (); 327 if ( output_filename != NULL) {328 aubio_s ndfile_write (fileout, overlap_size, &obuf);290 if (this_sink) { 291 aubio_sink_do (this_sink, obuf, overlap_size); 329 292 } 330 293 frames++; 331 } 294 } while (read == overlap_size); 332 295 333 296 debug ("Processed %d frames of %d samples.\n", frames, buffer_size); 334 297 335 298 flush_process (process_func, print); 336 del_aubio_sndfile (file); 337 338 if (output_filename != NULL) 339 del_aubio_sndfile (fileout); 340 341 } 342 } 343 344 #else /* HAVE_SNDFILE */ 345 346 void 347 examples_common_process (aubio_process_func_t process_func, 348 aubio_print_func_t print) 349 { 350 } 351 352 #endif /* HAVE_SNDFILE */ 299 del_aubio_source (this_source); 300 del_aubio_sink (this_sink); 301 302 } 303 } 353 304 354 305 void -
examples/utils.h
r87b0c03 r5a66677 65 65 void send_noteon (int pitch, int velo); 66 66 67 extern const char * output_filename;67 extern const char *sink_uri; 68 68 extern char_t * onset_mode; 69 69 extern smpl_t threshold;
Note: See TracChangeset
for help on using the changeset viewer.