aubio 0.4.9
spectral/test-fft.c
#include <aubio.h>
int main (void)
{
int return_code = 0;
uint_t i, n_iters = 100; // number of iterations
uint_t win_s = 512; // window size
fvec_t * in = new_fvec (win_s); // input buffer
cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase
fvec_t * out = new_fvec (win_s); // output buffer
// create fft object
aubio_fft_t * fft = new_aubio_fft(win_s);
if (!fft) {
return_code = 1;
goto beach;
}
// fill input with some data
in->data[0] = 1;
in->data[1] = 2;
in->data[2] = 3;
in->data[3] = 4;
in->data[4] = 5;
in->data[5] = 6;
in->data[6] = 5;
in->data[7] = 6;
//fvec_print(in);
for (i = 0; i < n_iters; i++) {
// execute stft
aubio_fft_do (fft,in,fftgrain);
cvec_print(fftgrain);
// execute inverse fourier transform
aubio_fft_rdo(fft,fftgrain,out);
}
// cleam up
//fvec_print(out);
beach:
del_fvec(in);
del_cvec(fftgrain);
del_fvec(out);
return return_code;
}
Global aubio include file.
cvec_t * new_cvec(uint_t length)
cvec_t buffer creation function
void del_cvec(cvec_t *s)
cvec_t buffer deletion function
void cvec_print(const cvec_t *s)
print out cvec data
aubio_fft_t * new_aubio_fft(uint_t size)
create new FFT computation object
void aubio_fft_rdo(aubio_fft_t *s, const cvec_t *spectrum, fvec_t *output)
compute backward (inverse) FFT
void del_aubio_fft(aubio_fft_t *s)
delete FFT object
struct _aubio_fft_t aubio_fft_t
FFT object.
Definition: fft.h:46
void aubio_fft_do(aubio_fft_t *s, const fvec_t *input, cvec_t *spectrum)
compute forward FFT
fvec_t * new_fvec(uint_t length)
fvec_t buffer creation function
void del_fvec(fvec_t *s)
fvec_t buffer deletion function
void aubio_cleanup(void)
clean up cached memory at the end of program
Vector of real-valued phase and spectrum data.
Definition: cvec.h:63
Buffer for real data.
Definition: fvec.h:67
smpl_t * data
data vector of length fvec_t.length
Definition: fvec.h:69
unsigned int uint_t
unsigned integer
Definition: types.h:60