[9ffcf83] | 1 | #define AUBIO_UNSTABLE 1 |
---|
[11a1abe] | 2 | #include <aubio.h> |
---|
[248da64] | 3 | #include "utils_tests.h" |
---|
[11a1abe] | 4 | |
---|
[856ceb5] | 5 | // this file uses the unstable aubio api, please use aubio_sink instead |
---|
| 6 | // see src/io/sink.h and tests/src/sink/test-sink.c |
---|
| 7 | |
---|
[248da64] | 8 | int main (int argc, char **argv) |
---|
| 9 | { |
---|
| 10 | sint_t err = 0; |
---|
| 11 | |
---|
| 12 | if (argc < 3) { |
---|
| 13 | err = 2; |
---|
| 14 | PRINT_ERR("not enough arguments\n"); |
---|
[9f68f11] | 15 | PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]); |
---|
[248da64] | 16 | return err; |
---|
| 17 | } |
---|
[11a1abe] | 18 | |
---|
[4a17757] | 19 | #ifdef HAVE_SINK_APPLE_AUDIO |
---|
[d7ac23f] | 20 | uint_t samplerate = 0; |
---|
[11a1abe] | 21 | uint_t hop_size = 512; |
---|
[248da64] | 22 | uint_t n_frames = 0, read = 0; |
---|
| 23 | |
---|
| 24 | char_t *source_path = argv[1]; |
---|
| 25 | char_t *sink_path = argv[2]; |
---|
[9f68f11] | 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 | } |
---|
[248da64] | 34 | |
---|
[11a1abe] | 35 | fvec_t *vec = new_fvec(hop_size); |
---|
[9f68f11] | 36 | if (!vec) { err = 1; goto beach_fvec; } |
---|
| 37 | |
---|
[9e58e78] | 38 | aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); |
---|
[9f68f11] | 39 | if (!i) { err = 1; goto beach_source; } |
---|
| 40 | |
---|
[9e58e78] | 41 | if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); |
---|
[11a1abe] | 42 | |
---|
[9f68f11] | 43 | aubio_sink_apple_audio_t *o = new_aubio_sink_apple_audio(sink_path, samplerate); |
---|
| 44 | if (!o) { err = 1; goto beach_sink; } |
---|
[11a1abe] | 45 | |
---|
[248da64] | 46 | do { |
---|
[9e58e78] | 47 | aubio_source_do(i, vec, &read); |
---|
[11a1abe] | 48 | aubio_sink_apple_audio_do(o, vec, read); |
---|
[248da64] | 49 | n_frames += read; |
---|
| 50 | } while ( read == hop_size ); |
---|
| 51 | |
---|
[9f68f11] | 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); |
---|
[11a1abe] | 55 | |
---|
| 56 | del_aubio_sink_apple_audio(o); |
---|
[9f68f11] | 57 | beach_sink: |
---|
| 58 | del_aubio_source(i); |
---|
| 59 | beach_source: |
---|
[11a1abe] | 60 | del_fvec(vec); |
---|
[9f68f11] | 61 | beach_fvec: |
---|
[4a17757] | 62 | #else /* HAVE_SINK_APPLE_AUDIO */ |
---|
[248da64] | 63 | err = 3; |
---|
[856ceb5] | 64 | PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n"); |
---|
[4a17757] | 65 | #endif /* HAVE_SINK_APPLE_AUDIO */ |
---|
[11a1abe] | 66 | return err; |
---|
| 67 | } |
---|