source: tests/src/synth/test-sampler.c @ 5525507

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

tests/src/synth/test-sampler.c: shorter frames, repeat three times

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[22df684]1#include <aubio.h>
2#include "utils_tests.h"
3
4int main (int argc, char **argv)
5{
6  sint_t err = 0;
7
8  if (argc < 4) {
9    err = 2;
10    PRINT_ERR("not enough arguments\n");
11    PRINT_MSG("usage: %s <input_path> <output_path> <sample_path> [samplerate]\n", argv[0]);
12    return err;
13  }
14
15  uint_t samplerate = 0; // default is the samplerate of input_path
[f174a22]16  uint_t hop_size = 256;
[22df684]17  uint_t n_frames = 0, read = 0;
18
19  char_t *source_path = argv[1];
20  char_t *sink_path = argv[2];
21  char_t *sample_path = argv[3];
22  if ( argc == 5 ) samplerate = atoi(argv[4]);
23
24  fvec_t *vec = new_fvec(hop_size);
25  aubio_source_t *source = new_aubio_source(source_path, samplerate, hop_size);
26  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(source);
27  aubio_sink_t *sink = new_aubio_sink(sink_path, samplerate);
28
29  aubio_sampler_t * sampler = new_aubio_sampler (samplerate, hop_size);
30
31  aubio_sampler_load (sampler, sample_path);
32
33  do {
34    aubio_source_do(source, vec, &read);
35    if (n_frames / hop_size == 10) {
36      aubio_sampler_play ( sampler );
37    }
[f174a22]38    if (n_frames / hop_size == 40) {
39      aubio_sampler_play ( sampler );
40    }
41    if (n_frames / hop_size == 70) {
[22df684]42      aubio_sampler_play ( sampler );
43    }
44    if (n_frames > 10.0 * samplerate) {
45      aubio_sampler_stop ( sampler );
46    }
47    aubio_sampler_do (sampler, vec, vec);
48    aubio_sink_do(sink, vec, read);
49    n_frames += read;
50  } while ( read == hop_size );
51
52  del_aubio_sampler(sampler);
53  del_aubio_source(source);
54  del_aubio_sink(sink);
55  del_fvec(vec);
56  aubio_cleanup();
57
58  return 0;
59}
Note: See TracBrowser for help on using the repository browser.