Changeset fc117d0 for examples


Ignore:
Timestamp:
Feb 11, 2013, 11:06:28 AM (12 years ago)
Author:
Paul Brossier <piem@piem.org>
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:
050a8f3
Parents:
5314432 (diff), 88fc249 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge from develop

Location:
examples
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • examples/aubiomfcc.c

    r5314432 rfc117d0  
    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/aubioonset.c

    r5314432 rfc117d0  
    2727
    2828static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
    29   unsigned int i;       /*channels*/
    3029  unsigned int j;       /*frames*/
    3130  for (j=0;j<(unsigned)nframes;j++) {
  • examples/aubiotrack.c

    r5314432 rfc117d0  
    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

    r5314432 rfc117d0  
    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;
     
    6361uint_t samplerate = 44100;
    6462
    65 
    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
     63aubio_source_t *this_source = NULL;
     64aubio_sink_t *this_sink = NULL;
    7365
    7466fvec_t *ibuf;
     
    136128    switch (next_option) {
    137129      case 'o':
    138         output_filename = optarg;
     130        sink_uri = optarg;
    139131        break;
    140132      case 'i':
    141         input_filename = optarg;
     133        source_uri = optarg;
    142134        break;
    143135      case 'h':                /* help */
     
    183175  while (next_option != -1);
    184176
    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);
     177  if (source_uri != NULL) {
     178    debug ("Input file : %s\n", source_uri);
     179  } else if (source_uri != NULL && sink_uri != NULL) {
     180    debug ("Input file : %s\n", source_uri);
     181    debug ("Output file : %s\n", sink_uri);
    190182  } else {
    191183#if HAVE_JACK
     
    193185    usejack = 1;
    194186#else
    195     debug
    196         ("Error: Could not switch to jack mode\n   aubio was compiled without jack support\n");
    197     exit (1);
     187    errmsg("Error: no arguments given (and no available audio input)\n");
     188    usage ( stderr, 1 );
    198189#endif
    199190  }
     
    202193}
    203194
    204 #ifdef HAVE_SNDFILE
    205 
    206195void
    207196examples_common_init (int argc, char **argv)
    208197{
    209198
    210   uint_t found_wood = 0;
    211 
    212   aubio_sndfile_t *onsetfile = NULL;
    213199  /* parse command line arguments */
    214200  parse_args (argc, argv);
     
    216202  if (!usejack) {
    217203    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);
     204    this_source = new_aubio_source ((char_t*)source_uri, 0, overlap_size);
     205    if (this_source == NULL) {
     206      outmsg ("Could not open input file %s.\n", source_uri);
    221207      exit (1);
    222208    }
    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);
     209    samplerate = aubio_source_get_samplerate(this_source);
     210    if (sink_uri != NULL) {
     211      this_sink = new_aubio_sink ((char_t*)sink_uri, samplerate);
     212      if (this_sink == NULL) {
     213        outmsg ("Could not open output file %s.\n", sink_uri);
     214        exit (1);
     215      }
     216    }
    228217  }
    229218#ifdef HAVE_LASH
     
    246235
    247236  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   }
     237  //TODO create woodblock sound
    262238
    263239  ibuf = new_fvec (overlap_size);
     
    266242}
    267243
    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 
    280244void
    281245examples_common_del (void)
    282246{
    283 #if HAVE_SNDFILE
    284247  del_fvec (ibuf);
    285248  del_fvec (obuf);
    286249  del_fvec (woodblock);
    287 #endif
    288250  aubio_cleanup ();
    289251}
     
    293255#endif
    294256
    295 #if HAVE_SNDFILE
    296 
    297257void
    298258examples_common_process (aubio_process_func_t process_func,
    299259    aubio_print_func_t print)
    300260{
     261
     262  uint_t read = 0;
    301263  if (usejack) {
    302264
     
    321283    frames = 0;
    322284
    323     while ((signed) overlap_size ==
    324         aubio_sndfile_read_mono (file, overlap_size, ibuf)) {
     285    do {
     286      aubio_source_do (this_source, ibuf, &read);
    325287      process_func (&ibuf->data, &obuf->data, overlap_size);
    326288      print ();
    327       if (output_filename != NULL) {
    328         aubio_sndfile_write (fileout, overlap_size, &obuf);
     289      if (this_sink) {
     290        aubio_sink_do (this_sink, obuf, overlap_size);
    329291      }
    330292      frames++;
    331     }
     293    } while (read == overlap_size);
    332294
    333295    debug ("Processed %d frames of %d samples.\n", frames, buffer_size);
    334296
    335297    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 */
     298    del_aubio_source (this_source);
     299    del_aubio_sink   (this_sink);
     300
     301  }
     302}
    353303
    354304void
  • examples/utils.h

    r5314432 rfc117d0  
    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;
  • examples/wscript_build

    r5314432 rfc117d0  
    22
    33# build examples
    4 utilsio = ctx.new_task_gen(name = 'utilsio', features = 'c',
    5       includes = '../src',
    6       source = ['utils.c', 'jackio.c'],
    7       uselib = ['LASH', 'JACK'],
    8       target = 'utilsio')
     4utilsio = bld(
     5        name = 'utilsio',
     6        features = 'c',
     7        includes = '../src',
     8        source = ['utils.c', 'jackio.c'],
     9        uselib = ['LASH', 'JACK'],
     10        target = 'utilsio')
    911
    1012# loop over all *.c filenames in examples to build them all
    11 for target_name in ctx.path.ant_glob('*.c', excl = ['utils.c', 'jackio.c']):
    12   ctx.new_task_gen(features = 'c cprogram',
    13       add_objects = 'utilsio',
     13for source_file in ctx.path.ant_glob('*.c', excl = ['utils.c', 'jackio.c']):
     14  bld.program(features = 'c cprogram',
    1415      includes = '../src',
    15       uselib = ['LASH', 'JACK', 'SNDFILE'],
    16       use = 'aubio',
    17       source = target_name,
    18       # program name is filename.c without the .c
    19       target = str(target_name).split('.')[0])
     16      use = ['aubio', 'LASH', 'JACK', 'SNDFILE', 'utilsio'],
     17      source = str(source_file),
     18      target = str(source_file).split('.')[0]
     19    )
Note: See TracChangeset for help on using the changeset viewer.