feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change
on this file since abd326c was
248da64,
checked in by Paul Brossier <piem@piem.org>, 12 years ago
|
tests/src/io: improve examples
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[2c3d4ca] | 1 | #include <aubio.h> |
---|
[248da64] | 2 | #include "utils_tests.h" |
---|
[2c3d4ca] | 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"); |
---|
| 11 | PRINT_MSG("usage: %s <input_path> <output_path> [samplerate]\n", argv[0]); |
---|
| 12 | return err; |
---|
| 13 | } |
---|
[2c3d4ca] | 14 | |
---|
| 15 | #ifdef HAVE_SNDFILE |
---|
| 16 | uint_t samplerate = 44100; |
---|
| 17 | uint_t hop_size = 512; |
---|
[248da64] | 18 | uint_t n_frames = 0, read = 0; |
---|
| 19 | |
---|
| 20 | char_t *source_path = argv[1]; |
---|
| 21 | char_t *sink_path = argv[2]; |
---|
| 22 | if ( argc == 4 ) samplerate = atoi(argv[3]); |
---|
| 23 | |
---|
[2c3d4ca] | 24 | fvec_t *vec = new_fvec(hop_size); |
---|
| 25 | aubio_source_sndfile_t * i = new_aubio_source_sndfile(path, samplerate, hop_size); |
---|
[248da64] | 26 | if (samplerate == 0 ) samplerate = aubio_source_sndfile_get_samplerate(i); |
---|
[d9ab958] | 27 | aubio_sink_sndfile_t * o = new_aubio_sink_sndfile(outpath, samplerate); |
---|
[2c3d4ca] | 28 | |
---|
[248da64] | 29 | if (!i || !o) { err = 1; goto beach; } |
---|
[2c3d4ca] | 30 | |
---|
[248da64] | 31 | do { |
---|
[2c3d4ca] | 32 | aubio_source_sndfile_do(i, vec, &read); |
---|
[d9ab958] | 33 | aubio_sink_sndfile_do(o, vec, read); |
---|
[248da64] | 34 | n_frames += read; |
---|
| 35 | } while ( read == hop_size ); |
---|
| 36 | |
---|
| 37 | PRINT_MSG("%d frames read from %s\n written to %s at %dHz\n", |
---|
| 38 | n_frames, source_path, sink_path, samplerate); |
---|
[2c3d4ca] | 39 | |
---|
| 40 | beach: |
---|
| 41 | del_aubio_source_sndfile(i); |
---|
| 42 | del_aubio_sink_sndfile(o); |
---|
| 43 | del_fvec(vec); |
---|
| 44 | #else |
---|
[248da64] | 45 | PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n"); |
---|
| 46 | err = 3; |
---|
[2c3d4ca] | 47 | #endif /* HAVE_SNDFILE */ |
---|
| 48 | return err; |
---|
| 49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.