source: tests/src/io/test-sink_apple_audio-multi.c @ 81b3910

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5
Last change on this file since 81b3910 was 81b3910, checked in by Paul Brossier <piem@piem.org>, 6 years ago

Merge branch 'intel_ipp_pull' of https://github.com/emuell/aubio into emuell-intel_ipp_pull

  • Property mode set to 100644
File size: 2.3 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 to test aubio_sink_apple_audio, please
6// use aubio_sink instead 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] [channels] [hop_size]\n", argv[0]);
18    return err;
19  }
20
21#ifdef HAVE_SINK_APPLE_AUDIO
22  uint_t samplerate = 0;
23  uint_t channels = 0;
24  uint_t hop_size = 512;
25  uint_t n_frames = 0, read = 0;
26
27  char_t *source_path = argv[1];
28  char_t *sink_path = argv[2];
29
30  if ( argc >= 4 ) samplerate = atoi(argv[3]);
31  if ( argc >= 5 ) channels = atoi(argv[4]);
32  if ( argc >= 6 ) hop_size = atoi(argv[5]);
33  if ( argc >= 7 ) {
34    err = 2;
35    PRINT_ERR("too many arguments\n");
36    return err;
37  }
38
39  aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
40  if (!i) { err = 1; goto beach_source; }
41
42  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
43  if (channels == 0 ) channels = aubio_source_get_channels(i);
44
45  fmat_t *mat = new_fmat(channels, hop_size);
46  if (!mat) { err = 1; goto beach_fmat; }
47
48  aubio_sink_apple_audio_t *o = new_aubio_sink_apple_audio(sink_path, 0);
49  if (!o) { err = 1; goto beach_sink; }
50  err = aubio_sink_apple_audio_preset_samplerate(o, samplerate);
51  if (err) { goto beach; }
52  err = aubio_sink_apple_audio_preset_channels(o, channels);
53  if (err) { goto beach; }
54
55  do {
56    aubio_source_do_multi(i, mat, &read);
57    aubio_sink_apple_audio_do_multi(o, mat, read);
58    n_frames += read;
59  } while ( read == hop_size );
60
61  PRINT_MSG("read %d frames at %dHz in %d channels (%d blocks) from %s written to %s\n",
62      n_frames, samplerate, channels, n_frames / hop_size,
63      source_path, sink_path);
64  PRINT_MSG("wrote %s with %dHz in %d channels\n", sink_path,
65      aubio_sink_apple_audio_get_samplerate(o),
66      aubio_sink_apple_audio_get_channels(o) );
67
68beach:
69  del_aubio_sink_apple_audio(o);
70beach_sink:
71  del_fmat(mat);
72beach_fmat:
73  del_aubio_source(i);
74beach_source:
75#else /* HAVE_SINK_APPLE_AUDIO */
76  err = 3;
77  PRINT_ERR("aubio was not compiled with aubio_sink_apple_audio\n");
78#endif /* HAVE_SINK_APPLE_AUDIO */
79
80  aubio_cleanup();
81 
82  return err;
83}
Note: See TracBrowser for help on using the repository browser.