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

tests/src/spectral/: improve examples

File:
1 edited

Legend:

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

    r26775a3 r6938a20  
    1 
    21#include <aubio.h>
    32
    4 int main(){
    5         /* allocate some memory */
    6         uint_t win_s      = 8;                       /* window size        */
    7         fvec_t * in       = new_fvec (win_s); /* input buffer       */
    8         cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
    9         fvec_t * out      = new_fvec (win_s); /* output buffer      */
    10         in->data[0] = 1;
    11         in->data[1] = 2;
    12         in->data[2] = 3;
    13         in->data[3] = 4;
    14         in->data[4] = 5;
    15         in->data[5] = 6;
    16         in->data[6] = 5;
    17         in->data[7] = 6;
    18         /* allocate fft and other memory space */
    19         aubio_fft_t * fft = new_aubio_fft(win_s);
    20         /* fill input with some data */
    21         fvec_print(in);
    22         /* execute stft */
    23         aubio_fft_do (fft,in,fftgrain);
    24         cvec_print(fftgrain);
    25         /* execute inverse fourier transform */
    26         aubio_fft_rdo(fft,fftgrain,out);
    27         fvec_print(out);
    28         del_aubio_fft(fft);
    29         del_fvec(in);
    30         del_cvec(fftgrain);
    31         del_fvec(out);
    32         aubio_cleanup();
    33         return 0;
     3int main ()
     4{
     5  uint_t win_s = 8; // window size
     6  fvec_t * in = new_fvec (win_s); // input buffer
     7  cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase
     8  fvec_t * out = new_fvec (win_s); // output buffer
     9  // create fft object
     10  aubio_fft_t * fft = new_aubio_fft(win_s);
     11
     12  // fill input with some data
     13  in->data[0] = 1;
     14  in->data[1] = 2;
     15  in->data[2] = 3;
     16  in->data[3] = 4;
     17  in->data[4] = 5;
     18  in->data[5] = 6;
     19  in->data[6] = 5;
     20  in->data[7] = 6;
     21  fvec_print(in);
     22
     23  // execute stft
     24  aubio_fft_do (fft,in,fftgrain);
     25  cvec_print(fftgrain);
     26
     27  // execute inverse fourier transform
     28  aubio_fft_rdo(fft,fftgrain,out);
     29
     30  // cleam up
     31  fvec_print(out);
     32  del_aubio_fft(fft);
     33  del_fvec(in);
     34  del_cvec(fftgrain);
     35  del_fvec(out);
     36  aubio_cleanup();
     37  return 0;
    3438}
Note: See TracChangeset for help on using the changeset viewer.