本文介绍了规范化FFT幅度模仿WMP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我一直都在为声音文件稍微可视化工具,只是为了好玩。我基本上想模仿在Windows Media Player中的范围和海洋薄雾展示台。适用范围是很容易,但我有与海洋雾的问题。我是pretty确保它是某种形式的频谱,但是当我在我的波形数据做了一个FFT,我没有收到对应于什么海洋薄雾显示的数据。频谱实际上看起来正确的,所以我知道有没有错FFT。我假设可视化贯穿某种过滤器的频谱,但我不知道它可能是什么。任何想法?

So, I've been working on a little visualizer for sound files, just for fun. I basically wanted to imitate the "Scope" and "Ocean Mist" visualizers in Windows Media Player. Scope was easy enough, but I'm having problems with Ocean Mist. I'm pretty sure that it is some kind of frequency spectrum, but when I do an FFT on my waveform data, I'm not getting the data that corresponds to what Ocean Mist displays. The spectrum actually looks correct, so I knew there was nothing wrong with the FFT. I'm assuming that the visualizer runs the spectrum through some kind of filter, but I have no idea what it might be. Any ideas?

EDIT2:
我这里张贴了我的code 。

I posted an edited version of my code here. By edited, I mean that I removed all the experimental comments everywhere, and left only the active code. I also added some descriptive comments. The visualizer now looks like this.

编辑:
以下是图像。第一个是我的可视化,并且第二个是海洋薄雾

Here are images. The first is my visualizer, and the second is Ocean Mist.


推荐答案

下面是一些倍频code,显示什么,我认为应该发生。我希望语法是不言自明的:

Here's some Octave code that shows what I think should happen. I hope the syntax is self-explanatory:

%# 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

这会导致如下图:

which results in the following graph:

我让倍频从线性处理缩放登录x和y轴。你得到像正弦波简单波形相似的地方?

I'm letting Octave handle the scaling from linear to log x and y axes. Do you get something similar for a simple waveform like a sine wave?

OLD答案

我不熟悉你所提到的可视化工具,但一般:

I'm not familiar with the visualizer you mention, but in general:


  • Spectra是使用对数y轴(或颜色映射为谱图)显示频率。

  • 您的FFT可能会返回一个双面谱,但你可能想只用上半场(看起来像你这样做的话)。

  • 申请一个您的时间数据,使谱峰通过减少渗漏窄(看起来像你这样做这太)。

  • 您可能需要通过变换块大小,如果你关心的绝对星等来划分(我猜不是你的情况很重要)。

  • 它看起来像海洋喷雾可视化是使用数x轴了。它也可能是套什么的平滑邻接的频率段。

  • Spectra are often displayed using a log y-axis (or colormap for spectrograms).
  • Your FFT might be returning a double-sided spectrum, but you probably want to use only the first half (looks like you're doing already).
  • Applying a window function to your time data makes the spectral peaks narrower by reducing leakage (looks like you're doing this too).
  • You might need to divide by the transform blocksize if you're concerned with absolute magnitudes (I guess not important in your case).
  • It looks like the Ocean Mist visualizer is using a log x-axis too. It might also be smoothing adjacent frequency bins in sets or something.

这篇关于规范化FFT幅度模仿WMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 01:45