feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change
on this file since 3a6aa799 was
2c3d4ca,
checked in by Paul Brossier <piem@piem.org>, 12 years ago
|
added sink_sndfile.c draft
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[2c3d4ca] | 1 | #include <stdio.h> |
---|
| 2 | #include <aubio.h> |
---|
| 3 | #include "config.h" |
---|
| 4 | |
---|
| 5 | char_t *path = "/home/piem/archives/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav"; |
---|
| 6 | char_t *outpath = "/var/tmp/test.wav"; |
---|
| 7 | |
---|
| 8 | int main(){ |
---|
| 9 | int err = 0; |
---|
| 10 | #ifdef HAVE_SNDFILE |
---|
| 11 | uint_t samplerate = 44100; |
---|
| 12 | uint_t hop_size = 512; |
---|
| 13 | uint_t read = hop_size; |
---|
| 14 | uint_t written = 512; |
---|
| 15 | fvec_t *vec = new_fvec(hop_size); |
---|
| 16 | aubio_source_sndfile_t * i = new_aubio_source_sndfile(path, samplerate, hop_size); |
---|
| 17 | aubio_sink_sndfile_t * o = new_aubio_sink_sndfile(outpath, samplerate, hop_size); |
---|
| 18 | |
---|
| 19 | if (!i || !o) { err = -1; goto beach; } |
---|
| 20 | |
---|
| 21 | while ( read == hop_size ) { |
---|
| 22 | aubio_source_sndfile_do(i, vec, &read); |
---|
| 23 | if (read == 0) break; |
---|
| 24 | written = read; |
---|
| 25 | aubio_sink_sndfile_do(o, vec, &written); |
---|
| 26 | if (read != written) |
---|
| 27 | fprintf(stderr, "ERR: read %d, but wrote %d\n", read, written); |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | beach: |
---|
| 31 | del_aubio_source_sndfile(i); |
---|
| 32 | del_aubio_sink_sndfile(o); |
---|
| 33 | del_fvec(vec); |
---|
| 34 | #else |
---|
| 35 | fprintf(stderr, "ERR: aubio was not compiled with aubio_source_sndfile\n"); |
---|
| 36 | #endif /* HAVE_SNDFILE */ |
---|
| 37 | return err; |
---|
| 38 | } |
---|
| 39 | |
---|
Note: See
TracBrowser
for help on using the repository browser.