所以,我一直在为声音文件制作一个小可视化工具,只是为了好玩。我基本上想模仿 Windows Media Player 中的“Scope”和“Ocean Mist”可视化工具。 Scope 很容易,但我在使用 Ocean Mist 时遇到了问题。我很确定它是某种频谱,但是当我对波形数据进行 FFT 时,我没有得到与 Ocean Mist 显示的数据相对应的数据。频谱实际上看起来是正确的,所以我知道 FFT 没有任何问题。我假设可视化器通过某种过滤器运行光谱,但我不知道它可能是什么。有任何想法吗?
编辑2:
我在这里发布了我的代码的编辑版本(编者注:链接不再有效)。通过编辑,我的意思是我删除了所有地方的所有实验注释,只留下事件代码。我还添加了一些描述性评论。可视化工具现在看起来像 this .
编辑:
这里是图像。第一个是我的可视化工具,第二个是 Ocean Mist。
最佳答案
这是一些 Octave 代码,显示了我认为应该发生的事情。我希望语法是不言自明的:
%# First generate some test data
%# make a time domain waveform of sin + low level noise
N = 1024;
x = sin(2*pi*200.5*((0:1:(N-1))')/N) + 0.01*randn(N,1);
%# Now do the processing the way the visualizer should
%# first apply Hann window = 0.5*(1+cos)
xw = x.*hann(N, 'periodic');
%# Calculate FFT. Octave returns double sided spectrum
Sw = fft(xw);
%# Calculate the magnitude of the first half of the spectrum
Sw = abs(Sw(1:(1+N/2))); %# abs is sqrt(real^2 + imag^2)
%# For comparison, also calculate the unwindowed spectrum
Sx = fft(x)
Sx = abs(Sx(1:(1+N/2)));
subplot(2,1,1);
plot([Sx Sw]); %# linear axes, blue is unwindowed version
subplot(2,1,2);
loglog([Sx Sw]); %# both axes logarithmic
结果如下图:
top: regular spectral plot, bottom: loglog spectral plot (blue is unwindowed) http://img710.imageshack.us/img710/3994/spectralplots.png
我让 Octave 处理从线性到 log x 和 y 轴的缩放。对于像正弦波这样的简单波形,您是否得到类似的结果?
旧答案
我不熟悉你提到的可视化工具,但总的来说:
关于audio - 归一化 FFT 幅度以模仿 WMP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2466196/