source: tests/src/io/test-sink.c @ 5d16185

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 5d16185 was b429b68, checked in by Paul Brossier <piem@piem.org>, 12 years ago

tests/src/io/test-sink.c: improve message

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[5d1f716]1#include <aubio.h>
[248da64]2#include "utils_tests.h"
[5d1f716]3
[248da64]4int main (int argc, char **argv)
5{
6  sint_t err = 0;
7
8  if (argc < 3) {
9    err = 2;
10    PRINT_ERR("not enough arguments\n");
11    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate]\n", argv[0]);
12    return err;
13  }
[5d1f716]14
15  uint_t samplerate = 44100;
16  uint_t hop_size = 512;
[248da64]17  uint_t n_frames = 0, read = 0;
18
19  char_t *source_path = argv[1];
20  char_t *sink_path = argv[2];
21  if ( argc == 4 ) samplerate = atoi(argv[3]);
22
[5d1f716]23  fvec_t *vec = new_fvec(hop_size);
[248da64]24  aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
25  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
26  aubio_sink_t *o = new_aubio_sink(sink_path, samplerate);
[5d1f716]27
[248da64]28  if (!i || !o) { err = 1; goto beach; }
[5d1f716]29
[248da64]30  do {
[5d1f716]31    aubio_source_do(i, vec, &read);
32    aubio_sink_do(o, vec, read);
[248da64]33    n_frames += read;
34  } while ( read == hop_size );
35
[b429b68]36  PRINT_MSG("wrote %d frames at %dHz from %s written to %s\n",
37      n_frames, samplerate, source_path, sink_path);
[5d1f716]38
39beach:
40  del_aubio_source(i);
41  del_aubio_sink(o);
42  del_fvec(vec);
43  return err;
44}
Note: See TracBrowser for help on using the repository browser.