[80b5bbd] | 1 | #define AUBIO_UNSTABLE 1 |
---|
| 2 | #include <aubio.h> |
---|
| 3 | #include "utils_tests.h" |
---|
| 4 | |
---|
| 5 | int main (int argc, char **argv) |
---|
| 6 | { |
---|
| 7 | sint_t err = 0; |
---|
| 8 | |
---|
[d5f538f] | 9 | if (argc < 4) { |
---|
[80b5bbd] | 10 | err = 2; |
---|
| 11 | PRINT_ERR("not enough arguments\n"); |
---|
[4ac4ebc] | 12 | PRINT_MSG("usage: %s <input_path> <output_path> <transpose> [mode] " |
---|
| 13 | "[hop_size] [samplerate]\n", argv[0]); |
---|
[d5f538f] | 14 | PRINT_MSG(" with <transpose> a number of semi tones in the range [-24, 24]\n"); |
---|
[6e6849d] | 15 | PRINT_MSG(" and [mode] in 'default', 'crispness:0', ..., 'crispness:6'\n"); |
---|
[80b5bbd] | 16 | return err; |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | uint_t samplerate = 0; |
---|
[9953f09] | 20 | uint_t hop_size = 64; |
---|
[d5f538f] | 21 | smpl_t transpose = 0.; |
---|
[80b5bbd] | 22 | uint_t n_frames = 0, read = 0; |
---|
| 23 | |
---|
| 24 | char_t *source_path = argv[1]; |
---|
| 25 | char_t *sink_path = argv[2]; |
---|
[6e6849d] | 26 | char_t *mode = "default"; |
---|
[80b5bbd] | 27 | |
---|
[d5f538f] | 28 | transpose = atof(argv[3]); |
---|
| 29 | |
---|
[6e6849d] | 30 | if ( argc >= 5 ) mode = argv[4]; |
---|
[d5f538f] | 31 | if ( argc >= 6 ) hop_size = atoi(argv[5]); |
---|
[6e6849d] | 32 | if ( argc >= 7 ) samplerate = atoi(argv[6]); |
---|
| 33 | if ( argc >= 8 ) { |
---|
[80b5bbd] | 34 | err = 2; |
---|
| 35 | PRINT_ERR("too many arguments\n"); |
---|
| 36 | return err; |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | fvec_t *vec = new_fvec(hop_size); |
---|
| 40 | fvec_t *out = new_fvec(hop_size); |
---|
| 41 | if (!vec) { err = 1; goto beach_fvec; } |
---|
| 42 | |
---|
| 43 | aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); |
---|
| 44 | if (!i) { err = 1; goto beach_source; } |
---|
| 45 | |
---|
| 46 | if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); |
---|
| 47 | |
---|
| 48 | aubio_sink_t *o = new_aubio_sink(sink_path, samplerate); |
---|
| 49 | if (!o) { err = 1; goto beach_sink; } |
---|
| 50 | |
---|
[6e6849d] | 51 | aubio_pitchshift_t *ps = new_aubio_pitchshift(mode, transpose, hop_size, samplerate); |
---|
[d5f538f] | 52 | if (!ps) { err = 1; goto beach_pitchshift; } |
---|
[80b5bbd] | 53 | |
---|
| 54 | do { |
---|
| 55 | aubio_source_do(i, vec, &read); |
---|
[d5f538f] | 56 | //aubio_pitchshift_set_transpose(ps, tranpose); |
---|
[80b5bbd] | 57 | aubio_pitchshift_do(ps, vec, out); |
---|
| 58 | aubio_sink_do(o, out, read); |
---|
| 59 | n_frames += read; |
---|
| 60 | } while ( read == hop_size ); |
---|
| 61 | |
---|
| 62 | PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n", |
---|
| 63 | n_frames, samplerate, n_frames / hop_size, |
---|
| 64 | source_path, sink_path); |
---|
| 65 | |
---|
| 66 | del_aubio_pitchshift(ps); |
---|
[d5f538f] | 67 | beach_pitchshift: |
---|
[80b5bbd] | 68 | del_aubio_sink(o); |
---|
| 69 | beach_sink: |
---|
| 70 | del_aubio_source(i); |
---|
| 71 | beach_source: |
---|
| 72 | del_fvec(vec); |
---|
| 73 | del_fvec(out); |
---|
| 74 | beach_fvec: |
---|
[4ac4ebc] | 75 | aubio_cleanup(); |
---|
[80b5bbd] | 76 | return err; |
---|
| 77 | } |
---|