source: examples/tests/test-fft.c @ 28d8c4a

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 28d8c4a was 28d8c4a, checked in by Paul Brossier <piem@altern.org>, 19 years ago

prefix mathutils function with aubio_

  • Property mode set to 100644
File size: 1.8 KB
Line 
1
2#include "aubio_priv.h"
3#include "aubio.h"
4
5int main(){
6        uint_t i,j;
7        /* allocate some memory */
8        uint_t win_s      = 1024;                       /* window size */
9        uint_t channels   = 1;                          /* number of channel */
10        fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
11        cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
12        fvec_t * out      = new_fvec (win_s, channels); /* output buffer */
13 
14        /* allocate fft and other memory space */
15        aubio_fft_t * fft      = new_aubio_fft(win_s);              /* fftw interface */
16        smpl_t * w             = AUBIO_ARRAY(smpl_t,win_s);         /* window */
17        /* complex spectral data */
18        fft_data_t ** spec      = AUBIO_ARRAY(fft_data_t*,channels); 
19        for (i=0; i < channels; i++)
20                spec[i] = AUBIO_ARRAY(fft_data_t,win_s);
21        /* initialize the window (see mathutils.c) */
22        aubio_window(w,win_s,aubio_win_hanningz);
23 
24        /* fill input with some data */
25 
26        /* execute stft */
27        for (i=0; i < channels; i++) {
28                aubio_fft_do (fft,in->data[i],spec[i],win_s);
29                /* put norm and phase into fftgrain */
30                aubio_fft_getnorm(fftgrain->norm[i], spec[i], win_s/2+1);
31                aubio_fft_getphas(fftgrain->phas[i], spec[i], win_s/2+1);
32        }
33 
34        /* execute inverse fourier transform */
35        for (i=0; i < channels; i++) {
36                for (j=0; j<win_s/2+1; j++) {
37                        spec[i][j]  = CEXPC(I*aubio_unwrap2pi(fftgrain->phas[i][j]));
38                        spec[i][j] *= fftgrain->norm[i][j];
39                }
40                aubio_fft_rdo(fft,spec[i],out->data[i],win_s);
41        }
42        return 0;
43}
Note: See TracBrowser for help on using the repository browser.