如何利用傅立叶变换从WAV文件中提取半precise频率 [英] How to extract semi-precise frequencies from a WAV file using Fourier Transforms

查看:303
本文介绍了如何利用傅立叶变换从WAV文件中提取半precise频率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说,我有一个WAV文件。在这个文件中,是precise间隔1秒一连串正弦波音。我想使用的FFTW库按顺序提取这些音调。这是特别难呢?我怎么会去吗?

Let us say that I have a WAV file. In this file, is a series of sine tones at precise 1 second intervals. I want to use the FFTW library to extract these tones in sequence. Is this particularly hard to do? How would I go about this?

此外,什么是写这种色调成WAV文件的最好方法?我想我只需要一个简单的音频库的输出。

Also, what is the best way to write tones of this kind into a WAV file? I assume I would only need a simple audio library for the output.

我选择的语言是C

推荐答案

要得到一个部分的功率谱您的文件:

To get the power spectrum of a section of your file:


  • 收集N个样本,其中N是2的幂 - 如果你的采样率44.1千赫例如,你想品尝大约每一秒,然后去说,N = 32768样品

  • collect N samples, where N is a power of 2 - if your sample rate is 44.1 kHz for example and you want to sample approx every second then go for say N = 32768 samples.

应用合适的窗函数的样品,例如寒凝

apply a suitable window function to the samples, e.g. Hanning

传递窗采样到 FFT 程序 - 最好你想要一个真正的到复杂,但FFT如果你有一个复杂到复杂FFT那么对于所有的虚拟输入部分传递0

pass the windowed samples to an FFT routine - ideally you want a real-to-complex FFT but if all you have a is complex-to-complex FFT then pass 0 for all the imaginary input parts

计算你的FFT输出箱(重*重+ IM * IM)

calculate the squared magnitude of your FFT output bins (re * re + im * im)

(可选)计算出每级10 * log10的平方出纸槽,以获得分贝一个幅值

(optional) calculate 10 * log10 of each magnitude squared output bin to get a magnitude value in dB

现在,你有你的功率谱,你只需要确定峰(S),这应该是pretty简单,如果你有一个合理的S / N比率。注意,频率分辨率与较大N.改善有关的44.1千赫采样率和N = 32768上面的例子中每个仓的频率分辨率为44100/32768 = 1.35赫兹

Now that you have your power spectrum you just need to identify the peak(s), which should be pretty straightforward if you have a reasonable S/N ratio. Note that frequency resolution improves with larger N. For the above example of 44.1 kHz sample rate and N = 32768 the frequency resolution of each bin is 44100 / 32768 = 1.35 Hz.

这篇关于如何利用傅立叶变换从WAV文件中提取半precise频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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