matlab代码语音信号分析和去噪处理docWord文档下载推荐.docx
《matlab代码语音信号分析和去噪处理docWord文档下载推荐.docx》由会员分享,可在线阅读,更多相关《matlab代码语音信号分析和去噪处理docWord文档下载推荐.docx(16页珍藏版)》请在冰豆网上搜索。
2014.7.3~2014.7.6:
设计模块划分、实现及各模块调试、验证。
2014.7.7~2014.7.8:
设计整体实现、调试及验证,并开始撰写报告。
2014.7.9~2014.7.10:
设计完成,课程设计报告撰写并定稿,上交。
其它
认真阅读数字信号处理课程设计报告撰写规范;
课题小组经协商好要指定组长并明确分工,形成良好团队工作氛围;
基于课题基本要求,各小组课再细化、增加要求;
课题小组每成员均需各自撰写一份课程设计报告。
附录
源码
functionvarargout=PF(varargin)
%PFMATLABcodeforPF.fig
%PF,byitself,createsanewPForraisestheexisting
%singleton*.
%
%H=PFreturnsthehandletoanewPForthehandleto
%theexistingsingleton*.
%PF('
CALLBACK'
hObject,eventData,handles,...)callsthelocal
%functionnamedCALLBACKinPF.Mwiththegiveninputarguments.
Property'
'
Value'
...)createsanewPForraisesthe
%existingsingleton*.Startingfromtheleft,propertyvaluepairsare
%appliedtotheGUIbeforePF_OpeningFcngetscalled.An
%unrecognizedpropertynameorinvalidvaluemakespropertyapplication
%stop.AllinputsarepassedtoPF_OpeningFcnviavarargin.
%*SeeGUIOptionsonGUIDE'
sToolsmenu.Choose"
GUIallowsonlyone
%instancetorun(singleton)"
.
%Seealso:
GUIDE,GUIDATA,GUIHANDLES
%EdittheabovetexttomodifytheresponsetohelpPF
%LastModifiedbyGUIDEv2.506-Jul-201411:
15:
51
%Begininitializationcode-DONOTEDIT
gui_Singleton=1;
gui_State=struct('
gui_Name'
mfilename,...
'
gui_Singleton'
gui_Singleton,...
gui_OpeningFcn'
@PF_OpeningFcn,...
gui_OutputFcn'
@PF_OutputFcn,...
gui_LayoutFcn'
[],...
gui_Callback'
[]);
ifnargin&
&
ischar(varargin{1})
gui_State.gui_Callback=str2func(varargin{1});
end
ifnargout
[varargout{1:
nargout}]=gui_mainfcn(gui_State,varargin{:
});
else
gui_mainfcn(gui_State,varargin{:
%Endinitializationcode-DONOTEDIT
%---ExecutesjustbeforePFismadevisible.
functionPF_OpeningFcn(hObject,eventdata,handles,varargin)
%Thisfunctionhasnooutputargs,seeOutputFcn.
%hObjecthandletofigure
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%varargincommandlineargumentstoPF(seeVARARGIN)
%ChoosedefaultcommandlineoutputforPF
handles.output=hObject;
%Updatehandlesstructure
guidata(hObject,handles);
%UIWAITmakesPFwaitforuserresponse(seeUIRESUME)
%uiwait(handles.figure1);
%---Outputsfromthisfunctionarereturnedtothecommandline.
functionvarargout=PF_OutputFcn(hObject,eventdata,handles)
%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);
%Getdefaultcommandlineoutputfromhandlesstructure
varargout{1}=handles.output;
%---Executesonbuttonpressinpushbutton1.
functionpushbutton1_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton1(seeGCBO)
%************语音信号采集******************
globalYLYHYKYGYY;
globalFBB;
[fn,pn,fi]=uigetfile('
*.wav'
selectawav-file'
);
%调用选择文件对话框,返回fn代表名字,pn代表路径
name=strcat(pn,fn);
[y1,Fs,bits]=wavread(name);
%采样值放在向量y中,fs表示采样频率(hz),bits表示采样位数
T=length(y1)/Fs;
set(handles.text4,'
string'
Fs);
set(handles.text12,'
T);
set(handles.text15,'
bits);
YL=y1;
YH=y1;
YK=y1;
YG=y1;
YY=y1;
BB=bits;
F=Fs;
Y=fft(y1,524288);
plot(handles.axes1,0:
1/Fs:
(length(y1)-1)/Fs,y1);
axes(handles.axes1);
legend('
原信号波形'
1);
stem(handles.axes2,0:
2*pi/524288:
2*pi-1/524288,abs(Y),'
.'
set(handles.axes2,'
ylim'
[01500],'
xlim'
[02*pi]);
axes(handles.axes2);
原信号频谱'
%************************************************
%---Executesonbuttonpressinpushbutton2.
functionpushbutton2_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton2(seeGCBO)
%*****************声音播放****************************
globalYYFBB;
y1=YY;
Fs=F;
bits=BB;
sound(YY,Fs,bits);
%播放声音
%---Executesonbuttonpressinpushbutton3.
functionpushbutton3_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton3(seeGCBO)
%*******************高斯噪声**************************
globalhzYYYG;
y1=YG;
h=0.05*randn(size(y1));
z=plus(h,y1);
Z=fft(z,524288);
stem(handles.axes4,0:
2*pi-1/524288,abs(Z),'
set(handles.axes4,'
axes(handles.axes4);
加入高斯噪声频谱'
YY=z;
%---Executesonbuttonpressinpushbutton4.
functionpushbutton4_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton4(seeGCBO)
%***************滤除高斯噪声******************
globalhzYY;
%*****************自适应算法***********************
w=[0,1];
%初始2阶加权系数
u=0.00026;
%最佳参数
fori=1:
length(z);
y(i+1)=h(i:
i+1)*w'
;
e(i+1)=z(i+1)-y(i+1);
w=w+2*u*e(i+1)*h(i:
i+1);
end;
Y=fft(e,524288);
滤除高斯噪声频谱'
YY=e;
%******************************************
%---Executesonbuttonpressinpushbutton5.
functionpushbutton5_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton5(seeGCBO)
%******************低通滤波器***********************
globalYLYYFYliYlf;
y1=YL;
%******************IIR*****************
fp=6000;
fs=8000;
Fs=44100;
rp=3;
rs=10;
wp=2*pi*fp/Fs;
ws=2*pi*fs/Fs;
op=2*tan(wp/2);
os=2*tan(ws/2);
[N,wc]=buttord(op,os,rp,rs,'
s'
[B,A]=butter(N,wc,'
[Bz,Az]=bilinear(B,A,1);
%**********FIR****************
Bt=abs(wp-ws);
N=ceil(6.6*pi/Bt);
wc=(wp+ws)/2/pi;
hn=fir1(N-1,wc,'
low'
hamming(N));
co=get(handles.popupmenu1,'
value'
ifco==2
y2=fftfilt(Bz,y1);
Yli=fft(y2,524288);
YY=y2;
stem(handles.axes4,0:
2*pi-1/524288,abs(Yli),'
set(handles.axes4,'
axes(handles.axes4);
legend('
低通滤波频谱'
elseifco==3
y3=fftfilt(hn,y1);
Ylf=fft(y3,524288);
YY=y3;
2*pi-1/524288,abs(Ylf),'
%---Executesonbuttonpressinpushbutton6.
functionpushbutton6_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton6(seeGCBO)
%*********************高通*******************
globalYHYYFYhiYhf;
y1=YH;
%*********************IIR*********************
fph=10000;
fsh=11000;
rph=3;
rsh=10;
wph=2*pi*fph/Fs;
wsh=2*pi*fsh/Fs;
oph=2*tan(wph/2);
osh=2*tan(wsh/2);
[Nh,wch]=buttord(oph,osh,rph,rsh,'
[Bh,Ah]=butter(Nh,wch,'
[Bs,As]=lp2hp(Bh,Ah,wch);
[Bzh,Azh]=bilinear(Bs,As,1);
%*******************FIR************************
Bth=abs(wph-wsh);
Nh0=ceil(6.6*pi/Bth);
Nh=Nh0+mod(Nh0+1,2);
wch=(wph+wsh)/2/pi;
hnh=fir1(Nh-1,wch,'
high'
hamming(Nh));
y3=fftfilt(Bzh,y1);
Yhi=fft(y3,524288);
2*pi-1/524288,abs(Yhi),'
高通滤波频谱'
y4=fftfilt(hnh,y1);
Yhf=fft(y4,524288);
YY=y4;
2*pi-1/524288,abs(Yhf),'
%---Executesonbuttonpressinpushbutton7.
functionpushbutton7_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton7(seeGCBO)
%***********************带通****************
%******************IIR**********************
globalYKYYYpiYpf;
y1=YK;
wpp=[60008000]*2/Fs;
wsp=[500010000]*2/Fs;
rpp=3;
rsp=20;
[N,Wn]=buttord(wpp,wsp,rpp,rsp,'
[Bp,Ap]=butter(N,Wn,'
bandpass'
%*********************FIR**********************
fpl=5000;
fph1=6000;
fsl=8000;
fsh1=10000;
wpl=2*pi*fpl/Fs;
wph1=2*pi*fph1/Fs;
wsl=2*pi*fsl/Fs;
wsh1=2*pi*fsh1/Fs;
Bthb=abs(wpl-wsl);
Nhb=ceil(6.6*pi/Bthb);
wcl=(wpl+wph1)/2/pi;
wch1=(wsl+wsh1)/2/pi;
wn=[wclwch1];
hnb=fir1(Nhb-1,wn,hamming(Nhb));
)
y3=fftfilt(Bp,y1);
Ypi=fft(y3,524288);
2*pi-1/524288,abs(Ypi),'
[040],'
带通滤波频谱'
y4=fftfilt(hnb,y1);
Ypf=fft(y4,524288);
2*pi-1/524288,abs(Ypf),'