tests/src/io/test-source_sndfile.c: test downsampling
[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/samples/loops/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav";
6
7 int main(){
8   int err = 0;
9 #ifdef HAVE_SNDFILE
10   uint_t samplerate = 8000;
11   uint_t hop_size = 512;
12   uint_t read = hop_size;
13   fvec_t *vec = new_fvec(hop_size);
14   aubio_source_sndfile_t * s = new_aubio_source_sndfile(path, samplerate, hop_size);
15
16   if (!s) { err = 1; goto beach; }
17
18   while ( read == hop_size ) {
19     aubio_source_sndfile_do(s, vec, &read);
20     if (read == 0) break;
21     fprintf(stdout, "%d [%f, %f, ..., %f]\n", read, vec->data[0], vec->data[1], vec->data[read - 1]);
22   }
23
24 beach:
25   del_aubio_source_sndfile(s);
26   del_fvec(vec);
27 #else
28   fprintf(stderr, "ERR: aubio was not compiled with aubio_source_sndfile\n");
29   err = 2;
30 #endif /* HAVE_SNDFILE */
31   return err;
32 }
33