简体   繁体   English

FFT和IFFT的长度

[英]Length of FFT and IFFT

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. 现在,我使用FFTW对大信号执行FFT运算,并切断具体的FFT分档(信号所在的位置)。

For example: The big signal is FFT transformed with 1024 points, the sample rate of the signal is fs=200000 . 例如:大信号用1024点FFT变换,信号的采样率为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 eg I get for the first signal to be cut out 16 bins. 例如,我得到第一个信号被切掉16个箱子。 Now I do the IFFT transformation again with FFTW and get the 16 complex values back (because I reserved the vector for 16 bins). 现在我再次使用FFTW进行IFFT转换并获得16个复数值(因为我保留了16个二进制数的向量)。

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. 但是当我在MATLAB中将提取的信号与原始的小信号进行比较时,我可以看到原始信号(是一个wav-File)有xxxxx数据而我的信号(我保存为原始二进制文件)只有16个复数值。

So how do I obtain the length of the IFFT operation to be correctly transformed? 那么如何获得正确转换的IFFT操作的长度呢? What is wrong here? 这有什么不对?

EDIT The logic itself is split over 3 programs, each line is in a multithreaded environment. 编辑逻辑本身分为3个程序,每个行都处于多线程环境中。 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). - >然后在MATLAB中分析数据(目前在工作中)。

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. 如果您有一个由1024个样本组成的实信号,则可以通过将频谱乘以矩形窗口然后采用IFFT来获得16个感兴趣频率区间的贡献。 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 ). 如果使用全谱表示(如果你使用fftw_plan_dft_1d(..., FFTW_BACKWARD,...用于逆变换),计算频谱上半部分的Hermitian对称性(或者简单地使用半频谱表示和通过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. 也就是说,通过使用专门设计的滤波器而不是仅使用频域中的矩形窗口,您将获得更好的频率分解。

The output length of the FT is equal to the input length. FT的输出长度等于输入长度。 I don't know how you got to 16 bins; 我不知道你怎么到16箱; the FT of 1024 inputs is 1024 bins. 1024输入的FT是1024个箱。 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. 现在对于一个真正的输入(不复杂),1024个区域将在512/513左右镜像相同,因此您的FFT库可能仅返回实际输入的低512个区间。 Still, that's more than 16 bins. 不过,这还不止16个箱子。

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. 在进行IFFT时,您可能需要填充所有1024个二进制位,因为它通常不会假设其输出将成为真实信号。 But that's just a matter of mirroring the lower 512 bins then. 但那只是反映了较低512个分档的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM