source: tests/src/effects/test-pitchshift.c @ 283a619a

feature/cnnfeature/crepefeature/pitchshiftfeature/timestretchfix/ffmpeg5
Last change on this file since 283a619a was 5b46bc3, checked in by Paul Brossier <piem@piem.org>, 8 years ago

tests/src/effects/test-pitchshift.c: remove HAVE_RUBBERBAND

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[80b5bbd]1#define AUBIO_UNSTABLE 1
2#include <aubio.h>
3#include "utils_tests.h"
4
5int main (int argc, char **argv)
6{
7  sint_t err = 0;
8
[d5f538f]9  if (argc < 4) {
[80b5bbd]10    err = 2;
11    PRINT_ERR("not enough arguments\n");
[6e6849d]12    PRINT_MSG("usage: %s <input_path> <output_path> <transpose> [mode] [hop_size] [samplerate]\n", argv[0]);
[d5f538f]13    PRINT_MSG(" with <transpose> a number of semi tones in the range [-24, 24]\n");
[6e6849d]14    PRINT_MSG(" and [mode] in 'default', 'crispness:0', ..., 'crispness:6'\n");
[80b5bbd]15    return err;
16  }
17
18  uint_t samplerate = 0;
[9953f09]19  uint_t hop_size = 64;
[d5f538f]20  smpl_t transpose = 0.;
[80b5bbd]21  uint_t n_frames = 0, read = 0;
22
23  char_t *source_path = argv[1];
24  char_t *sink_path = argv[2];
[6e6849d]25  char_t *mode = "default";
[80b5bbd]26
[d5f538f]27  transpose = atof(argv[3]);
28
[6e6849d]29  if ( argc >= 5 ) mode = argv[4];
[d5f538f]30  if ( argc >= 6 ) hop_size = atoi(argv[5]);
[6e6849d]31  if ( argc >= 7 ) samplerate = atoi(argv[6]);
32  if ( argc >= 8 ) {
[80b5bbd]33    err = 2;
34    PRINT_ERR("too many arguments\n");
35    return err;
36  }
37
38  fvec_t *vec = new_fvec(hop_size);
39  fvec_t *out = new_fvec(hop_size);
40  if (!vec) { err = 1; goto beach_fvec; }
41
42  aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
43  if (!i) { err = 1; goto beach_source; }
44
45  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
46
47  aubio_sink_t *o = new_aubio_sink(sink_path, samplerate);
48  if (!o) { err = 1; goto beach_sink; }
49
[6e6849d]50  aubio_pitchshift_t *ps = new_aubio_pitchshift(mode, transpose, hop_size, samplerate);
[d5f538f]51  if (!ps) { err = 1; goto beach_pitchshift; }
[80b5bbd]52
53  do {
54    aubio_source_do(i, vec, &read);
[d5f538f]55    //aubio_pitchshift_set_transpose(ps, tranpose);
[80b5bbd]56    aubio_pitchshift_do(ps, vec, out);
57    aubio_sink_do(o, out, read);
58    n_frames += read;
59  } while ( read == hop_size );
60
61  PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n",
62      n_frames, samplerate, n_frames / hop_size,
63      source_path, sink_path);
64
65  del_aubio_pitchshift(ps);
[d5f538f]66beach_pitchshift:
[80b5bbd]67  del_aubio_sink(o);
68beach_sink:
69  del_aubio_source(i);
70beach_source:
71  del_fvec(vec);
72  del_fvec(out);
73beach_fvec:
74  return err;
75}
Note: See TracBrowser for help on using the repository browser.