source: tests/src/io/test-sink_sndfile.c @ 856ceb5

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

tests/src/io/: add comment about unstable

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[856ceb5]1#define AUBIO_UNSTABLE 1
[2c3d4ca]2#include <aubio.h>
[248da64]3#include "utils_tests.h"
[2c3d4ca]4
[856ceb5]5// this file uses the unstable aubio api, please use aubio_sink instead
6// see src/io/sink.h and tests/src/sink/test-sink.c
7
[248da64]8int main (int argc, char **argv)
9{
10  sint_t err = 0;
11
12  if (argc < 3) {
13    err = 2;
14    PRINT_ERR("not enough arguments\n");
15    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate]\n", argv[0]);
16    return err;
17  }
[2c3d4ca]18
19#ifdef HAVE_SNDFILE
20  uint_t samplerate = 44100;
21  uint_t hop_size = 512;
[248da64]22  uint_t n_frames = 0, read = 0;
23
24  char_t *source_path = argv[1];
25  char_t *sink_path = argv[2];
26  if ( argc == 4 ) samplerate = atoi(argv[3]);
27
[2c3d4ca]28  fvec_t *vec = new_fvec(hop_size);
29  aubio_source_sndfile_t * i = new_aubio_source_sndfile(path, samplerate, hop_size);
[248da64]30  if (samplerate == 0 ) samplerate = aubio_source_sndfile_get_samplerate(i);
[d9ab958]31  aubio_sink_sndfile_t *   o = new_aubio_sink_sndfile(outpath, samplerate);
[2c3d4ca]32
[248da64]33  if (!i || !o) { err = 1; goto beach; }
[2c3d4ca]34
[248da64]35  do {
[2c3d4ca]36    aubio_source_sndfile_do(i, vec, &read);
[d9ab958]37    aubio_sink_sndfile_do(o, vec, read);
[248da64]38    n_frames += read;
39  } while ( read == hop_size );
40
41  PRINT_MSG("%d frames read from %s\n written to %s at %dHz\n",
42      n_frames, source_path, sink_path, samplerate);
[2c3d4ca]43
44beach:
45  del_aubio_source_sndfile(i);
46  del_aubio_sink_sndfile(o);
47  del_fvec(vec);
48#else
[248da64]49  err = 3;
[856ceb5]50  PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n");
[2c3d4ca]51#endif /* HAVE_SNDFILE */
52  return err;
53}
Note: See TracBrowser for help on using the repository browser.