FFT-计算频点之间的准确频率 [英] FFT - Calculating exact frequency between frequency bins

查看:907
本文介绍了FFT-计算频点之间的准确频率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用我在网上找到的一个不错的FFT库看看我是否可以编写一个音高检测程序.到目前为止,我已经能够成功地使该库对包含几个正弦波的测试音频信号进行FFT计算,其中包括一个440Hz的正弦波(我使用16384个样本作为大小,并以44100Hz的采样率进行采样.)

I am using a nice FFT library I found online to see if I can write a pitch-detection program. So far, I have been able to successfully let the library do FFT calculation on a test audio signal containing a few sine waves including one at 440Hz (I'm using 16384 samples as the size and the sample rate at 44100Hz).

FFT输出如下:

433.356Hz - Real: 590.644 - Imag: -27.9856 - MAG: 16529.5
436.047Hz - Real: 683.921 - Imag: 51.2798 - MAG: 35071.4
438.739Hz - Real: 4615.24 - Imag: 1170.8 - MAG: 5.40352e+006
441.431Hz - Real: -3861.97 - Imag: 2111.13 - MAG: 8.15315e+006
444.122Hz - Real: -653.75 - Imag: 341.107 - MAG: 222999
446.814Hz - Real: -564.629 - Imag: 186.592 - MAG: 105355

如您所见,441.431Hz和438.739Hz的仓位都显示同样高的幅度输出("MAG:"之后的最右边的数字),因此很明显,目标频率440Hz介于两者之间.提高分辨率可能是关闭的一种方法,但这会增加计算时间.

As you can see, the 441.431Hz and 438.739Hz bins both show equally high magnitude outputs (the right-most numbers following "MAG:"), so it's obvious that the target frequency 440Hz falls somewhere between. Increasing the resolution might be one way to close in, but that would add to the calculation time.

我如何计算落在两个频点之间的确切频率?

How do I calculate the exact frequency that falls between two frequency bins?

更新:

我尝试了巴里·奎因(Barry Quinn)的第二估算器" 在DSPGuru网站上进行了讨论,并获得了出色的效果.下面显示了440Hz方波的结果-现在我只有0.003Hz了!

I tried out Barry Quinn's "Second Estimator" discussed on the DSPGuru website and got excellent results. The following shows the result for 440Hz square wave - now I'm only off by 0.003Hz!

这里是我使用的代码.我只是修改了此示例,是给斯威夫特的谢谢大家的宝贵意见,这是一段很棒的学习过程:)

Here is the code I used. I simply adapted this example I found, which was for Swift. Thank you everyone for your very valuable input, this has been a great learning journey :)

推荐答案

Sinc插值可用于准确地插值(或重建)FFT结果仓之间的频谱.零填充FFT将产生相似的内插频谱.您可以使用高质量的插值器(例如开窗的Sinc核)并进行逐次逼近,以将实际频谱峰值估算为S/N允许的任何分辨率.除非您在插值内核中包括频谱共轭图像的影响,否则这种重构可能无法在DC或Fs/2 FFT结果仓附近工作.

Sinc interpolation can be used to accurately interpolate (or reconstruct) the spectrum between FFT result bins. A zero-padded FFT will produce a similar interpolated spectrum. You can use a high quality interpolator (such as a windowed Sinc kernel) with successive approximation to estimate the actual spectral peak to whatever resolution the S/N allows. This reconstruction might not work near the DC or Fs/2 FFT result bins unless you include the effects of the the spectrum's conjugate image in the interpolation kernel.

请参阅: https://ccrma.stanford.edu/~jos/Interpolation/Ideal_Bandlimited_Sinc_Interpolation.html https://en.wikipedia.org/wiki/Whittaker%E2%80%93Shannon_interpolation_formula 了解有关时域重构的详细信息,但相同的插值方法分别在域,频率或时间上适用于带宽受限或时限受限的信号.

See: https://ccrma.stanford.edu/~jos/Interpolation/Ideal_Bandlimited_Sinc_Interpolation.html and https://en.wikipedia.org/wiki/Whittaker%E2%80%93Shannon_interpolation_formula for details about time domain reconstruction, but the same interpolation method works in either domain, frequency or time, for bandlimited or time limited signals respectively.

如果您需要精度较低的估算器,而其计算开销要少得多,则抛物线插值法(以及其他类似的曲线拟合估算器)可能会起作用.请参阅: https://www.dsprelated.com/freebooks/sasp/Quadratic_Interpolation_Spectral_Peaks.html https://mgasior.web.cern.ch/mgasior/pap/FFT_resol_note.pdf 了解抛物线的详细信息,以及

If you require a less accurate estimator with far less computational overhead, parabolic interpolation (and other similar curve fitting estimators) might work. See: https://www.dsprelated.com/freebooks/sasp/Quadratic_Interpolation_Spectral_Peaks.html and https://mgasior.web.cern.ch/mgasior/pap/FFT_resol_note.pdf for details for parabolic, and http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.555.2873&rep=rep1&type=pdf for other curve fitting peak estimators.

这篇关于FFT-计算频点之间的准确频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆