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_apple_audio_file.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 = "/Users/piem/archives/sounds/loops/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#ifdef __APPLE__
    1116  uint_t samplerate = 44100;
    1217  uint_t hop_size = 512;
    13   uint_t read = hop_size;
     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
    1424  fvec_t *vec = new_fvec(hop_size);
    15   aubio_source_apple_audio_t * i = new_aubio_source_apple_audio(path, samplerate, hop_size);
    16   aubio_sink_apple_audio_t *   o = new_aubio_sink_apple_audio(outpath, samplerate);
     25  aubio_source_apple_audio_t *i = new_aubio_source_apple_audio(source_path, samplerate, hop_size);
     26  if (samplerate == 0 ) samplerate = aubio_source_apple_audio_get_samplerate(i);
     27  aubio_sink_apple_audio_t *o = new_aubio_sink_apple_audio(sink_path, samplerate);
    1728
    18   if (!i || !o) { err = -1; goto beach; }
     29  if (!i || !o) { err = 1; goto beach; }
    1930
    20   while ( read == hop_size ) {
     31  do {
    2132    aubio_source_apple_audio_do(i, vec, &read);
    2233    aubio_sink_apple_audio_do(o, vec, read);
    23   }
     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);
    2439
    2540beach:
     
    2843  del_fvec(vec);
    2944#else
    30   fprintf(stderr, "ERR: aubio was not compiled with aubio_source_apple_audio\n");
     45  PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n");
     46  err = 3;
    3147#endif /* __APPLE__ */
    3248  return err;
    3349}
    34 
Note: See TracChangeset for help on using the changeset viewer.