Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/src/io/test-source_sndfile.c

    r248da64 r2ea7a10  
     1#include <stdio.h>
    12#include <aubio.h>
    2 #include "utils_tests.h"
     3#include "config.h"
    34
    4 int main (int argc, char **argv)
    5 {
    6   uint_t err = 0;
    7   if (argc < 2) {
    8     err = 2;
    9     PRINT_ERR("not enough arguments\n");
    10     PRINT_MSG("usage: %s <source_path> [samplerate]\n", argv[0]);
    11     return err;
    12   }
     5char_t *path = "/home/piem/archives/samples/loops/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav";
    136
     7int main(){
     8  int err = 0;
    149#ifdef HAVE_SNDFILE
    15   uint_t samplerate = 32000;
    16   uint_t hop_size = 256;
    17   uint_t n_frames = 0, read = 0;
    18   if ( argc == 3 ) samplerate = atoi(argv[2]);
    19 
    20   char_t *source_path = argv[1];
    21 
     10  uint_t samplerate = 8000;
     11  uint_t hop_size = 512;
     12  uint_t read = hop_size;
    2213  fvec_t *vec = new_fvec(hop_size);
    23   aubio_source_sndfile_t * s = new_aubio_source_sndfile(source_path, samplerate, hop_size);
    24   if (samplerate == 0 ) samplerate = aubio_source_sndfile_get_samplerate(s);
     14  aubio_source_sndfile_t * s = new_aubio_source_sndfile(path, samplerate, hop_size);
    2515
    2616  if (!s) { err = 1; goto beach; }
    2717
    28   do {
     18  while ( read == hop_size ) {
    2919    aubio_source_sndfile_do(s, vec, &read);
    30     // fvec_print (vec);
    31     n_frames += read;
    32   } while ( read == hop_size );
     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  }
    3323
    3424beach:
    35   del_aubio_source_sndfile (s);
    36   del_fvec (vec);
     25  del_aubio_source_sndfile(s);
     26  del_fvec(vec);
    3727#else
    38   PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n");
     28  fprintf(stderr, "ERR: aubio was not compiled with aubio_source_sndfile\n");
    3929  err = 2;
    4030#endif /* HAVE_SNDFILE */
    4131  return err;
    4232}
     33
Note: See TracChangeset for help on using the changeset viewer.