Merge branch 'develop' into io
[aubio.git] / tests / src / io / test-source_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
7 int main(){
8 #ifdef HAVE_SNDFILE
9   uint_t samplerate = 44100;
10   uint_t hop_size = 512;
11   uint_t read = hop_size;
12   fvec_t *vec = new_fvec(hop_size);
13   aubio_source_sndfile_t * s = new_aubio_source_sndfile(path, samplerate, hop_size);
14
15   if (!s) return -1;
16
17   while ( read == hop_size ) {
18     aubio_source_sndfile_do(s, vec, &read);
19     if (read == 0) break;
20     fprintf(stdout, "%d [%f, %f, ..., %f]\n", read, vec->data[0], vec->data[1], vec->data[read - 1]);
21   }
22
23   del_aubio_source_sndfile(s);
24 #else
25   fprintf(stderr, "ERR: aubio was not compiled with aubio_source_sndfile\n");
26 #endif /* HAVE_SNDFILE */
27   return 0;
28 }
29