Ignore:
File:
1 edited

Legend:

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

    r248da64 r301b807  
     1#include <stdio.h>
    12#include <aubio.h>
    2 #include "utils_tests.h"
    33
    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;
     4char_t *path = "/Users/piem/archives/sounds/loops/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav";
     5//char_t *path = "/Users/piem/Downloads/Keziah Jones - Where's Life.mp3";
     6
     7int main(){
     8  uint_t samplerate = 32000;
     9  uint_t hop_size = 1024;
     10  uint_t read = hop_size;
     11  fvec_t *vec = new_fvec(hop_size);
     12  aubio_source_t* s = new_aubio_source(path, samplerate, hop_size);
     13
     14  if (!s) return -1;
     15
     16  while ( read == hop_size ) {
     17    aubio_source_do(s, vec, &read);
     18    fprintf(stdout, "%d [%f, %f, ..., %f]\n", read, vec->data[0], vec->data[1], vec->data[read - 1]);
    1219  }
    1320
    14   uint_t samplerate = 32000;
    15   uint_t hop_size = 256;
    16   uint_t n_frames = 0, read = 0;
    17   if ( argc == 3 ) samplerate = atoi(argv[2]);
     21  del_aubio_source(s);
    1822
    19   char_t *source_path = argv[1];
     23  return 0;
     24}
    2025
    21   fvec_t *vec = new_fvec(hop_size);
    22   aubio_source_t* s = new_aubio_source(source_path, samplerate, hop_size);
    23   if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(s);
    24 
    25   if (!s) { err = 1; goto beach; }
    26 
    27   do {
    28     aubio_source_do(s, vec, &read);
    29     // fvec_print (vec);
    30     n_frames += read;
    31   } while ( read == hop_size );
    32 
    33 beach:
    34   del_aubio_source (s);
    35   del_fvec (vec);
    36 
    37   return err;
    38 }
Note: See TracChangeset for help on using the changeset viewer.