You are on page 1of 12

TEMA 2

PDS

Dutan Andrei
442G (432G)
a) Create a Matlab program to read the audio file from www.comm.pub.ro/pds_proiect/files/
For each student the file name is taken from the table below
 Plot the audio signal in absolute time and the signal spectrogram.
 Determine from the signal spectrum the sinusoidal spectral components and determine the
normalized frequency and angular frequency of each sinusoid.

close all;
clear all;
clc;

[x,Fs]=audioread('sp10.wav');
size(x)
n=0:length(x)-1;
time=n/Fs;
figure(1),plot(time,x),grid
title('Semnalul'),xlabel('timp(s)')
figure(2), spectrogram(x,512,256,512,Fs,'Yaxis'), colormap(jet);
title('Spectograma')
%Frecventele nenormate:
F1=1600;
F2=400;
%Frecventele normate:
f1=F1/Fs
f2=F2/Fs
%Pulsatia normata:
W1=2*pi*f1
W2=2*pi*f2
%sound(x,Fs);
b) Design a FIR notch filter that eliminates disturbing spectral components and leaves the
output voice signal clean.
 Determine the zeros so that the H(z) function has real coefficients.
 Determine the coefficients of the transfer function H(z) of the FIR filter.
 Plot the zeros-poles diagram.
 Plot the frequency response of the system in dB and linear.
 Plot the impulse response of the system.
 Determine the output signal if the audio signal read from the file is applied to the input.
 Plot the output signal in absolute time and plot the output signal spectrogram.
z1=1*exp(j*W1);
z2=1*exp(j*W2);
z=[z1;conj(z1);z2;conj(z2)];

%Coeficientii functiei de transfer:


b1=poly(z);
a1=1;

figure(3),zplane(b1,a1)
title('Diagrama poli-zerouri')
[H,W]=freqz(b1,a1);
figure(4),plot(W,abs(H)),grid,title('Raspunsul in frecventa, liniar')
figure(5),plot(W,20*log10(abs(H))),grid,title('Raspunsul in frecventa, in
dB')
y1=filter(b1,a1,x);
[h,t]=impz(b1,a1);
figure(6), subplot(3,1,1),plot(n,x),grid ,title('Intrarea')
subplot(3,1,2),plot(t,h),grid ,title('Functia pondere, raspunsul
la impuls')
subplot(3,1,3),plot(n,y1),grid ,title('Iesirea')

figure(7), spectrogram(y1,512,256,512,Fs,'Yaxis'), colormap(jet);


title('Spectograma semnalului de iesire')
figure(8), plot(time,y1),grid
title('Semnalul de iesire'),xlabel('Timp(s)');
%sound(y1,Fs);

a1 = 1;

b1= [1, -3.8247, 5.6519, -3.8247, 1]


c) Design a IIR notch filter that eliminates disturbing spectral components and leaves the output
voice signal clean.
 Determine all the zeros and poles of the H(z) function. 0.7<r
 Determine the coefficients of the transfer function H(z) of the IIR filter.
 Plot the zeros-poles diagram.
 Plot the frequency response of the system in dB and linear. How the frequency response
changes if the poles are close to the unit circle (r1)?
 Plot the impulse response of the system.
 Determine the output signal if the audio signal read from the file is applied to the input.
 Plot the output signal in absolute time and plot the output signal spectrogram.

p1=0.85*exp(j*W1)
p2=0.85*exp(j*W2)
p=[p1;conj(p1);p2;conj(p2)];

%Coeficientii functiei de transfer:


b2=poly(z);
a2=poly(p);

figure(9),zplane(b2,a2)
[H2,W2]=freqz(b2,a2);
figure(10), plot(W2,abs(H2)),grid,title('Raspunsul in frecventa, liniar')
figure(11), plot(W2,20*log10(abs(H2))),grid,title('Raspunsul in frecventa, in
dB')
y2=filter(b2,a2,x);
[h2,t2]=impz(b2,a2);
figure(12), subplot(3,1,1),plot(n,x),grid ,title('Intrarea')
subplot(3,1,2),plot(t2,h2),grid ,title('Functia pondere,raspunsul
la impuls')
subplot(3,1,3),plot(n,y2),grid ,title('Iesirea')

figure(13), spectrogram(y2,512,256,512,Fs,'Yaxis'), colormap(jet);


title('Spectograma semnalului de iesire')
figure(14), plot(time,y2),grid
title('Semnalul de iesire'),xlabel('Timp(s)');
%sound(y2,Fs);

a2=[1, -3.2510, 4.0853, -2.3488, 0.5220]


b2=[1, -3.8247, 5.6519, -3.8247, 1]
Exp: The band is narrowing when the poles get closer to the unit radius circle.

You might also like