Changeset 5a66677


Ignore:
Timestamp:
Feb 10, 2013, 6:14:29 AM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
a8752a8
Parents:
87b0c03
Message:

examples/: use aubio_source and aubio_sink

Location:
examples
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • examples/aubiomfcc.c

    r87b0c03 r5a66677  
    6666     
    6767      uint_t coef_cnt;
    68       if (output_filename == NULL) {
     68      if (sink_uri == NULL) {
    6969        outmsg("%f\t",frames*overlap_size/(float)samplerate);
    7070        for (coef_cnt = 0; coef_cnt < n_coefs; coef_cnt++) {
  • examples/aubiotrack.c

    r87b0c03 r5a66677  
    5757
    5858static void process_print (void) {
    59         if (output_filename == NULL) {
     59        if (sink_uri == NULL) {
    6060                if (istactus) {
    6161                        outmsg("%f\n",((smpl_t)(frames*overlap_size)+(istactus-1.)*overlap_size)/(smpl_t)samplerate);
  • examples/utils.c

    r87b0c03 r5a66677  
    4242
    4343/* 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";
     44const char *sink_uri = NULL;
     45const char *source_uri = NULL;
    4846int frames = 0;
    4947int verbose = 0;
     
    6462
    6563
    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
     64aubio_source_t *this_source = NULL;
     65aubio_sink_t *this_sink = NULL;
    7366
    7467fvec_t *ibuf;
     
    136129    switch (next_option) {
    137130      case 'o':
    138         output_filename = optarg;
     131        sink_uri = optarg;
    139132        break;
    140133      case 'i':
    141         input_filename = optarg;
     134        source_uri = optarg;
    142135        break;
    143136      case 'h':                /* help */
     
    183176  while (next_option != -1);
    184177
    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);
    190183  } else {
    191184#if HAVE_JACK
     
    202195}
    203196
    204 #ifdef HAVE_SNDFILE
    205 
    206197void
    207198examples_common_init (int argc, char **argv)
    208199{
    209200
    210   uint_t found_wood = 0;
    211 
    212   aubio_sndfile_t *onsetfile = NULL;
    213201  /* parse command line arguments */
    214202  parse_args (argc, argv);
     
    216204  if (!usejack) {
    217205    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);
    221211      exit (1);
    222212    }
    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    }
    228218  }
    229219#ifdef HAVE_LASH
     
    246236
    247237  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
    262239
    263240  ibuf = new_fvec (overlap_size);
     
    266243}
    267244
    268 #else /* HAVE_SNDFILE */
    269 
    270 void
    271 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 
    280245void
    281246examples_common_del (void)
    282247{
    283 #if HAVE_SNDFILE
    284248  del_fvec (ibuf);
    285249  del_fvec (obuf);
    286250  del_fvec (woodblock);
    287 #endif
    288251  aubio_cleanup ();
    289252}
     
    293256#endif
    294257
    295 #if HAVE_SNDFILE
    296 
    297258void
    298259examples_common_process (aubio_process_func_t process_func,
    299260    aubio_print_func_t print)
    300261{
     262
     263  uint_t read = 0;
    301264  if (usejack) {
    302265
     
    321284    frames = 0;
    322285
    323     while ((signed) overlap_size ==
    324         aubio_sndfile_read_mono (file, overlap_size, ibuf)) {
     286    do {
     287      aubio_source_do (this_source, ibuf, &read);
    325288      process_func (&ibuf->data, &obuf->data, overlap_size);
    326289      print ();
    327       if (output_filename != NULL) {
    328         aubio_sndfile_write (fileout, overlap_size, &obuf);
     290      if (this_sink) {
     291        aubio_sink_do (this_sink, obuf, overlap_size);
    329292      }
    330293      frames++;
    331     }
     294    } while (read == overlap_size);
    332295
    333296    debug ("Processed %d frames of %d samples.\n", frames, buffer_size);
    334297
    335298    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}
    353304
    354305void
  • examples/utils.h

    r87b0c03 r5a66677  
    6565void send_noteon (int pitch, int velo);
    6666
    67 extern const char *output_filename;
     67extern const char *sink_uri;
    6868extern char_t * onset_mode;
    6969extern smpl_t threshold;
Note: See TracChangeset for help on using the changeset viewer.