Ignore:
Timestamp:
Mar 3, 2013, 7:37:43 PM (11 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:
9547247
Parents:
26775a3
Message:

tests/src/spectral/: improve examples

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/src/spectral/test-phasevoc.c

    r26775a3 r6938a20  
    1 /* test sample for phase vocoder */
    2 
    3 #include <stdio.h>
    41#include <aubio.h>
    52
    6 int main(){
    7         uint_t win_s    = 1024; /* window size                       */
    8         uint_t hop_s    = 256;  /* hop size                          */
    9         /* allocate some memory */
    10         fvec_t * in       = new_fvec (hop_s); /* input buffer       */
    11         cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
    12         fvec_t * out      = new_fvec (hop_s); /* output buffer      */
    13         /* allocate fft and other memory space */
    14         aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s);
    15         /* fill input with some data */
    16         printf("initialised\n");
    17         /* execute stft */
    18         aubio_pvoc_do (pv,in,fftgrain);
    19         printf("computed forward\n");
    20         /* execute inverse fourier transform */
    21         aubio_pvoc_rdo(pv,fftgrain,out);
    22         printf("computed backard\n");
    23         del_aubio_pvoc(pv);
    24         del_fvec(in);
    25         del_cvec(fftgrain);
    26         del_fvec(out);
    27         aubio_cleanup();
    28         printf("memory freed\n");
    29         return 0;
     3int main ()
     4{
     5  uint_t n = 6; // compute n times
     6  uint_t win_s = 32; // window size
     7  uint_t hop_s = win_s / 4; // hop size
     8
     9  fvec_t * in = new_fvec (hop_s); // input buffer
     10  cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase
     11  fvec_t * out = new_fvec (hop_s); // output buffer
     12
     13  // allocate fft and other memory space
     14  aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s);
     15
     16  // fill input with some data
     17  fvec_set (in, 1.);
     18  fvec_print (in);
     19
     20  while ( n-- ) {
     21    // get some fresh input data
     22    // ..
     23
     24    // execute phase vocoder
     25    aubio_pvoc_do (pv,in,fftgrain);
     26
     27    // do something with fftgrain
     28    // ...
     29    cvec_print (fftgrain);
     30
     31    // optionnaly rebuild the signa
     32    aubio_pvoc_rdo(pv,fftgrain,out);
     33
     34    // and do something with the result
     35    // ...
     36    fvec_print (out);
     37  }
     38
     39  // clean up
     40  del_fvec(in);
     41  del_cvec(fftgrain);
     42  del_fvec(out);
     43  del_aubio_pvoc(pv);
     44  aubio_cleanup();
     45
     46  return 0;
    3047}
Note: See TracChangeset for help on using the changeset viewer.