Question

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 :

pwelch result

no noise or no effect

50 percent

100 percent noisy

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top