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-source_apple_audio_file.c

    rc71aa44 r248da64  
    1 #include <stdio.h>
    21#include <aubio.h>
     2#include "utils_tests.h"
    33
    4 char_t *path = "/Users/piem/archives/sounds/loops/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav";
    5 //char_t *path = "/Volumes/moving/moving/photos/gopro2/100GOPRO/GOPR4515.MP4";
    6 
    7 int main(){
    8 #ifdef __APPLE__
    9   uint_t samplerate = 32000;
    10   uint_t hop_size = 1024;
    11   uint_t read = hop_size;
    12   fvec_t *vec = new_fvec(hop_size);
    13   aubio_source_apple_audio_t * s = new_aubio_source_apple_audio(path, samplerate, hop_size);
    14 
    15   if (!s) return -1;
    16 
    17   while ( read == hop_size ) {
    18     aubio_source_apple_audio_do(s, vec, &read);
    19     fprintf(stdout, "%d [%f, %f, ..., %f]\n", read, vec->data[0], vec->data[1], vec->data[read - 1]);
     4int 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;
    2012  }
    2113
    22   del_aubio_source_apple_audio(s);
     14#if __APPLE__
     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
     22  fvec_t *vec = new_fvec(hop_size);
     23  aubio_source_apple_audio_t * s = new_aubio_source_apple_audio(source_path, samplerate, hop_size);
     24  if (samplerate == 0 ) samplerate = aubio_source_apple_audio_get_samplerate(s);
     25
     26  if (!s) { err = 1; goto beach; }
     27
     28  do {
     29    aubio_source_apple_audio_do(s, vec, &read);
     30    // fvec_print (vec);
     31    n_frames += read;
     32  } while ( read == hop_size );
     33
     34beach:
     35  del_aubio_source_apple_audio (s);
     36  del_fvec (vec);
    2337#else
    24   fprintf(stderr, "ERR: aubio was not compiled with aubio_source_apple_audio\n");
     38  err = 3;
     39  PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n");
    2540#endif /* __APPLE__ */
    2641  return 0;
    2742}
    28 
Note: See TracChangeset for help on using the changeset viewer.