source: tests/src/synth/test-wavetable.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#include <aubio.h>
2#include "utils_tests.h"
3
4int main (int argc, char **argv)
5{
6  aubio_init();
7 
8  sint_t err = 0;
9
10  if (argc < 2) {
11    err = 2;
12    PRINT_ERR("not enough arguments\n");
13    PRINT_MSG("usage: %s <output_path> [freq] [samplerate]\n", argv[0]);
14    return err;
15  }
16
17  uint_t samplerate = 44100; // default is the samplerate of input_path
18  uint_t hop_size = 256;
19  smpl_t freq = 440.;
20
21  char_t *sink_path = argv[1];
22  if ( argc == 4 ) samplerate = atoi(argv[3]);
23  if ( argc == 3 ) freq = atof(argv[2]);
24
25  fvec_t *vec = new_fvec(hop_size);
26  aubio_sink_t *sink = new_aubio_sink(sink_path, samplerate);
27
28  aubio_wavetable_t * wavetable = new_aubio_wavetable (samplerate, hop_size);
29
30  // 2 seconds duration, in samples
31  uint_t duration = 2 * samplerate;
32
33  uint_t n_frames = 0;
34  uint_t write = 0;
35
36  aubio_wavetable_play (wavetable);
37  aubio_wavetable_set_freq ( wavetable, freq );
38
39  uint_t region = 0;
40
41  do {
42    if ( n_frames > duration / 3 && region < 1) {
43      aubio_wavetable_stop (wavetable);
44      region++;
45    }
46    if ( n_frames > 2 * duration / 3 && region < 2) {
47      aubio_wavetable_play (wavetable);
48      aubio_wavetable_set_freq ( wavetable, freq  / 2.);
49      region++;
50    }
51    if (duration - n_frames < hop_size * 2 ) {
52      aubio_wavetable_stop( wavetable );
53    }
54    if (duration - n_frames < hop_size ) {
55      write = duration - n_frames;
56    } else {
57      write = hop_size;
58    }
59    aubio_wavetable_do (wavetable, vec, vec);
60    aubio_sink_do(sink, vec, write);
61    n_frames += hop_size;
62  } while ( n_frames <= duration );
63
64  del_aubio_wavetable (wavetable);
65  del_aubio_sink(sink);
66  del_fvec(vec);
67 
68  aubio_cleanup();
69
70  return 0;
71}
Note: See TracBrowser for help on using the repository browser.