Ignore:
Timestamp:
Mar 3, 2013, 7:30:40 PM (11 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
26775a3
Parents:
c71aa44
Message:

tests/src/io: improve examples

File:
1 edited

Legend:

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

    rc71aa44 r248da64  
    1 #include <stdio.h>
    21#include <aubio.h>
    3 #include "config.h"
     2#include "utils_tests.h"
    43
    5 char_t *path = "/home/piem/archives/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav";
    6 char_t *outpath = "/var/tmp/test.wav";
     4int main (int argc, char **argv)
     5{
     6  sint_t err = 0;
    77
    8 int main(){
    9   int err = 0;
     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
    1015  uint_t samplerate = 44100;
    1116  uint_t hop_size = 512;
    12   uint_t read = hop_size;
     17  uint_t n_frames = 0, read = 0;
     18
     19  char_t *source_path = argv[1];
     20  char_t *sink_path = argv[2];
     21  if ( argc == 4 ) samplerate = atoi(argv[3]);
     22
    1323  fvec_t *vec = new_fvec(hop_size);
    14   aubio_source_t * i = new_aubio_source(path, samplerate, hop_size);
    15   aubio_sink_t *   o = new_aubio_sink(outpath, samplerate);
     24  aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
     25  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
     26  aubio_sink_t *o = new_aubio_sink(sink_path, samplerate);
    1627
    17   if (!i || !o) { err = -1; goto beach; }
     28  if (!i || !o) { err = 1; goto beach; }
    1829
    19   while ( read == hop_size ) {
     30  do {
    2031    aubio_source_do(i, vec, &read);
    2132    aubio_sink_do(o, vec, read);
    22   }
     33    n_frames += read;
     34  } while ( read == hop_size );
     35
     36  PRINT_MSG("%d frames read from %s\n written to %s at %dHz\n",
     37      n_frames, source_path, sink_path, samplerate);
    2338
    2439beach:
     
    2843  return err;
    2944}
    30 
Note: See TracChangeset for help on using the changeset viewer.