归一化FFT幅度以模仿WMP

Bev*_*vin 6 audio visualization fft visualizer

所以,我一直在为声音文件制作一个小型可视化工具,只是为了好玩.我基本上想模仿Windows Media Player中的"Scope"和"Ocean Mist"可视化器.范围很简单,但我遇到了Ocean Mist的问题.我很确定它是某种频谱,但是当我对波形数据进行FFT时,我得不到与Ocean Mist显示的数据相对应的数据.频谱实际上看起来是正确的,所以我知道FFT没有任何问题.我假设可视化器通过某种过滤器运行光谱,但我不知道它可能是什么.有任何想法吗?

EDIT2:我在这里发布了我的代码的编辑版本.通过编辑,我的意思是我删除了所有实验性评论,只留下了活动代码.我还添加了一些描述性的评论.可视化器现在看起来像这样.

编辑:这是图像.第一个是我的可视化器,第二个是Ocean Mist.

我的可视化工具http://i43.tinypic.com/5xuyqa.jpg 海洋雾http://i41.tinypic.com/f1bb04.jpg

mtr*_*trw 6

这是一些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
Run Code Online (Sandbox Code Playgroud)

结果如下图所示: top:常规光谱图,底部:loglog光谱图(蓝色未显示)http://img710.imageshack.us/img710/3994/spectralplots.png

我让Octave处理从线性到log x和y轴的缩放.对于像正弦波这样的简单波形,你有类似的东西吗?

老答复

我不熟悉你提到的可视化工具,但总的来说:

  • 通常使用对数y轴(或光谱图的色图)显示光谱.
  • 你的FFT可能会返回一个双面光谱,但你可能只想使用前半部分(看起来你已经在做了).
  • 对您的时间数据应用窗口函数可以通过减少泄漏来缩小光谱峰值(看起来您也正在这样做).
  • 如果您关注绝对量值,您可能需要除以变换块大小(我认为在您的情况下并不重要).
  • 看起来Ocean Mist可视化器也使用了对数x轴.它也可能是平滑相邻频率箱的集合或其他东西.