1 #define AUBIO_UNSTABLE 1
4 #include "utils_tests.h"
6 // this file uses the unstable aubio api, please use aubio_sink instead
7 // see src/io/sink.h and tests/src/sink/test-sink.c
9 int main (int argc, char **argv)
15 PRINT_ERR("not enough arguments\n");
16 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
21 uint_t samplerate = 0;
22 uint_t hop_size = 512;
23 uint_t n_frames = 0, read = 0;
25 char_t *source_path = argv[1];
26 char_t *sink_path = argv[2];
28 if ( argc >= 4 ) samplerate = atoi(argv[3]);
29 if ( argc >= 5 ) hop_size = atoi(argv[4]);
32 PRINT_ERR("too many arguments\n");
36 fvec_t *vec = new_fvec(hop_size);
37 if (!vec) { err = 1; goto beach_fvec; }
39 aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
40 if (!i) { err = 1; goto beach_source; }
42 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
44 aubio_sink_sndfile_t *o = new_aubio_sink_sndfile(sink_path, samplerate);
45 if (!o) { err = 1; goto beach_sink; }
48 aubio_source_do(i, vec, &read);
49 aubio_sink_sndfile_do(o, vec, read);
51 } while ( read == hop_size );
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);
57 del_aubio_sink_sndfile(o);
65 PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n");
66 #endif /* HAVE_SNDFILE */