【发布时间】:2011-10-17 11:51:27
【问题描述】:
我已经将一个对数扫频正弦(带有一些短暂的淡入/淡出)加载到 Matlab 中,并通过 fft 函数运行它并使用 semilog 绘制它。
输入信号幅度在 10 ... 20000 Hz 范围内几乎是恒定的。因此,为了更准确地表示正在发生的事情,我希望将图表视为几乎水平的线。
我应该应用什么公式来使 AFR 图水平?
我用来绘制图形的 Matlab 脚本:
fid = fopen('sweepfaded.raw','rb'); %open file
data = fread(fid, inf, 'float32'); %read in the data
fclose(fid); %close file
n = size(data,1);
n = 2^nextpow2(n); % Next power of 2 from length of audio - 2-powers are faster to calculate
p = fft(data, n); % take the fourier transform
nUniquePts = ceil((n+1)/2);
p = p(1:nUniquePts); % select just the first half since the second half
% is a mirror image of the first
p = abs(p); % take the absolute value, or the magnitude
p = p/n; % scale by the number of points so that
% the magnitude does not depend on the length
% of the signal or on its sampling frequency
p = p.^2; % square it to get the power
sampFreq = 44100;
freqArray = (0:nUniquePts-1) * (sampFreq / n); % create the frequency array
semilogx(freqArray, 10*log10(p))
xlabel('Frequency (Hz)')
ylabel('Power (dB)')
我想要水平的结果图(比如对其进行一些旋转,使 100...10000 Hz 的范围变成一条水平线):
附:我不擅长音频信号处理,我只是一个普通的程序员,所以不要浪费你的时间来解释发生了什么(虽然我想,总有一天我还是要读一本好的 DSP 书)。只要一个正确的公式插入到我的 Matlab 脚本中就足够了。
【问题讨论】: