实验 7MAtlab 语音仿真系统 实验报告

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

陕西科技大学实验报告
班级信工082 学号16 姓名刘刚实验组别
实验日期室温报告日期成绩
报告内容:(目的和要求,原理,步骤,数据,计算,小结等)
实验七语音处理系统仿真(综合滤波器设计)
一代码:
(1)主程序:
x=wavread('login.wav');
n=0:1/22050:(size(x)-1)/22050;
x_dft=fft(x);%DFT
[x_dtft w]=freqz(x);%DTFT
subplot(2,2,1);
plot(n,x); title('原语音信号x1');
subplot(2,2,2);plot(n,abs(x_dft));
title('x的DFT变换结果x2'); grid on;
subplot(2,2,3); plot(w/pi,abs(x_dtft));
title('x2的幅度相位响应');grid on;
subplot(2,2,4);plot(w/pi,unwrap(angle(x_dtft)));
title('x2的相位相位响应');grid on;
%用FIR滤波器进行滤波
[y_low b_low]=lowpass_fir_filter(x);%调用FIR低通滤波器函数
[y_band b_band]=bandpass_fir_filter(x);%调用FIR带通滤波器函数[y_high b_high]=highpass_fir_filter(x);%调用FIR高通滤波器函数[hh_low ww_low]=freqz(b_low,1,512);
[hh_band ww_band]=freqz(b_band,1,512);
[hh_high ww_high]=freqz(b_high,1,512);
[h_low w_low]=freqz(y_low);
[h_band w_band]=freqz(y_band);
[h_high w_high]=freqz(y_high);
figure ;subplot(3,3,1); plot(ww_low/pi,20*log10(abs(hh_low))); title('FIR低通滤波器');grid on;
subplot(3,3,2);plot(n,y_low);
title('经FIR低通滤波后的信号x1'); grid on;
subplot(3,3,3); plot(w_low/pi,abs(h_low));
title('x1的幅度相位响应'); grid on;
subplot(3,3,4); plot(ww_band/pi,20*log10(abs(hh_band)));
title('FIR带通滤波器'); grid on;
subplot(3,3,5); plot(n,y_band);
title('经FIR带通滤波后的信号x2'); grid on;
subplot(3,3,6); plot(w_band/pi,abs(h_band));
title('x2的幅度相位响应'); grid on;
subplot(3,3,7); plot(ww_high/pi,20*log10(abs(hh_high)));
title('FIR高通滤波器'); grid on;
subplot(3,3,8); plot(n,y_high);
title('经FIR高通滤波后的信号x3'); grid on;
subplot(3,3,9); plot(w_high/pi,abs(h_high));
title('x3的幅度相位响应'); grid on;
%用IIR滤波器进行滤波
[y_low bz_low az_low]=lowpass_iir_filter(x);%调用IIR低通滤波器函数
[y_band bz_band az_band]=bandpass_iir_filter(x);%调用IIR带通滤波器函数
[y_high bz_high az_high]=highpass_iir_filter(x);%调用IIR高通滤波器函数
[hh_low ww_low]=freqz(bz_low,az_low,256,1);
[hh_band ww_band]=freqz(bz_band,az_band,256,1);
[hh_high ww_high]=freqz(bz_high,az_high,256,1);
[h_low w_low]=freqz(y_low);
[h_band w_band]=freqz(y_band);
[h_high w_high]=freqz(y_high);
figure (3);subplot(3,3,1); plot(ww_low,abs(hh_low));
title('IIR低通滤波器'); grid on;
subplot(3,3,2);plot(n,y_low);
title('经IIR低通滤波后的信号x1'); grid on;
subplot(3,3,3); plot(w_low/pi,abs(h_low));
title('x1的幅度相位响应'); grid on;
subplot(3,3,4); plot(ww_band,abs(hh_band));
title('IIR带通滤波器'); grid on;
subplot(3,3,5); plot(n,y_band);
title('经IIR带通滤波后的信号x2'); grid on; subplot(3,3,6); plot(w_band/pi,abs(h_band)); title('x2的幅度相位响应'); grid on;
subplot(3,3,7); plot(ww_high,abs(hh_high)); title('IIR高通滤波器'); grid on;
subplot(3,3,8); plot(n,y_high);
title('经IIR高通滤波后的信号x3'); grid on; subplot(3,3,9); plot(w_high/pi,abs(h_high)); title('x3的幅度相位响应'); grid on;
(1)主程序:
1) FIR低通滤波器
function [y b]=bandpass_fir_filter(x)
w1=0.4*pi; w2=0.7*pi;
wn=[w1 w2];
wdelta=w2-w1;
M=ceil(3.32*pi/wdelta);
N=2*M+1;
win=hamming(N);
b=fir1(N-1,wn/pi,'bandpass',win);
y=filter(b,1,x);
2) FIR高通滤波器
function [y b]=highpass_fir_filter(x)
wp=0.6*pi; ws=0.9*pi;
wdelta=ws-wp;
M=ceil(3.32*pi/wdelta);
N=2*M+1;
wc=(ws+wp)/2;
win=hamming(N);
b=fir1(N-1,wc/pi,'high',win);
y=filter(b,1,x);
3) FIR带通滤波器
function [y b]=lowpass_fir_filter(x)
wp=0.22*pi; ws=0.46*pi;
wdelta=ws-wp;
M=ceil(3.32*pi/wdelta);
N=2*M+1; %´°
wc=(ws+wp)/2;
win=hamming(N);
b=fir1(N-1,wc/pi,win);
y=filter(b,1,x);
4) IIR低通滤波器
function [y bz az]=lowpass_iir_filter(x) rp=1; rs=15; wp=0.25*pi; ws=0.4*pi; wap=tan(wp/2);
was=tan(ws/2);
[n,wn]=buttord(wap,was,rp,rs,'s') ; [z,p,k]=buttap(n);
[bp,ap]=zp2tf(z,p,k);
[bs,as]=lp2lp(bp,ap,wap);
[bz,az]=bilinear(bs,as,1/2);
y=filter(bz,az,x);
5) IIR高通滤波器
function [y bz az]=highpass_iir_filter(x) rp=1; rs=15;
wp=0.7*pi; ws=0.85*pi;
wap=tan(wp/2); was=tan(ws/2);
[n,wn]=buttord(wap,was,rp,rs,'s') ;
[z,p,k]=buttap(n);
[bp,ap]=zp2tf(z,p,k);
[bs,as]=lp2hp(bp,ap,wap);
[bz,az]=bilinear(bs,as,1/2);
y=filter(bz,az,x);
6) IIR带通滤波器
function [y bz az]=bandpass_iir_filter(x) rp=1; rs=15;
wp=0.35*pi; ws=0.65*pi;
wap=tan(wp/2); was=tan(ws/2);
[n,wn]=buttord(wap,was,rp,rs,'s') ; [z,p,k]=buttap(n);
[bp,ap]=zp2tf(z,p,k); [bs,as]=lp2bp(bp,ap,1,0.5);
[bz,az]=bilinear(bs,as,1/2);
y=filter(bz,az,x);
二结果:。

相关文档
最新文档