Ignore:
File:
1 edited

Legend:

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

    r248da64 rd9ab958  
     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   sint_t err = 0;
     5char_t *path = "/home/piem/archives/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav";
     6char_t *outpath = "/var/tmp/test.wav";
    77
    8   if (argc < 3) {
    9     err = 2;
    10     PRINT_ERR("not enough arguments\n");
    11     PRINT_MSG("usage: %s <input_path> <output_path> [samplerate]\n", argv[0]);
    12     return err;
    13   }
    14 
     8int main(){
     9  int err = 0;
    1510#ifdef HAVE_SNDFILE
    1611  uint_t samplerate = 44100;
    1712  uint_t hop_size = 512;
    18   uint_t n_frames = 0, read = 0;
    19 
    20   char_t *source_path = argv[1];
    21   char_t *sink_path = argv[2];
    22   if ( argc == 4 ) samplerate = atoi(argv[3]);
    23 
     13  uint_t read = hop_size;
    2414  fvec_t *vec = new_fvec(hop_size);
    2515  aubio_source_sndfile_t * i = new_aubio_source_sndfile(path, samplerate, hop_size);
    26   if (samplerate == 0 ) samplerate = aubio_source_sndfile_get_samplerate(i);
    2716  aubio_sink_sndfile_t *   o = new_aubio_sink_sndfile(outpath, samplerate);
    2817
    29   if (!i || !o) { err = 1; goto beach; }
     18  if (!i || !o) { err = -1; goto beach; }
    3019
    31   do {
     20  while ( read == hop_size ) {
    3221    aubio_source_sndfile_do(i, vec, &read);
    3322    aubio_sink_sndfile_do(o, vec, read);
    34     n_frames += read;
    35   } while ( read == hop_size );
    36 
    37   PRINT_MSG("%d frames read from %s\n written to %s at %dHz\n",
    38       n_frames, source_path, sink_path, samplerate);
     23  }
    3924
    4025beach:
     
    4328  del_fvec(vec);
    4429#else
    45   PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n");
    46   err = 3;
     30  fprintf(stderr, "ERR: aubio was not compiled with aubio_source_sndfile\n");
    4731#endif /* HAVE_SNDFILE */
    4832  return err;
    4933}
     34
Note: See TracChangeset for help on using the changeset viewer.