实验三.docx
- 文档编号:6290394
- 上传时间:2023-01-05
- 格式:DOCX
- 页数:22
- 大小:334.05KB
实验三.docx
《实验三.docx》由会员分享,可在线阅读,更多相关《实验三.docx(22页珍藏版)》请在冰豆网上搜索。
实验三
实验三数字信号处理综合设计(reference)
1、原始的语音信号的频谱分析:
clearall;
closeall;
[y,fs,bits]=wavread('C:
\outputfile.wav');%y音数据fs采样频率bits采样点数
n=length(y);%求出语音信号的长度
Y=fft(y,n);%傅里叶变换
subplot(2,1,1);
plot(y);%连续plot()
title('原始信号波形');
subplot(2,1,2);
plot(abs(Y));
title('原始信号频谱');
2、用窗函数法设计三种滤波器
(1)、低通滤波器
clearall;
closeall;
[z1,fs,bits]=wavread('c:
\outputfile.wav');
n=length(z1);%求出语音信号的长度
Y1=fft(z1,n);%傅里叶变换
fb=1000;fc=1200;As=100;Ap=1;Fs=8000;%设置参数
wc=2*pi*fc/Fs;
wb=2*pi*fb/Fs;
wdel=wc-wb;%过渡带的带宽
beta=0.112*(As-8.7);
N=ceil((As-8)/2.285/wdel);%估算采样的点数
wn=kaiser(N+1,beta);%凯瑟窗返回长度为(n+1)的wn,截短
ws=(wb+wc)/2/pi;%理想的通带截止频率
b=fir1(N,ws,wn);%firl函数的使用
figure
(1);
freqz(b,1);%画出频率响应曲线
x=fftfilt(b,z1);
X=fft(x,n);
figure
(2);
subplot(2,2,1);
plot(abs(Y1));
%axis([0,10000,0,20]);
title('滤波前信号频谱');
subplot(2,2,2);
plot(abs(X));
%axis([0,1000,0,2]);
title('滤波后信号频谱');
subplot(2,2,3);
plot(z1);
title('滤波前信号波形');
subplot(2,2,4);
plot(x);
title('滤波后信号波形');
%sound(x,fs,bits);
运行结果:
频率响应曲线如图:
滤波前后波形以及频谱的变化:
(2)、高通滤波器
clearall;
closeall;
[z1,fs,bits]=wavread('c:
\outputfile.wav')
n=length(z1);%求出语音信号的长度
Y1=fft(z1,n);%傅里叶变换
fc=4800;fb=5000;As=100;Ap=1;
Fs=22500;
wc=2*pi*fc/Fs;
wb=2*pi*fb/Fs;
wdel=wb-wc;
beta=0.112*(As-8.7);
N=ceil((As-8)/2.285/wdel);
wn=kaiser(N,beta);
ws=(wb+wc)/2/pi;
b=fir1(N-1,ws,'high',wn);
figure
(1);
freqz(b,1);
x=fftfilt(b,z1);
X=fft(x,n);
figure
(2);
subplot(2,2,1);plot(abs(Y1));
%axis([0,1000,0,1.0]);
title('滤波前信号频谱');
subplot(2,2,2);plot(abs(X));
%axis([0,1000,0,1.0]);
title('滤波后信号频谱');
subplot(2,2,3);plot(z1);
title('滤波前信号波形');
subplot(2,2,4);plot(x);
title('滤波后信号波形');
%sound(x,fs,bits);
(3)、带通滤波器
clearall;
closeall
[z1,fs,bits]=wavread('c:
\outputfile.wav')
n=length(z1);%求出语音信号的长度
Y1=fft(z1,n);%傅里叶变换
fb1=1200;fb2=3000;fc1=1000;
fc2=3200;As=100;Ap=1;Fs=8000
wb1=2*pi*fb1/Fs;
wc1=2*pi*fc1/Fs;
wb2=2*pi*fb2/Fs;
wc2=2*pi*fc2/Fs;
wdel=wb1-wc1;
beta=0.112*(As-8.7);
N=ceil((As-8)/2.285/wdel);
ws=[(wb1+wc1)/2/pi,(wb2+wc2)/2/pi];
wn=kaiser(N+1,beta);
b=fir1(N,ws,wn);
figure
(1);
freqz(b,1);
x=fftfilt(b,z1);
X=fft(x,n);
figure
(2);
subplot(2,2,1);plot(abs(Y1));
%axis([0,1000,0,1.0]);
title('滤波前信号频谱');
subplot(2,2,2);plot(abs(X));
%axis([0,2000,0,0.00003]);
title('滤波后信号频谱')
subplot(2,2,3);plot(z1);
title('滤波前信号波形');
subplot(2,2,4);plot(x);
title('滤波前信号波形');
%sound(x,fs,bits);
3、双线性变换法设计上面要求的三种滤波器
(1)、低通滤波器
选用butter程序设计如下:
clearall;
closeall
[z1,fs,bits]=wavread('c:
\outputfile.wav');
n=length(z1);
Y1=fft(z1,n);
fb=1000;fc=1200;As=100;Ap=1;
Fs=8000;
wc=2*fc/Fs;
wb=2*fb/Fs;
[N,ws]=buttord(wc,wb,Ap,As);
[b,a]=butter(N,ws);
figure
(1);
freqz(b,a,512,Fs);
x=filter(b,a,z1);
X=fft(x,8192);
figure
(2);
subplot(2,2,1);plot(abs(Y1));
axis([0,1000,0,15]);
title('滤波前信号频谱');
subplot(2,2,2);plot(abs(X));
axis([0,1000,0,20]);
title('滤波后信号频谱');
subplot(2,2,3);plot(z1);title('滤波前信号波形');
subplot(2,2,4);plot(x);title('滤波后信号波形');
%sound(x,fs,bits);
限定范围(频谱)
选用cheby
[n,wn]=cheb1ord(wb,wc,Ap,As);
[b,a]=cheby1(n,Ap,wn);
选用椭圆滤波器
[n,wn]=ellipord(wb,wc,Ap,As);
[b,a]=ellip(n,Ap,As,wn);
如图所示:
(2)、高通滤波器
选用butter
clearall;
closeall;
[z1,fs,bits]=wavread('c:
\outputfile.wav')
n=length(z1);
Y1=fft(z1,n);
fc=4800;fb=5000;As=100;Ap=1;
Fs=50000;
wc=2*pi*fc/Fs;
wb=2*pi*fb/Fs;
[N,ws]=buttord(wc,wb,Ap,As);
[b,a]=butter(N,ws);
b=fir1(N-1,ws,'high');
figure
(1);
freqz(b,1);
x=fftfilt(b,z1);
X=fft(x,n);
figure
(2);
subplot(2,2,1);plot(abs(Y1));
%axis([0,1000,0,1.0]);
title('滤波前信号频谱');
subplot(2,2,2);plot(abs(X));
%axis([0,1000,0,1.0]);
title('滤波后信号频谱');
subplot(2,2,3);plot(z1);
title('滤波前信号波形');
subplot(2,2,4);plot(x);
title('滤波后信号波形');
%sound(x,fs,bits);
运行结果:
fs=
44100
bits=
16
选用cheby
[n,wn]=cheb1ord(wb,wc,Ap,As);
[b,a]=cheby1(n,Ap,wn);
选用椭圆滤波器
[n,wn]=ellipord(wb,wc,Ap,As);
[b,a]=ellip(n,Ap,As,wn);
(3)、带通滤波器
Butter滤波器
clearall;
closeall
[z1,fs,bits]=wavread('c:
\outputfile.wav')
n=length(z1);%求出语音信号的长度
Y1=fft(z1,n);%傅里叶变换
fb1=1200;fb2=3000;fc1=1000;fc2=3200;As=100;Ap=1;
Fs=22500;
wb1=2*pi*fb1/Fs;
wc1=2*pi*fc1/Fs;
wb2=2*pi*fb2/Fs;
wc2=2*pi*fc2/Fs;
wc=[wc1,wc2];
wb=[wb1,wb2];
[N,ws]=buttord(wc,wb,Ap,As);
[b,a]=butter(N,ws);
b=fir1(N,ws);
figure
(1);
freqz(b,1);
x=fftfilt(b,z1);
X=fft(x,n);
figure
(2);
subplot(2,2,1);plot(abs(Y1));
%axis([0,1000,0,1.0]);
title('滤波前信号频谱');
subplot(2,2,2);plot(abs(X));
%axis([0,2000,0,0.00003]);
title('滤波后信号频谱')
subplot(2,2,3);plot(z1);
title('滤波前信号波形');
subplot(2,2,4);plot(x);
title('滤波后信号波形');
%sound(x,fs,bits);
运行结果:
fs=
44100
bits=
16
切比雪夫滤波器
[N,wn]=cheb1ord(wb,wc,Ap,As);
[b,a]=cheby1(N,Ap,wn);
b=fir1(N,wn);
椭圆滤波器
[N,wn]=ellipord(wb,wc,Ap,As);
[b,a]=ellip(N,Ap,As,wn);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 实验