如何用Matlab比较两个音频信号 [英] how to compare two audio signals with Matlab
问题描述
我有两个要使用Matlab比较的音频信号,我的问题是我可以清晰听到它们之间的区别,但是当使用功能pwelch
比较它们的PSD时,我看不到它们之间的区别,任何想法我该如何将它们与其他方法进行比较!提前致谢 !
PS:1.我已经问过DSP.stackexchange中的问题,但没有答案!
2.我不要求输入密码,这就是为什么我不放我的密码!
I have two audio signas that I want to compare using Matlab, my problem is that I can hear the difference between them loud and clear, but when use the function pwelch
to compare their PSD ,I don't see much difference between them,any idea how can I compare them with a different methode ! thanks in advance !
PS: 1. I already ask the quesiton in DSP.stackexchange but had no answer!
2. I'm not asking for codes, that'S why I didn't put mine !
更新
在@Bas Swinckels的答案之后,这里是我正在使用结果的代码,而我仍然看不到描述此方法的方式?
after the answer of @Bas Swinckels here the code par that I'm using the result and I still can't see a way that the describ this ?
clear;
clc;
[x0,Fs] = audioread('Nonoise.wav');
x0 = x0(:,1);
[Y0,G] = pwelch(x0,hamming(512));
plot(G,10*log10(Y0));
grid on
[x50,Fs] = audioread('50% noise.wav');
x50 = x50(:,1);
[Y50,G] = pwelch(x50,hamming(512));
hold on ;
plot(G,10*log10(Y50),'r');
[x100,Fs] = audioread('100% noisy.wav');
x100 = x100(:,1);
[Y100,G] = pwelch(x100,hamming(512));
hold on ;
plot(G,10*log10(Y100),'g');
%% spectrogram
spectrogram(x0,hann(64),32,64,Fs)
figure();
spectrogram(x50,hann(64),32,64,Fs)
figure();
spectrogram(x100,hann(64),32,64,Fs)
这是结果:
有人可以告诉我,我添加到信号源中的噪声或影响如何影响我的频谱?
can anybody tell me how does the noise or the effect that I'm adding to the source influences my spectrum ?
推荐答案
您可以尝试绘制频谱图:
spectrogram(x, hann(nfft), nfft/2, nfft, fsample)
使用pwelch
计算PSD时,您只会得到平均频谱,并且会丢失所有时间信息:如果信号在开始或结束时响亮,则不会显示给您.频谱图的计算也与您的耳朵所感知的非常相似,它们根据时间来测量某种频谱.因此,如果您能听到差异,那么它应该在频谱图中显示为具有足够SNR的差异.
When you calculate a PSD with pwelch
, you only get the average spectrum and you lose all temporal information: it will not show you if a signal is louder at the beginning or at the end. Calculating a spectrogram is also pretty similar to what your ears perceive, they measure a sort of spectrum as a function of time. So if you can hear the difference, it should show up as a difference in the spectrogram with enough SNR.
制作频谱图时,应尝试使用频率和时间分辨率,因为它们遵循某种海森堡定律.使FFT窗口变短(通过选择较小的nfft
)将为您提供良好的时间分辨率,但会降低频率分辨率,反之亦然.
When you make a spectrogram, you should try to play with the frequency and temporal resolution, since they follow some sort of Heisenberg law. Making the FFT window short (by chosing a small nfft
) will give you good temporal resolution, but worse frequency resolution, and the other way around.
这篇关于如何用Matlab比较两个音频信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!