I am trying to FFT my complex signal and the output should be real. So I make this code
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "lib\kiss_fftr.c"
int N = 16;
void TestFftReal(const char* title, const kiss_fft_cpx in[N/2+1], kiss_fft_scalar out[N/2+1])
{
kiss_fftr_cfg cfg = kiss_fftr_alloc(N, 1/*is_inverse_fft*/, NULL, NULL);
printf("%s\n", title);
if (cfg != NULL)
{
size_t i;
kiss_fftr(cfg, in, out);
free(cfg);
for (i = 0; i < N; i++)
{
printf("out[%2zu] = %+f ", i, out[i]);
if (i < N/2+1 )
{
printf(" in[%2zu] = %+f, %+f ", i, in[i].r, in[i].i);
}
printf("\n");
}
}
}
int main(void)
{
kiss_fft_cpx In[N/2+1];
kiss_fft_scalar Out[N];
size_t i;
for (i = 0; i < N; i++)
{
In[i].r = In[i].i = 0;
}
TestFftReal("Zeroes (real)", In, Out);
for (i = 0; i < N; i++)
{
In[i].r = 1, In[i].i = 0;
}
TestFftReal("Ones (real)", In, Out);
for (i = 0; i < N; i++)
{
In[i].r = sin(45 * i * (M_PI / 180)), In[i].i =0;
}
TestFftReal("SineWave (real)", In, Out);
return 0;
}
But now I have a problem with the function kiss_fftr(). Should I use kiss_fft() ? The error says that in or out isn't the correct type, but on Git-Hub it says it should go so. https://github.com/berndporr/kiss-fft