FFT and IFFT length

I have some signals that I add to a larger signal where each signal is located in a different frequency domain. Now I am performing an FFT operation on a large signal with FFTW and cutting out specific FFT cells (where the signals are located).

For example: large signal converted by FFT with 1024 points, signal sampling rate fs=200000


I calculate specific bin positions for given start and end frequencies as follows:

tIndex.iStartPos = (int64_t) ((tFreqs.i64fstart) / (mSampleRate / uFFTLen));


and for example I get for the first signal to be cut 16 baskets. Now I am doing the IFFT transformation again with FFTW and returning 16 complex values ​​(because I reserved the vector for 16 bins).

But when I compare the extracted signal to the original weak signal in MATLAB, then I see that the original signal (this is a wav file) contains xxxxx data, and my signal (which I saved as a raw binary) has only 16 complex values.

So how do I get the length of the IFFT operation for the correct conversion? What's wrong here?

EDIT The logic itself is split into 3 programs, each line is in a multi-threaded environment. For this reason, I am posting some pseudocode here:

ReadWavFile(); //returns the signal data and the RIFF/FMT header information
CalculateFFT_using_CUFFTW(); //calculates FFT with user given parameters, like FFT length, polyphase factor, and applies polyphased window to reduce leakage effect
GetFFTData(); //copy/get FFT data from CUDA device
SendDataToSignalDetector(); //detects signals and returns center frequency and bandwith for each sigal
Freq2Index(); // calculates positions with the returned data from the signal detector
AddPaddingZeroToConcreteBins(); // adds zeros till next power of 2
ApplyPolyphaseAndWindow(); //appends the signal itself polyphase-factor times and applies polyphased window


→ Then analyze the data in MATLAB (currently in work).


source to share

2 answers

If you have a real 1024 sample signal, the contribution from the 16 frequency bins of interest can be obtained by multiplying the frequency spectrum by a rectangular window and then by IFFT. This basically amounts to:

  • filling the buffer with zeros before and after the frequency bins of interest
  • copying the frequency cells of interest to the same locations in this buffer
  • if you are using the full size representation (if you are using fftw_plan_dft_1d(..., FFTW_BACKWARD,...

    for the inverse transform), calculating the Hermitian symmetry for the upper half of the spectrum (or simply using the semitransparent spectrum representation and performing the inverse transformation through fftw_plan_dft_c2r_1d


However, you will get better frequency decomposition using specially designed filters instead of just using a rectangular frequency domain window.



The output length FT is equal to the input length. I don't know how you got to 16 bunkers; FT of 1024 inputs is 1024 bins. Now, for real input (not hard), 1024 bins will be mirrored around 512/513, so your FFT library can only return the bottom 512 bins for real input. However, there are over 16 boxes.

You will probably need to fill all 1024 bins when doing IFFT, as it does not usually assume its output will be a real signal. But it's just a matter of reflecting the bottom 512 boxes.



All Articles