如何将波浪数据转换为复数

发布于 2024-11-18 12:33:13 字数 358 浏览 3 评论 0原文

我正在从麦克风读取原始数据并输入 FFT。我正在尝试的两个 FFT 库(AForgeExocortex.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云淡月浅 2024-11-25 12:33:13

当对实际数据执行 FFT 时,您只需将输入的虚部设置为零。 (请注意,FFT 的输出仍然很复杂。)

绘制频谱图更为复杂 - 之前有关于此的帖子,但本质上您需要计算连续重叠时间的功率谱窗口(典型重叠 = 50%),然后使用颜色或灰度强度作为幅度(通常在 X 轴上显示时间,在 Y 轴上显示频率)绘制这些功率谱的对数 (dB) 幅度。要计算功率谱:

  • 窗函数应用于输入数据(例如汉宁窗)
  • FFT
  • 取幅度平方FFT 输出的前 N/2 个值 (re*re + im*im)
  • 将幅度转换为 dB 值 (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:

  • apply window function to input data (e.g. Hanning window)
  • FFT
  • take magnitude squared of first N/2 values of FFT output (re*re + im*im)
  • convert magnitude to dB value (10 * log10 (magnitude squared))
只有一腔孤勇 2024-11-25 12:33:13

为了绘制“漂亮”的频谱图:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文