基于matlab的语音信号处理 下载本文

附 录

附录I设计FIR和IIR数字滤波器

1.IIR低通滤波器

Ft=8000; Fp=1000; Fs=1200;

wp=2*pi*Fp/Ft; ws=2*pi*Fs/Ft; fp=2*Ft*tan(wp/2); fs=2*Fs*tan(wp/2);

[n11,wn11]=buttord(wp,ws,1,50,'s'); [b11,a11]=butter(n11,wn11,'s');

[num11,den11]=bilinear(b11,a11,0.5); [h,w]=freqz(num11,den11); figure; plot(w*8000*0.5/pi,abs(h));

legend('IIR低通滤波器,'Location','NorthWest'); grid;

程序结果如下图:

2.IIR带通滤波器

Fp1=1200; Fp2=3000; Fs1=1000; Fs2=3200;

1

附 录

Ft=8000;

wp1=tan(pi*Fp1/Ft); wp2=tan(pi*Fp2/Ft); ws1=tan(pi*Fs1/Ft); ws2=tan(pi*Fs2/Ft); w=wp1*wp2/ws2;

bw=wp2-wp1; %有效通带频率 wp=1;

ws=(wp1*wp2-w.^2)/(bw*w);

[n12,wn12]=buttord(wp,ws,1,50,'s'); [b12,a12]=butter(n12,wn12,'s');

[num2,den2]=lp2bp(b12,a12,sqrt(wp1*wp2),bw); [num12,den12]=bilinear(num2,den2,0.5); [h,w]=freqz(num12,den12); figure;

plot(w*8000*0.5/pi,abs(h)); axis([0 4500 0 1.5]);

legend('IIR带通滤波器,'Location','NorthWest'); grid;

程序结果如下图:

3.IIR高通滤波器

Ft=8000; Fp=4000; Fs=3500;

2

附 录

wp1=tan(pi*Fp/Ft); ws1=tan(pi*Fs/Ft); wp=1;

ws=wp1*wp/ws1;

[n13,wn13]=cheb1ord(wp,ws,1,50,'s'); [b13,a13]=cheby1(n13,1,wn13,'s'); [num,den]=lp2hp(b13,a13,wn13);

[num13,den13]=bilinear(num,den,0.5); [h,w]=freqz(num13,den13); figure;

plot(w*21000*0.5/pi,abs(h));

legend('IIR高通滤波器','Location','NorthWest'); axis([0 11000 0 1.5]); grid;

程序结果如下图:

4.FIR低通滤波器

Ft=8000; Fp=1000; Fs=1200; wp=2*Fp/Ft; ws=2*Fs/Ft; rp=1; rs=50;

3

附 录

p=1-10.^(-rp/20); s=10.^(-rs/20); fpts=[wp ws]; mag=[1 0]; dev=[p s];

[n21,wn21,beta,ftype]=kaiserord(fpts,mag,dev); b21=fir1(n21,wn21,kaiser(n21+1,beta)); [h,w]=freqz(b21,1); figure;

plot(w*8000*0.5/pi,abs(h));

title('FIR低通滤波器,'fontweight','bold'); grid;

程序结果如下图:

5.FIR带通滤波器

Fp1=1200; %通带边界频率 Fp2=3000;

Fs1=1000; %阻带截止频率 Fs2=3200; Ft=8000;

wp1=tan(pi*Fp1/Ft); wp2=tan(pi*Fp2/Ft); ws1=tan(pi*Fs1/Ft); ws2=tan(pi*Fs2/Ft);

4

附 录

w=wp1*wp2/ws2; bw=wp2-wp1; wp=1;

ws=(wp*wp2-w.^2)/(bw*w);

[n22,wn22]=buttord(wp,ws,1,50,'s'); [b22,a22]=butter(n22,wn22,'s');

[num2,den2]=lp2bp(b22,a22,sqrt(wp1*wp2),bw); [num22,den22]=bilinear(num2,den2,0.5); [h,w]=freqz(num22,den22); figure;

plot(w*8000*0.5/pi,abs(h)); axis([0 4500 0 1.5]);

legend('FIR带通滤波器','Location','NorthWest'); grid;

程序结果如下图:

6.FIR高通滤波器

Ft=8001;

Fp=4000; %通带边界频率 Fs=3500; %阻带截止频率 wp=2*Fp/Ft; ws=2*Fs/Ft; rp=1; rs=50;

p=1-10.^(-rp/20);

5