Digital Signal Processing Reference
In-Depth Information
Programmbeispiel 6-1
Audiosignal, DFT-Spektrum und Spektrogramm
% Spectral analysis of audio signal
% dsplab6_1.m * mw * 04/10/2008
[y,fs,bits] = wavread('speech');
%
load audio signal
soundsc(y,fs,bits);
%
sound
%%
Graphics
t = 0:length(y)-1; t = t/fs;
%
time scale
figure('Name','dsplab6_1 : Audio signal "telecommunications
laboratory" ','NumberTitle','off');
plot(t,y), grid
xlabel('{\itt} in s \rightarrow')
ylabel('{\ity}({\itt}) \rightarrow')
%%
Spetral analysis - short term
y = y(1:fs);
%
curtail signal to 1 second
M = 512;
%
fft length
w = hamming(M);
%
Hamming window
OL = 0.5;
%
50% overlap of the fft blocks
NY = floor(length(y)/(M*(1-OL)));
%
number of dft spectra
MY = M/4;
%
number of dft coefficients per dft spectrum
Y = zeros(NY,MY);
start = 1; stop = start + M - 1; k = 0;
while stop<=length(y)
k = k + 1;
YY = fft(w.*y(start:stop))';
Y(k,:) = abs(YY(1:MY));
start = start + M*(1-OL);
stop = start + M - 1;
end
%
Graphics
figure('Name','dsplab6_1 : Waterfall diagram
"telecommunications"','NumberTitle','off');
Y = Y/max(max(Y));
t = 1:NY; t = t*(M*(1-OL))/fs;
%
time scale
f = 0:1:M/4-1; f = fs*f/M;
%
frequency scale
waterfall(f,t,Y);
view(45,40)
xlabel('{\itf} in Hz \rightarrow'), ylabel('{\itt} in s
\rightarrow')
zlabel('Magnitudes of short term dft spectra \rightarrow')
%%
MATLAB built-in spectrogram
figure('Name','dsplab6_1 : Spectrogram
"telecommunications"','NumberTitle','off');
spectrogram(y,hamming(M),M/2,0:20:4000,fs,'yaxis');
6.3.3
Versuchsdurchführung
M6.4
Zum Thema Spektrogramm gibt es ein MATLAB-Demoprogramm in der Signal
Processing Toolbox mit grafischer Benutzerschnittstelle. Der Aufruf ohne Parameter
specgramdemo
liefert das Beispiel in Bild 6-6. Menüleiste und Eingabefenster er-
möglichen eine interaktive Bedienung des Demoprogramms.