This MATLAB tutorial explains the Spectrogram visualization using DTMF audio as input signal. The code reads, analyzes and plots the spectrogram of a DTMF signal. The time-frequency resolution problem is explained with different frame sizes.
Screen Display Specifications
scrsz = get(0,'ScreenSize');
P1=[40 500 scrsz(3)/3 scrsz(4)/3];
P2=[40 80 scrsz(3)/3 scrsz(4)/3];
P3=[600 500 scrsz(3)/3 scrsz(4)/3];
P4=[600 80 scrsz(3)/3 scrsz(4)/3];
P5=[1000 500 scrsz(3)/3 scrsz(4)/3];
P6=[1000 80 scrsz(3)/3 scrsz(4)/3];
File Reading
[y, Fs] = audioread('C:\Users\SAJIL\Documents\MATLAB\DTMF1.wav');
L=length(y);
N = nextpow2(L);
T=1/Fs;
Signal Analysis Part
t=(0:T:(L-1)/Fs)';
NFFT = 2^nextpow2(L);
Y = fft(y,NFFT);
f = Fs/2*linspace(0,1,NFFT/2+1);
Mag=2*abs(Y(1:NFFT/2+1));
Plot Signal
figure('position', P1);
figure(1);
plot(t,y,'k');
grid on
title('Time Domain');
xlabel('Time in Seconds');
ylabel('Amplitude');
legend('DTMF Tone');
Plot single-sided Amplitude Spectrum.
figure('position',P2);
figure(2);
plot(f,Mag);
grid on
title('Magnitude Spectrum');
xlabel('Frequency (Hz)');
ylabel('|X(f)|');
legend('Frequency Spectrum');
DTMF Signal Table
I = imread('DTMF.png');
figure('position',P3);
figure(3);
image(I)
f=text(0.4,0.4,'Original Input is 0696675356','FontSize',12);
axis off
Spectrogram Display Part
figure('position',P4);
figure(4);
spectrogram(y,32);
text(0.4,28,'Frame Size 32','FontSize',12);
figure('position',P5);
figure(5);
spectrogram(y,256);
text(0.4,28,'Frame Size 256','FontSize',12);
figure('position',P6);
figure(6);
spectrogram(y,512);
text(0.4,28,'Frame Size 512','FontSize',12);
Play back block
soundsc(y,Fs);
End of Program
No comments:
Post a Comment