feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change
on this file since d45f527 was
9f68f11,
checked in by Paul Brossier <piem@piem.org>, 11 years ago
|
tests/src/io/test-sink*: improve, unify
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[5d1f716] | 1 | #include <aubio.h> |
---|
[248da64] | 2 | #include "utils_tests.h" |
---|
[5d1f716] | 3 | |
---|
[248da64] | 4 | int main (int argc, char **argv) |
---|
| 5 | { |
---|
| 6 | sint_t err = 0; |
---|
| 7 | |
---|
| 8 | if (argc < 3) { |
---|
| 9 | err = 2; |
---|
| 10 | PRINT_ERR("not enough arguments\n"); |
---|
[d67a08e] | 11 | PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]); |
---|
[248da64] | 12 | return err; |
---|
| 13 | } |
---|
[5d1f716] | 14 | |
---|
[9f68f11] | 15 | uint_t samplerate = 0; |
---|
| 16 | uint_t hop_size = 512; |
---|
| 17 | uint_t n_frames = 0, read = 0; |
---|
| 18 | |
---|
[248da64] | 19 | char_t *source_path = argv[1]; |
---|
| 20 | char_t *sink_path = argv[2]; |
---|
[d67a08e] | 21 | |
---|
| 22 | if ( argc >= 4 ) samplerate = atoi(argv[3]); |
---|
| 23 | if ( argc >= 5 ) hop_size = atoi(argv[4]); |
---|
| 24 | if ( argc >= 6 ) { |
---|
| 25 | err = 2; |
---|
| 26 | PRINT_ERR("too many arguments\n"); |
---|
| 27 | return err; |
---|
| 28 | } |
---|
[248da64] | 29 | |
---|
[5d1f716] | 30 | fvec_t *vec = new_fvec(hop_size); |
---|
[d67a08e] | 31 | if (!vec) { err = 1; goto beach_fvec; } |
---|
| 32 | |
---|
[248da64] | 33 | aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); |
---|
[d67a08e] | 34 | if (!i) { err = 1; goto beach_source; } |
---|
| 35 | |
---|
[248da64] | 36 | if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); |
---|
[d67a08e] | 37 | |
---|
[248da64] | 38 | aubio_sink_t *o = new_aubio_sink(sink_path, samplerate); |
---|
[d67a08e] | 39 | if (!o) { err = 1; goto beach_sink; } |
---|
[5d1f716] | 40 | |
---|
[248da64] | 41 | do { |
---|
[5d1f716] | 42 | aubio_source_do(i, vec, &read); |
---|
| 43 | aubio_sink_do(o, vec, read); |
---|
[248da64] | 44 | n_frames += read; |
---|
| 45 | } while ( read == hop_size ); |
---|
| 46 | |
---|
[d67a08e] | 47 | PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n", |
---|
| 48 | n_frames, samplerate, n_frames / hop_size, |
---|
| 49 | source_path, sink_path); |
---|
[5d1f716] | 50 | |
---|
| 51 | del_aubio_sink(o); |
---|
[d67a08e] | 52 | beach_sink: |
---|
| 53 | del_aubio_source(i); |
---|
| 54 | beach_source: |
---|
[5d1f716] | 55 | del_fvec(vec); |
---|
[d67a08e] | 56 | beach_fvec: |
---|
[5d1f716] | 57 | return err; |
---|
| 58 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.