Ignore:
Timestamp:
Mar 3, 2013, 5:47:05 PM (12 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
248da64
Parents:
e230bb4
Message:

tests/src/pitch/: improve examples

File:
1 edited

Legend:

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

    re230bb4 rc71aa44  
    11#include <aubio.h>
    22
    3 int
    4 main ()
     3int main ()
    54{
    6   /* allocate some memory */
    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   fvec_t *in = new_fvec (hop_s);      /* input buffer */
    11   fvec_t *out = new_fvec (1); /* input buffer */
    12   aubio_pitch_t *o =
    13       new_aubio_pitch ("default", win_s, hop_s, samplerate);
    14   uint_t i = 0;
     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 (hop_s); // input buffer
     12  fvec_t *out = new_fvec (1); // output candidates
     13  // create pitch object
     14  aubio_pitch_t *o = new_aubio_pitch ("default", win_s, hop_s, samplerate);
    1515
    16   while (i < 100) {
    17     aubio_pitch_do (o, in, out);
    18     i++;
     16  // 2. do something with it
     17  while (n < 100) {
     18    // get `hop_s` new samples into `input`
     19    // ...
     20    // exectute pitch
     21    aubio_pitch_do (o, input, out);
     22    // do something with output candidates
     23    // ...
     24    n++;
    1925  };
    2026
     27  // 3. clean up memory
    2128  del_aubio_pitch (o);
    2229  del_fvec (out);
    23   del_fvec (in);
     30  del_fvec (input);
    2431  aubio_cleanup ();
    2532
Note: See TracChangeset for help on using the changeset viewer.