source: tests/src/io/test-source.c @ 26775a3

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 26775a3 was 248da64, checked in by Paul Brossier <piem@piem.org>, 11 years ago

tests/src/io: improve examples

  • Property mode set to 100644
File size: 832 bytes
RevLine 
[301b807]1#include <aubio.h>
[248da64]2#include "utils_tests.h"
[301b807]3
[248da64]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;
12  }
[301b807]13
14  uint_t samplerate = 32000;
[248da64]15  uint_t hop_size = 256;
16  uint_t n_frames = 0, read = 0;
17  if ( argc == 3 ) samplerate = atoi(argv[2]);
18
19  char_t *source_path = argv[1];
20
[301b807]21  fvec_t *vec = new_fvec(hop_size);
[248da64]22  aubio_source_t* s = new_aubio_source(source_path, samplerate, hop_size);
23  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(s);
[301b807]24
[248da64]25  if (!s) { err = 1; goto beach; }
[301b807]26
[248da64]27  do {
[301b807]28    aubio_source_do(s, vec, &read);
[248da64]29    // fvec_print (vec);
30    n_frames += read;
31  } while ( read == hop_size );
[301b807]32
[248da64]33beach:
34  del_aubio_source (s);
35  del_fvec (vec);
[301b807]36
[248da64]37  return err;
[301b807]38}
Note: See TracBrowser for help on using the repository browser.