-
Notifications
You must be signed in to change notification settings - Fork 0
Usage
clemenscorny edited this page Jan 21, 2013
·
1 revision
The following code shows an "easy to try" example.
/* main.c */
#include "lfft.h"
#include <stdio.h>
int main(int argc, char** argv)
{
uint16_t i;
uint16_t samples = 8;
lfft_Fft fft;
if(!lfft_fft_new(&fft, samples))
{
int32_t data[] = {1, 1, 0, 0, 0, 0, 0, 0};
lfft_fft(&fft, data);
for(i = 0; i < fft.samples; i++)
{
printf("real[%d]: %f imag[%d]: %f\n", i, lfft_fft_result_real_float_at(&fft, i), i, lfft_fft_result_imag_float_at(&fft, i));
}
lfft_fft_delete(&fft);
}
else
{
perror("Samples isn't to the power of two\n");
return -1;
}
return 0;
}
The expected output is:
real[0]: 2.000000 imag[0]: 0.000000
real[1]: 1.707031 imag[1]: -0.707031
real[2]: 1.000000 imag[2]: -1.000000
real[3]: 0.292969 imag[3]: -0.707031
real[4]: 0.000000 imag[4]: 0.000000
real[5]: 0.292969 imag[5]: 0.707031
real[6]: 1.000000 imag[6]: 1.000000
real[7]: 1.707031 imag[7]: 0.707031