4

I have some signals which I add up to a larger signal, where each signal is located in a different frequency region. Now, I perform the FFT operation on the big signal with FFTW and cut the concrete FFT bins (where the signals are located) out.

For example: The big signal is FFT transformed with 1024 points, the sample rate of the signal is fs=200000.

I calculate the concrete bin positions for given start and stop frequencies in the following way:

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

and e.g. I get for the first signal to be cut out 16 bins. Now I do the IFFT transformation again with FFTW and get the 16 complex values back (because I reserved the vector for 16 bins).

But when I compare the extracted signal with the original small signal in MATLAB, then I can see that the original signal (is a wav-File) has xxxxx data and my signal (which I saved as raw binary file) has only 16 complex values.

So how do I obtain the length of the IFFT operation to be correctly transformed? What is wrong here?

EDIT The logic itself is split over 3 programs, each line is in a multithreaded environment. For that reason I post here some pseudo-code:

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
CutConcreteBins(position);
AddPaddingZeroToConcreteBins(); // adds zeros till next power of 2
ApplyPolyphaseAndWindow(); //appends the signal itself polyphase-factor times and applies polyphased window
PerformIFFT_using_FFTW();
NormalizeFFTData();
Save2BinaryFile();

-->Then analyse data in MATLAB (is at the moment in work).

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
mbed_dev
  • 1,450
  • 16
  • 33
  • Could you please post your code? This will make your description clearer, and also it might be that the code doesn't correctly follow your description. – buzjwa Apr 30 '15 at 12:22
  • 1
    What wav file do you have with sampling rate of 200000? Crazy. – dmedine Apr 30 '15 at 21:40
  • 2
    The length of the input to the IFFT has to the same length as you want to get out (e.g. 1024, the same length as the data you put into the 1st FFT), not shorter (such as 16 instead of 1024). The input to the IFFT also has to be conjugate symmetric if you want real results. – hotpaw2 May 01 '15 at 10:41

2 Answers2

2

If you have a real signal consisting of 1024 samples, the contribution from the 16 frequency bins of interest could be obtained by multiplying the frequency spectrum by a rectangular window then taking the IFFT. This essentially amounts to:

  1. filling a buffer with zeros before and after the frequency bins of interest
  2. copying the frequency bins of interest at the same locations in that buffer
  3. if using a full-spectrum representation (if you are using fftw_plan_dft_1d(..., FFTW_BACKWARD,... for the inverse transform), computing the Hermitian symmetry for the upper half of the spectrum (or simply use a half-spectrum representation and perform the inverse transform through fftw_plan_dft_c2r_1d).

That said, you would get a better frequency decomposition by using specially designed filters instead of just using a rectangular window in the frequency domain.

SleuthEye
  • 14,379
  • 2
  • 32
  • 61
  • Have I understood it correctly: Create a zero initialized complex buffer (the signals I use, are complex) with the full size FFT length, then copy the concrete bins to the positions like in the original buffer. For windowing I alread use the polyphase filter bank technique(https://casper.berkeley.edu/wiki/The_Polyphase_Filter_Bank_Technique) by user request DPSS or Kaiser – mbed_dev May 01 '15 at 20:45
  • If you have isolated the frequency content of interest (by significantly attenuating the other frequency bins), then there is no need to cut out those bins. The polyphase filter bank with the right parameters could do just that for you. – SleuthEye May 04 '15 at 02:27
1

The output length of the FT is equal to the input length. I don't know how you got to 16 bins; the FT of 1024 inputs is 1024 bins. Now for a real input (not complex) the 1024 bins will be mirrorwise identical around 512/513, so your FFT library may return only the lower 512 bins for a real input. Still, that's more than 16 bins.

You'll probably need to fill all 1024 bins when doing the IFFT, as it generally doesn't assume that its output will become a real signal. But that's just a matter of mirroring the lower 512 bins then.

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • The 16 bins are the concrete bins with I cut/extract from the full sized spectrum, to get the detected signal.. But thanks for the hint with filling up the buffer with the full fft length – mbed_dev May 01 '15 at 20:20