问题描述
我正在尝试开发一个使用低音音频绘制音频频谱的应用程序( http://www. un4seen.com/).我的理解是,我将必须:
I'm trying to implement an app that plot the spectrum of an audio using bass audio (http://www.un4seen.com/). My understanding is that I will have to:
-
从流中获取FFT数据 float [] buffer =新的float [256]; Bass.BASS_ChannelGetData(句柄,缓冲区,(int)(BASS_DATA_FFT_COMPLEX | BASS_DATA_FFT_NOWINDOW));
Get the FFT data from the stream float[] buffer = new float[256]; Bass.BASS_ChannelGetData(handle, buffer, (int)(BASS_DATA_FFT_COMPLEX|BASS_DATA_FFT_NOWINDOW));
对于每个英尺,计算其幅度
For each fft, compute it’s magnitude
将窗口函数应用于FFT(汉宁或汉明均可)
Apply a window function to the FFT (Hanning or Hamming will do)
然后进行漂亮的光谱分析
then, draw a beautiful spectrum analysis
但是问题是:
- 似乎无法访问BASS_DATA_FFT_COMPLEX BassData.我可以在文档中看到它http://www.bass.radio42.com/help/html/a13cfef0-1056-bb94-81c4-a4fdf21bd463.htm ,但是由于出现BassData不包含此类枚举的错误,我无法使用它 li>
- 此外,我想知道我在做什么是否正确.要绘制频谱,我应该简单地绘制fft的幅度还是将fft的幅度与该fft的频率作对?在这种情况下,我将如何获得与该fft相对应的频率?我不介意从任何语言(C/C ++,C#,VB,Java等)中截取任何代码.
- It seems that the BASS_DATA_FFT_COMPLEX BassData isn't reachable. I can see it supposed to be available in the documentation http://www.bass.radio42.com/help/html/a13cfef0-1056-bb94-81c4-a4fdf21bd463.htm but I cannot use it since I get an error that BassData does not include such enum
- Further, I'm wondering if what I'm doing is right. To plot a spectrum, should I be simply plot the magnitude of fft or plat the magnitude of fft against the frequency of that fft? In this case, how would I get the frequency corresponding to that fft? I don't mind any code snipped from any language (C/C++, C#, VB, Java, etc..)
注意:我不确定这是否有帮助,但这就是我正在使用的内容:使用Microsoft Chart控件进行绘图.用BASS.NET API编写C# http://www.bass.radio42.com/非常感谢您的任何帮助和建议
Note: I'm not sure if this helps but this is what I'm using:Plotting using Microsoft Chart control.C# with the BASS.NET API byhttp://www.bass.radio42.com/Any help and suggestions in greatly appreciated
推荐答案
您混合了步骤的顺序-在计算FFT之前,您需要将窗函数应用于时域数据 .这些步骤通常是:
You have mixed up the order of the steps - you need to apply a window function to the time domain data before calculating the FFT. The steps are typically:
1. acquire time domain data
2. apply window function
3. calculate FFT
4. calculate log magnitude of FFT (log(re*re+im*im))
5. plot log magnitude (with appropriate scaling) against frequency
请注意,在Y轴上使用对数幅度可以有效地获得dB
比例,这是一种比线性幅度比例更自然,更有用的查看声音幅度的方法.
Note that using log magnitude for the Y axis gives you effectively a dB
scale, which is a more natural and useful way to view sound amplitude than a linear magnitude scale.
通常为了可视化音频等,您对连续的时域数据块(通常重叠50%)应用上述步骤1-5.
Normally for visualizing audio etc you apply steps 1 - 5 above on successive blocks of time domain data, typically with an overlap of 50%.
这篇关于绘制音频频谱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!