2 #include "utils_tests.h"
4 // same as test-sink.c, but uses aubio_source_do_multi to read multiple
7 int main (int argc, char **argv)
12 PRINT_ERR("not enough arguments, running tests\n");
13 err = run_on_default_source_and_sink(main);
14 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [channels] [hop_size]\n", argv[0]);
18 uint_t samplerate = 0;
20 uint_t hop_size = 512;
21 uint_t n_frames = 0, read = 0;
23 char_t *source_path = argv[1];
24 char_t *sink_path = argv[2];
26 if ( argc >= 4 ) samplerate = atoi(argv[3]);
27 if ( argc >= 5 ) channels = atoi(argv[4]);
28 if ( argc >= 6 ) hop_size = atoi(argv[5]);
31 PRINT_ERR("too many arguments\n");
35 aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
36 if (!i) { err = 1; goto beach_source; }
38 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
39 if (channels == 0 ) channels = aubio_source_get_channels(i);
41 fmat_t *mat = new_fmat(channels, hop_size);
42 if (!mat) { err = 1; goto beach_fmat; }
44 aubio_sink_t *o = new_aubio_sink(sink_path, 0);
45 if (!o) { err = 1; goto beach_sink; }
46 err = aubio_sink_preset_samplerate(o, samplerate);
47 if (err) { goto beach; }
48 err = aubio_sink_preset_channels(o, channels);
49 if (err) { goto beach; }
52 aubio_source_do_multi(i, mat, &read);
53 aubio_sink_do_multi(o, mat, read);
55 } while ( read == hop_size );
57 PRINT_MSG("read %d frames at %dHz in %d channels (%d blocks) from %s written to %s\n",
58 n_frames, samplerate, channels, n_frames / hop_size,
59 source_path, sink_path);
60 PRINT_MSG("wrote %s with %dHz in %d channels\n", sink_path,
61 aubio_sink_get_samplerate(o),
62 aubio_sink_get_channels(o) );