tests/src/onset/: improve examples
[aubio.git] / tests / src / onset / test-onset.c
1 #include <aubio.h>
2
3 int main ()
4 {
5   // 1. allocate some memory
6   uint_t n = 0; // frame counter
7   uint_t win_s = 1024; // window size
8   uint_t hop_s = win_s / 4; // hop size
9   uint_t samplerate = 44100; // samplerate
10   // create some vectors
11   fvec_t * input = new_fvec (win_s/4); // input buffer
12   fvec_t * out = new_fvec (2); // input buffer
13   // create onset object
14   aubio_onset_t * onset = new_aubio_onset("complex", win_s, hop_s, samplerate);
15
16   // 2. do something with it
17   while (n < 10) {
18     // get `hop_s` new samples into `input`
19     // ...
20     // exectute onset detection
21     aubio_onset_do (onset, input, out);
22     // do something with output candidates
23     // ...
24     n++;
25   };
26
27   // 3. clean up memory
28   del_aubio_onset(onset);
29   del_fvec(input);
30   del_fvec(out);
31   aubio_cleanup();
32
33   return 0;
34 }