中南数字信号处理课程设计

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

i=1;[x,fs,bits]=wavread('hello.wav');%x:语音数据;fs:采样频率;bits:采样点数sound(x,fs,bits);%语音回放n=0:N-1;figure(i);subplot(2,1,1);plot(n,x);%画出原始语音信号的波形xlabel('n');ylabel('x(n)');title('原始语音信号');subplot(2,1,2);[H,f]=freqz(x,1,512,fs);plot(f,20*log10(abs(H)));%画出原始语音信号的频谱xlabel('n');ylabel('x(n)');title('原始语音信号的频谱');抽取因子D=2对此语音信号进行抽取D=2;y1=decimate(x,D);N=length(y1);n=0:N-1;figure(i);subplot(2,1,1);plot(n,y1);%画出语音信号的波形xlabel('n');ylabel('y1(n)');title('D=2时语音信号');subplot(2,1,2);[H]=freqz(y1,1,512,fs);plot(f,20*log10(abs(H)));%画出语音信号的频谱xlabel('n');ylabel('y1(n)');title('D=2时语音信号的频谱');按内插因子I=2进行内插I=2;y2=interp(y1,I);N=length(y2);n=0:N-1;figure(i);subplot(2,1,1);plot(n,y2);%画出语音信号的波形xlabel('n');ylabel('y2(n)');title('I=2时语音信号');subplot(2,1,2);[H,f]=freqz(y2,1,512,fs);plot(f,20*log10(abs(H)));%画出语音信号的频谱xlabel('n');ylabel('y2(n)');title('I=2时语音信号的频谱');低通滤波器的设计fp=1000;fs=1200;Fs=11025;%确定技术指标Ap=1;As=10;wp=2*pi*fp/Fs;%归一化,求得数字边缘频率ws=2*pi*fs/Fs;Ts=1/Fs;wap=2/Ts*tan(wp/2);%将数字指标转换成模拟指标was=2/Ts*tan(ws/2);[N,wc]=buttord(wap,was,Ap,As,'s');%选择滤波器的最小阶数[z,p,k]=buttap(N);%创建butterworth模拟滤波器[Bap,Aap]=zp2tf(z,p,k);[b,a]=lp2lp(Bap,Aap,wc);[bz,az]=bilinear(b,a,Fs);%用双线性变换法实现模拟滤波器到数字滤波器的转换[H,w]=freqz(bz,az);figure(1);plot(w*Fs/(2*pi),20*log10(abs(H)));%绘制频率响应曲线grid;axis([0,3000,-20,2]);xlabel('频率/Hz');ylabel('幅度/dB');title('巴特沃兹低通滤波器');读入一段语音信号[x1,fs,bits]=wavread('hello.wav');sound(x1,fs,bits);y4=fft(x1);figure(1);subplot(2,1,1)plot(x1);title('原始语音信号时域波形');axis([010000-11]);subplot(2,1,2)plot(abs(y4));title('原始语音信号频谱');axis([03276801500])在语音信号中加入噪声:[x1,fs,bits]=wavread('hello.wav');y4=fft(x1,32768);x2=awgn(x1,10);%加白噪声%sound(x2,fs,bits);%回放加噪声后的语音y5=fft(x2,32768);f=0:fs/32768:fs/32768*32767;figure(2);subplot(3,2,1)plot(x2);title('加高斯白噪声语音信号的时域波形');axis([010000-22]);subplot(3,2,2);plot(f,abs(y5));xlabel('频率(Hz)');ylabel('幅度(dB)');title('加高斯白噪声语音信号的频谱');axis([03276801500]);N=length(x1)-1;t=0:1/fs:N/fs;d=[0.09*sin(2*pi*5000*t)]';x3=x1+d;%加单频正弦信号%sound(x3,fs,bits);f=0:fs/32768:fs/32768*32767;subplot(3,2,3);plot(x3);title('加单频正弦信号的语音信号时域波形');axis([010000-22]);y6=fft(x3,32768);subplot(3,2,4);plot(f,abs(y6));xlabel('频率(Hz)');ylabel('幅度(dB)');title('加单频正弦信号的语音信号频谱');axis([03276801500]);N=length(x1)-1;t=0:1/fs:N/fs;a=[0.09*sin(2*pi*2000*t)]';b=[0.09*sin(2*pi*3000*t)]';c=[0.09*sin(2*pi*3500000*t)]';x4=x1+a+b+c;%加多个正弦干扰%sound(x4,fs,bits);y7=fft(x4,32768);subplot(3,2,5);plot(x3);title('加多个正弦干扰语音信号时域波形');axis([010000-22]);subplot(3,2,6);plot(f,abs(y7));xlabel('频率(Hz)');ylabel('幅度(dB)');title('加多个正弦干扰信号的语音信号频谱');axis([03276801500]);多正弦干扰信号通过凯撒窗低通滤波器滤波fp=1000;Fs=1800;As=40;Ap=0.25;wp=2*pi*fp/fs;ws=2*pi*Fs/fs;Bt=ws-wp;alph=0.5842*(As-21)^0.4+0.07886*(As-21);M=ceil((As-8)/2.285/Bt);wc=(wp+ws)/2/pi;hn=fir1(M,wc,kaiser(M+1,alph));hk=fft(hn);hk=freqz(hn,1,Fs);xn3=fftfilt(hn,x4);sound(xn3,fs,bits);yn3=fft(xn3);figure(3);subplot(2,1,1);plot(xn3);title('多正弦干扰滤波后信号波形');axis([010000-22]);subplot(2,1,2);plot(abs(yn3));title('多正弦干扰滤波后信号频谱');axis([01000001500]);figure(4);subplot(2,1,1);stem(hn);title('凯撒窗hn波形');subplot(2,1,2);plot(abs(hk));title('凯撒窗hn信号频谱');sound(xn3,Fs,bits);修改过程序及频谱图像问题二1、读取语音信号[x,fs,bits]=wavread('away.wav');%x:语音数据;fs:采样频率;bits:采样点数sound(x,fs,bits);%语音回放N=length(x);n=0:N-1;figure(1);subplot(2,1,1);plot(n,x);%画出原始语音信号的波形xlabel('n');ylabel('x(n)');title('原始语音信号');subplot(2,1,2);[H,f]=freqz(x,1,512,fs);plot(f,20*log10(abs(H)));%画出原始语音信号的频谱xlabel('n');ylabel('x(n)');title('原始语音信号的频谱');020004000600080001000012000140001600018000-1-0.500.51nx(n)原始语音信号020004000600080001000012000-50050100nx(n)原始语音信号的频谱2、按抽取因子D=2进行抽取,降低信号采样率,使得数据量减少。D=2;y1=decimate(x,D);N=length(y1);n=0:N-1;figure(i);subplot(2,1,1);plot(n,y1);%画出语音信号的波形xlabel('n');ylabel('y1(n)');title('D=2时语音信号');subplot(2,1,2);[H,f]=freqz(y1,1,512,fs);plot(f,20*log10(abs(H)));%画出语音信号的频谱xlabel('n');ylabel('y1(n)');title('D=2时语音信号的频谱');0100020003000400050006000700080009000-1-0.500.51ny1(n)D=2时语音信号020004000600080001000012000-50050ny1(n)D=2时语音信号的频谱3、按内插因子I=2进行内插,将采样率提高2倍I=2;y2=interp(y1,I);N=length(y2);n=0:N-1;figure(i);subplot(2,1,1);plot(n,y2);%画出语音信号的波形xlabel('n');ylabel('y2(n)');title('I=2时语音信号');subplot(2,1,2);[H,f]=freqz(y2,1,512,fs);plot(f,20*log10(abs(H)));%画出语音信号的频谱xlabel('n');ylabel('y2(n)');title('I=2时语音信号的频谱');020004000600080001000012000140001600018000-1-0.500.51ny2(n)I=2时语音信号020004000600080001000012000-50050100ny2(n)I=2时语音信号的频谱4、设计模拟低通滤波器恢复出语音信号fp=1000;fs=1200;Fs=22050;%确定技术指标Ap=1;As=10;wp=2*pi*fp/Fs;%归一化,求得数字边缘频率ws=2*pi*fs/Fs;Ts=1/Fs;wap=2/Ts*tan(wp/2);%将数字指标转换成模拟指标was=2/Ts*tan(ws/2);[N,wc]=buttord(wap,was,Ap,As,'s');%选择滤波器的最小阶数[z,p,k]=buttap(N);%创建butterworth模拟滤波器[Bap,Aap]=zp2tf(z,p,k);[b,a]=lp2lp(Bap,Aap,wc);[bz,az]=bilinear(b,a,Fs);%用双线性变换法实现模拟滤波器到数字滤波器的转换[H,w]=freqz(bz,az);figure(1);plot(w*Fs/(2*pi),20*log10(abs(H)));%绘制频率响应曲线grid;axis([0,3000,-20,2]);xlabel('频率/Hz');ylabel('幅度/dB');title('巴特沃兹低通滤波器');050010001500200025003000-20-18-16-14-12-10-8-6-4-202频率/Hz幅度/dB巴特沃兹低通滤波器5、回放语音信号,比较它们之间的区别sound(x,22050);y3=filter(bz,az,y2);sound(y3,Fs);给出各个设计环节信号的时域波形和频域波形已经在各小问中给出图像进一步做FFTY2=fft(y2,1024)

1 / 18
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功