Merge branch 'develop' into io
[aubio.git] / tests / src / io / test-sink_sndfile.c
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   fvec_t *vec = new_fvec(hop_size);
15   aubio_source_sndfile_t * i = new_aubio_source_sndfile(path, samplerate, hop_size);
16   aubio_sink_sndfile_t *   o = new_aubio_sink_sndfile(outpath, samplerate);
17
18   if (!i || !o) { err = -1; goto beach; }
19
20   while ( read == hop_size ) {
21     aubio_source_sndfile_do(i, vec, &read);
22     aubio_sink_sndfile_do(o, vec, read);
23   }
24
25 beach:
26   del_aubio_source_sndfile(i);
27   del_aubio_sink_sndfile(o);
28   del_fvec(vec);
29 #else
30   fprintf(stderr, "ERR: aubio was not compiled with aubio_source_sndfile\n");
31 #endif /* HAVE_SNDFILE */
32   return err;
33 }
34