FFTW 3.01 and C++

Digital Signal Processing using computers.

FFTW 3.01 and C++

Postby Guffer » Mon Dec 26, 2005 5:15 pm

Hi,

I hope this is not off topic!

I'm trying to make use of the FFTW library (V3.01) but I have som
difficulties working out the data types which comes with the library - an
possibly the coding too! Below I have pasted in my current source cod
which should calculate the FFT of real input data. The input is a sinusoi
signal and I'm looking for non-zero data in the output vector but all I ge
is zeros. I'm fairly green in terms of c++ programming so there might b
some really basic problems with my code. Furthermore, I'm not really sur
how to extract data from the output vector (a vector of the fftw_complex
Does anyone know how to do this?

Cheers
Thomas

// FFT specific

int N = 256;

// Input test signal

double input[256];

char txt[256];

for(int indx=0; indx<256; indx++)

{

input[indx]=cos(2.f*22.f/7.f*1000.f*(indx/20000.f));

sprintf(txt,"sample[%d]= %f",indx,input[indx]);

OutputDebugString(txt);

}


double *in;

fftw_complex *out;

fftw_plan p;


in = (double *)fftw_malloc(sizeof(double) * N);

out = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * N);

p = fftw_plan_dft_r2c_1d(N, in, out, FFTW_MEASURE);

fftw_execute(p); /* repeat as needed */

fftw_destroy_plan(p);


in = input;

fftw_free(in);

fftw_free(out);

for(int indx=0; indx<256; indx++)

{

sprintf(txt,"re[%d]=%f,& im[%d]=%f", indx, &out[indx][0], indx
&out[indx][1]);

OutputDebugString(txt);

sprintf(txt,"re[%d]=%f,& im[%d]=%f", indx, out[indx][0], indx
out[indx][1]);

OutputDebugString(txt);

}
Guffer
 

Return to DSP

Who is online

Users browsing this forum: No registered users and 0 guests

cron