Comparing the spectra of two acoustic signals
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everybody, I want to compare the spectra of two acoustical signals (very short signals, with duration less than 300 milliseconds), but I don´t know how to do it.
I would like to have a measure indicating where in the spectrum of a signal there is more energy.
I just want to know a number summarizing the spectral content of a signal in order to compare it with the other signal.
Something like the spectral power of the signal is around 100 Hz or between 50 and 300 Hz...
Help!
I don't have too much experience in signal analysis...sorry maybe you find the question trivial!
Thanks in advance!
0 Kommentare
Antworten (7)
nanren888
am 23 Feb. 2012
Tell us a little more about the signal & what sort of characterisation you want. After all, a single number to represent the spectra needs a little prior knowledge about what is important to you. Position of the peak of the spectrum? Spectral weighted mean value? Bandwidth?
0 Kommentare
L T
am 23 Feb. 2012
Hello, thanks a lot for answering. Actually I am trying to see the differences between the spectra of two waveforms of two footsteps on different synthesized grounds.
The first sound is a footstep on metal, you can download it here: http://dl.dropbox.com/u/3288659/metal.wav
The second sound is a footstep on snow, you can download it here: http://dl.dropbox.com/u/3288659/snow.wav
Could you please tell me which analysis will you perform? And which function can I use in Matlab?
Thanks a lot
0 Kommentare
Wayne King
am 23 Feb. 2012
Hi you can look at the individual spectra:
[x,fs] = wavread('metal.wav');
psdx = psd(spectrum.periodogram,x,'Fs',44100,'NFFT',length(x));
plot(psdx);
You'll see that the metal.wav file features a strong oscillation at approximately 620 Hz if you zoom in on the plot.
To look at the snow.wav
[y,fs] = wavread('snow.wav');
psdy = psd(spectrum.periodogram,y,'Fs',44100,'NFFT',length(y));
plot(psdy)
You see that the snow.wav does not have any such prominent peaks. Both spectra have the same basic "background" shape -- more power at lower frequencies.
Finally, you can perform basically a correlation in the frequency domain using mscohere()
To do this you will have to shorten the snow.wav vector to be the same length as metal.wav
y1 = y(1:length(x));
You can hear that you still have the footstep.
soundsc(y1,44100);
Then compute the magnitiude-squared coherence.
mscohere(x,y1,hanning(1e3),800,1024,44100);
This shows the two spectra are poorly correlated.
0 Kommentare
L T
am 23 Feb. 2012
THANKS A LOT!!!!!!
I have two questions: 1- I have to compare many signals of different length. Should I zero padd the shortest ones until they have the same lenght of the largest one? Or should I shorten all the files to the lenght of the file with shorter lenght?
2- I noticed that I don't have installed the Signal Processing Toolbox....help! How can I perform that analysis without having those functions?
Best
1 Kommentar
Wayne King
am 23 Feb. 2012
The length restriction is only a result of using mscohere(), which is part of the Signal Processing Toolbox.
To simply look at the individual spectra, you can use fft(). It will not be so simply to do the coherence without the Signal Processing Toolbox. You can search the file exchange to see if anyone has provided a free version.
Wayne King
am 23 Feb. 2012
Note that I have not bothered with scaling the Fourier transforms to obtain proper power spectral density estimates. And just for convencience, I dropped the last sample from metal.wav to get an even length.
[y,fs] = wavread('snow.wav');
[x,fs] = wavread('metal.wav');
ydft = fft(y);
Fs = 44100;
ydft = ydft(1:length(y)/2+1);
freqy = 0:Fs/length(y):Fs/2;
subplot(211)
plot(freqy./1e3,20*log10(abs(ydft)));
set(gca,'xlim',[0 (Fs/2)/1e3]);
set(gca,'ylim',[-60 60]);
ylabel('dB'); title('Snow');
x1 = x(1:end-1);
xdft = fft(x1);
xdft = xdft(1:length(x1)/2+1);
freqx = 0:Fs/length(x1):Fs/2;
subplot(212)
plot(freqx./1e3,20*log10(abs(xdft)));
set(gca,'xlim',[0 (Fs/2)/1e3]);
set(gca,'ylim',[-60 60]);
xlabel('kHz'); ylabel('dB');
title('Metal');
0 Kommentare
L T
am 23 Feb. 2012
Thanks a lot, you are a saint! ;-)
...I am not able to find the free version of mscohere ;-(
Any suggestion?
I also tried to install the free trial of the signal processing toolbox but I have incompatibilities with my operative system...
1 Kommentar
L T
am 23 Feb. 2012
Sorry, another question. In case I get the toolbox, the mschoere function needs two vectors of the same lenght.
But if I have one vector longer than the other, can I add some zero to the shorter vector in order to reach the lenght of the longer vector but without affecting the result of the mscohere function?
Please enlighten me!
Thanks
1 Kommentar
Wayne King
am 23 Feb. 2012
In your example, you can just reduce the one vector as I did because that did no cut off the sound of the foot step
Siehe auch
Kategorien
Mehr zu Measurements and Spatial Audio finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!