how to compare two audio signals with Matlab

倖福魔咒の 提交于 2019-12-13 19:24:46

问题


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 !

UPDATE

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)

and here are the result :

can anybody tell me how does the noise or the effect that I'm adding to the source influences my spectrum ?


回答1:


You could try to plot a spectrogram of both signals like so:

spectrogram(x, hann(nfft), nfft/2, nfft, fsample)

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.

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.



来源:https://stackoverflow.com/questions/22298644/how-to-compare-two-audio-signals-with-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!