问题描述
我想打一个程序,将记录使用PortAudio(我有这部分完成)的音频数据,然后显示记录音频的频率信息(现在,我想每个显示的平均频率组样品,因为他们进来)。
I want to make a program that would record audio data using PortAudio (I have this part done) and then display the frequency information of that recorded audio (for now, I'd like to display the average frequency of each of the group of samples as they come in).
从一些研究,我已经做了,我知道我需要做的FFT。于是,我用Google搜索为图书馆要做到这一点,在C,发现FFTW。
From some research I've done, I know that I need to do an FFT. So I googled for a library to do that, in C, and found FFTW.
不过,现在我有点失落。究竟我应该用我录提取他们一些频率信息的样本呢?我应该使用什么样的FFT(我假设我需要一个真实的数据1D?)?
However, now I am a little lost. What exactly am I supposed to do with the samples I recorded to extract some frequency information from them? What kind of FFT should I use (I assume I'd need a real data 1D?)?
一旦我做了FFT,我该如何得到数据的频率信息,它给了我?
And once I'd do the FFT, how do I get the frequency information from the data it gives me?
编辑:我现在也发现了自相关算法。岂不是更好?简单?
EDIT : I now found also the autocorrelation algorithm. Is it better? Simpler?
非常感谢提前和对不起,我如果完全没有经验。我希望这使得至少有一点感觉。
Thanks a lot in advance, and sorry, I have absolutely no experience if this. I hope it makes at least a little sense.
推荐答案
要您的音频采样转换为功率谱:
To convert your audio samples to a power spectrum:
- 如果您的音频数据整数数据然后将其转换为浮点
- 选择一个FFT的大小(例如,N = 1024)
- 应用您的N个数据样本(如的)
- 使用大小为N真正到复杂FFT来产生频域数据
- 计算你的复频域数据的幅度(
=幅度的sqrt(RE ^ 2 + IM ^ 2)
) - 可选转换幅度对数刻度(DB)(
magnitude_dB = 20 * log10的(大小)
)
- if your audio data is integer data then convert it to floating point
- pick an FFT size (e.g. N=1024)
- apply a window function to N samples of your data (e.g. Hanning)
- use a real-to-complex FFT of size N to generate frequency domain data
- calculate the magnitude of your complex frequency domain data (
magnitude = sqrt(re^2 + im^2)
) - optionally convert magnitude to a log scale (dB) (
magnitude_dB = 20*log10(magnitude)
)
这篇关于如何从PortAudio使用C中的FFTW提取样品的频率信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!