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