source: tests/src/io/test-sink_sndfile.c @ 5c6b264

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

tests/src/io/test-sink_sndfile.c: include config, fix path

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