如何将波浪数据转换为复数
我正在从麦克风读取原始数据并输入 FFT。我正在尝试的两个 FFT 库(AForge 和 Exocortex.DSP) 将复数作为输入并给出复数作为输出。
我试图理解什么是复数。
更具体地说 - 如何将从麦克风获得的原始音频数据转换为复数以便在 FFT 中进行处理?
如何将输出绘制成漂亮的频谱图(即从输出中读取频率和幅度)?
额外的好处:除了提到的两个之外,.Net 还有哪些 FFT 库?
I'm reading raw data from a mic and feeding into FFT. Two of the FFT libraries I'm trying (AForge and Exocortex.DSP) takes Complex numbers as input and gives Complex numbers as output.
I'm trying to understand what complex numbers are.
More specifically - how do I convert the raw audio data obtained from a microphone into complex numbers for processing in FFT?
And how do I plot the output to a nice spectrogram (that is; reading the frequencies and amplitudes from the output)?
Added bonus: What FFT libs are there for .Net other than the two mentioned?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当对实际数据执行 FFT 时,您只需将输入的虚部设置为零。 (请注意,FFT 的输出仍然很复杂。)
绘制频谱图更为复杂 - 之前有关于此的帖子,但本质上您需要计算连续重叠时间的功率谱窗口(典型重叠 = 50%),然后使用颜色或灰度强度作为幅度(通常在 X 轴上显示时间,在 Y 轴上显示频率)绘制这些功率谱的对数 (dB) 幅度。要计算功率谱:
re*re + im*im
)10 * log10(幅度平方)
代码>)When performing an FFT on real data then you just need to set the imaginary part of the input to zero. (Note that the output of the FFT will still be complex though.)
Plotting a spectrogram is more complex - there are previous posts on SO about this but essentially you need to compute the power spectrum for successive overlapping time windows (typical overlap = 50%) and then plot the log (dB) magnitude of these power spectra using colour or grey scale intensity for magnitude (with time on the X axis and frequency on the Y axis usually). To compute the power spectrum:
N/2
values of FFT output (re*re + im*im
)10 * log10 (magnitude squared)
)为了绘制“漂亮”的频谱图:
FFT 计算与窗口变换卷积的数据的局部频谱。
如果您不在 FFT 前面使用窗函数,则默认情况下窗函数最终会成为 FFT 长度的矩形窗口,如果您不期望的话,它的变换可能看起来相当难看(有些称之为光谱“泄漏”)。您可能想尝试使用其他一些窗口函数(Von Hann 等人),其中窗口 FFT 产生的卷积可能会产生“更好看”的频谱图。
For plotting a "nice looking" spectrogram:
An FFT computes the local spectrum of your data convolved with the transform of the window.
If you don't use a window function in front of an FFT, the window function ends up being a rectangular window of the FFT length by default, which has a transform that might seem quite ugly looking if you don't expect it (some call it spectral "leakage"). You might want to try using some other window function (Von Hann, et.al.) where the convolution produced by the windowed FFT might result in a "nicer looking" spectrogram.