Changeset 9f68f11


Ignore:
Timestamp:
Feb 23, 2014, 3:13:26 AM (11 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:
a559796
Parents:
d7ac23f
Message:

tests/src/io/test-sink*: improve, unify

Location:
tests/src/io
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • tests/src/io/test-sink.c

    rd7ac23f r9f68f11  
    1313  }
    1414
     15  uint_t samplerate = 0;
     16  uint_t hop_size = 512;
     17  uint_t n_frames = 0, read = 0;
     18
    1519  char_t *source_path = argv[1];
    1620  char_t *sink_path = argv[2];
    1721
    18   uint_t samplerate = 0;
    19   uint_t hop_size = 256;
    2022  if ( argc >= 4 ) samplerate = atoi(argv[3]);
    2123  if ( argc >= 5 ) hop_size = atoi(argv[4]);
     
    3739  if (!o) { err = 1; goto beach_sink; }
    3840
    39   uint_t n_frames = 0, read = 0;
    40 
    4141  do {
    4242    aubio_source_do(i, vec, &read);
  • tests/src/io/test-sink_apple_audio.c

    rd7ac23f r9f68f11  
    1313    err = 2;
    1414    PRINT_ERR("not enough arguments\n");
    15     PRINT_MSG("usage: %s <input_path> <output_path> [samplerate]\n", argv[0]);
     15    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    1616    return err;
    1717  }
     
    2424  char_t *source_path = argv[1];
    2525  char_t *sink_path = argv[2];
    26   if ( argc == 4 ) samplerate = atoi(argv[3]);
     26
     27  if ( argc >= 4 ) samplerate = atoi(argv[3]);
     28  if ( argc >= 5 ) hop_size = atoi(argv[4]);
     29  if ( argc >= 6 ) {
     30    err = 2;
     31    PRINT_ERR("too many arguments\n");
     32    return err;
     33  }
    2734
    2835  fvec_t *vec = new_fvec(hop_size);
     36  if (!vec) { err = 1; goto beach_fvec; }
     37
    2938  aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
     39  if (!i) { err = 1; goto beach_source; }
     40
    3041  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
     42
    3143  aubio_sink_apple_audio_t *o = new_aubio_sink_apple_audio(sink_path, samplerate);
    32 
    33   if (!i || !o) { err = 1; goto beach; }
     44  if (!o) { err = 1; goto beach_sink; }
    3445
    3546  do {
     
    3950  } while ( read == hop_size );
    4051
    41   PRINT_MSG("%d frames read from %s\n written to %s at %dHz\n",
    42       n_frames, source_path, sink_path, samplerate);
     52  PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n",
     53      n_frames, samplerate, n_frames / hop_size,
     54      source_path, sink_path);
    4355
    44 beach:
     56  del_aubio_sink_apple_audio(o);
     57beach_sink:
    4558  del_aubio_source(i);
    46   del_aubio_sink_apple_audio(o);
     59beach_source:
    4760  del_fvec(vec);
     61beach_fvec:
    4862#else
    4963  err = 3;
  • tests/src/io/test-sink_sndfile.c

    rd7ac23f r9f68f11  
    1414    err = 2;
    1515    PRINT_ERR("not enough arguments\n");
    16     PRINT_MSG("usage: %s <input_path> <output_path> [samplerate]\n", argv[0]);
     16    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    1717    return err;
    1818  }
     
    2525  char_t *source_path = argv[1];
    2626  char_t *sink_path = argv[2];
    27   if ( argc == 4 ) samplerate = atoi(argv[3]);
     27
     28  if ( argc >= 4 ) samplerate = atoi(argv[3]);
     29  if ( argc >= 5 ) hop_size = atoi(argv[4]);
     30  if ( argc >= 6 ) {
     31    err = 2;
     32    PRINT_ERR("too many arguments\n");
     33    return err;
     34  }
    2835
    2936  fvec_t *vec = new_fvec(hop_size);
    30   aubio_source_sndfile_t * i = new_aubio_source_sndfile(source_path, samplerate, hop_size);
    31   if (samplerate == 0 ) samplerate = aubio_source_sndfile_get_samplerate(i);
    32   aubio_sink_sndfile_t *   o = new_aubio_sink_sndfile(sink_path, samplerate);
     37  if (!vec) { err = 1; goto beach_fvec; }
    3338
    34   if (!i || !o) { err = 1; goto beach; }
     39  aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
     40  if (!i) { err = 1; goto beach_source; }
     41
     42  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
     43
     44  aubio_sink_sndfile_t *o = new_aubio_sink_sndfile(sink_path, samplerate);
     45  if (!o) { err = 1; goto beach_sink; }
    3546
    3647  do {
    37     aubio_source_sndfile_do(i, vec, &read);
     48    aubio_source_do(i, vec, &read);
    3849    aubio_sink_sndfile_do(o, vec, read);
    3950    n_frames += read;
    4051  } while ( read == hop_size );
    4152
    42   PRINT_MSG("%d frames read from %s\n written to %s at %dHz\n",
    43       n_frames, source_path, sink_path, samplerate);
     53  PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n",
     54      n_frames, samplerate, n_frames / hop_size,
     55      source_path, sink_path);
    4456
    45 beach:
    46   del_aubio_source_sndfile(i);
    4757  del_aubio_sink_sndfile(o);
     58beach_sink:
     59  del_aubio_source(i);
     60beach_source:
    4861  del_fvec(vec);
     62beach_fvec:
    4963#else
    5064  err = 3;
  • tests/src/io/test-sink_wavwrite.c

    rd7ac23f r9f68f11  
    1313    err = 2;
    1414    PRINT_ERR("not enough arguments\n");
    15     PRINT_MSG("usage: %s <input_path> <output_path> [samplerate]\n", argv[0]);
     15    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    1616    return err;
    1717  }
     
    2424  char_t *source_path = argv[1];
    2525  char_t *sink_path = argv[2];
    26   if ( argc == 4 ) samplerate = atoi(argv[3]);
     26
     27  if ( argc >= 4 ) samplerate = atoi(argv[3]);
     28  if ( argc >= 5 ) hop_size = atoi(argv[4]);
     29  if ( argc >= 6 ) {
     30    err = 2;
     31    PRINT_ERR("too many arguments\n");
     32    return err;
     33  }
    2734
    2835  fvec_t *vec = new_fvec(hop_size);
     36  if (!vec) { err = 1; goto beach_fvec; }
     37
    2938  aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
     39  if (!i) { err = 1; goto beach_source; }
     40
    3041  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
     42
    3143  aubio_sink_wavwrite_t *o = new_aubio_sink_wavwrite(sink_path, samplerate);
    32 
    33   if (!i || !o) { err = 1; goto beach; }
     44  if (!o) { err = 1; goto beach_sink; }
    3445
    3546  do {
     
    3950  } while ( read == hop_size );
    4051
    41   PRINT_MSG("%d frames read from %s\n written to %s at %dHz\n",
    42       n_frames, source_path, sink_path, samplerate);
     52  PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n",
     53      n_frames, samplerate, n_frames / hop_size,
     54      source_path, sink_path);
    4355
    44 beach:
     56  del_aubio_sink_wavwrite(o);
     57beach_sink:
    4558  del_aubio_source(i);
    46   del_aubio_sink_wavwrite(o);
     59beach_source:
    4760  del_fvec(vec);
     61beach_fvec:
    4862#else
    4963  err = 3;
Note: See TracChangeset for help on using the changeset viewer.