source: tests/src/io/test-sink_sndfile.c @ 986131d

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5
Last change on this file since 986131d was 986131d, checked in by Eduard Müller <mueller.eduard@googlemail.com>, 7 years ago

Intel IPP support for aubio

See emuell/aubio/ intel_ipp2 for details please

  • Property mode set to 100644
File size: 1.7 KB
Line 
1#define AUBIO_UNSTABLE 1
2#include <aubio.h>
3#include "utils_tests.h"
4
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
8int main (int argc, char **argv)
9{
10  aubio_init();
11
12  sint_t err = 0;
13
14  if (argc < 3) {
15    err = 2;
16    PRINT_ERR("not enough arguments\n");
17    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
18    return err;
19  }
20
21#ifdef HAVE_SNDFILE
22  uint_t samplerate = 0;
23  uint_t hop_size = 512;
24  uint_t n_frames = 0, read = 0;
25
26  char_t *source_path = argv[1];
27  char_t *sink_path = argv[2];
28
29  if ( argc >= 4 ) samplerate = atoi(argv[3]);
30  if ( argc >= 5 ) hop_size = atoi(argv[4]);
31  if ( argc >= 6 ) {
32    err = 2;
33    PRINT_ERR("too many arguments\n");
34    return err;
35  }
36
37  fvec_t *vec = new_fvec(hop_size);
38  if (!vec) { err = 1; goto beach_fvec; }
39
40  aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
41  if (!i) { err = 1; goto beach_source; }
42
43  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
44
45  aubio_sink_sndfile_t *o = new_aubio_sink_sndfile(sink_path, samplerate);
46  if (!o) { err = 1; goto beach_sink; }
47
48  do {
49    aubio_source_do(i, vec, &read);
50    aubio_sink_sndfile_do(o, vec, read);
51    n_frames += read;
52  } while ( read == hop_size );
53
54  PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n",
55      n_frames, samplerate, n_frames / hop_size,
56      source_path, sink_path);
57
58  del_aubio_sink_sndfile(o);
59beach_sink:
60  del_aubio_source(i);
61beach_source:
62  del_fvec(vec);
63beach_fvec:
64#else
65  err = 3;
66  PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n");
67#endif /* HAVE_SNDFILE */
68
69  aubio_cleanup();
70 
71  return err;
72}
Note: See TracBrowser for help on using the repository browser.