Changeset 26775a3 for tests


Ignore:
Timestamp:
Mar 3, 2013, 7:36:18 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
6938a20
Parents:
248da64
Message:

tests/src/onset/: improve examples

Location:
tests/src/onset
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/src/onset/test-onset.c

    r248da64 r26775a3  
    11#include <aubio.h>
    22
    3 int main(){
    4         /* allocate some memory */
    5         uint_t win_s      = 1024;                       /* window size */
    6         fvec_t * in       = new_fvec (win_s/4); /* input buffer */
    7         fvec_t * out      = new_fvec (2);     /* input buffer */
    8         aubio_onset_t * onset  = new_aubio_onset("complex", win_s, win_s/4, 44100.);
    9         uint_t i = 0;
     3int 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);
    1015
    11         while (i < 10) {
    12           aubio_onset_do (onset,in,out);
    13           i++;
    14         };
     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  };
    1526
    16         del_aubio_onset(onset);
    17         del_fvec(in);
    18         del_fvec(out);
    19         aubio_cleanup();
     27  // 3. clean up memory
     28  del_aubio_onset(onset);
     29  del_fvec(input);
     30  del_fvec(out);
     31  aubio_cleanup();
    2032
    21         return 0;
     33  return 0;
    2234}
  • tests/src/onset/test-peakpicker.c

    r248da64 r26775a3  
    33#include <aubio.h>
    44
    5 int main(){
    6         /* allocate some memory */
    7         uint_t win_s      = 1024;                       /* window size */
    8         fvec_t * in       = new_fvec (win_s); /* input buffer */
    9         fvec_t * out      = new_fvec (1); /* input buffer */
    10         aubio_peakpicker_t * o = new_aubio_peakpicker();
    11         aubio_peakpicker_set_threshold (o, 0.3);
     5int main ()
     6{
     7  uint_t win_s = 1024; // window size
     8  fvec_t * in = new_fvec (win_s); // input buffer
     9  fvec_t * out = new_fvec (1); // input buffer
     10  aubio_peakpicker_t * o = new_aubio_peakpicker();
     11  aubio_peakpicker_set_threshold (o, 0.3);
    1212
    13         aubio_peakpicker_do(o, in, out);
    14         aubio_peakpicker_do(o, in, out);
    15         aubio_peakpicker_do(o, in, out);
    16         aubio_peakpicker_do(o, in, out);
     13  aubio_peakpicker_do(o, in, out);
     14  aubio_peakpicker_do(o, in, out);
     15  aubio_peakpicker_do(o, in, out);
     16  aubio_peakpicker_do(o, in, out);
    1717
    18         del_aubio_peakpicker(o);
    19         del_fvec(out);
    20         del_fvec(in);
    21         return 0;
     18  del_aubio_peakpicker(o);
     19  del_fvec(out);
     20  del_fvec(in);
     21  return 0;
    2222}
    2323
Note: See TracChangeset for help on using the changeset viewer.