【濾波器】基于低通、帶通、高通濾波器實(shí)現(xiàn)語音去噪含Matlab源碼
1 簡介
在本文中,我們分別研究了在MATLAB環(huán)境下IIR數(shù)字濾波器的典型設(shè)計(jì)和完全設(shè)計(jì)等方法。?典型設(shè)計(jì)是先按一定規(guī)則將給出的數(shù)字濾波器的技術(shù)指標(biāo)轉(zhuǎn)換成模擬低通濾波器的技術(shù)指標(biāo),據(jù)此產(chǎn)生模擬濾波器原型,然后把模擬低通濾波器原型轉(zhuǎn)換成模擬低通、高通、帶通濾波器,最后再把模擬濾波器轉(zhuǎn)換成數(shù)字濾波器。?完全設(shè)計(jì)方法中我們利用函數(shù)直接設(shè)計(jì)出低通、高通、帶通濾波器,并分別用巴特沃斯(Butterworth)濾波器來實(shí)現(xiàn)語音去噪。
2 部分代碼
function varargout = AMtiaozhi(varargin)
% AMTIAOZHI M-file for AMtiaozhi.fig
% ? ? ?AMTIAOZHI, by itself, creates a new AMTIAOZHI or raises the existing
% ? ? ?singleton*.
%
% ? ? ?H = AMTIAOZHI returns the handle to a new AMTIAOZHI or the handle to
% ? ? ?the existing singleton*.
%
% ? ? ?AMTIAOZHI('CALLBACK',hObject,eventData,handles,...) calls the local
% ? ? ?function named CALLBACK in AMTIAOZHI.M with the given input arguments.
%
% ? ? ?AMTIAOZHI('Property','Value',...) creates a new AMTIAOZHI or raises the
% ? ? ?existing singleton*. ?Starting from the left, property value pairs are
% ? ? ?applied to the GUI before AMtiaozhi_OpeningFunction gets called. ?An
% ? ? ?unrecognized property name or invalid value makes property application
% ? ? ?stop. ?All inputs are passed to AMtiaozhi_OpeningFcn via varargin.
%
% ? ? ?*See GUI Options on GUIDE's Tools menu. ?Choose "GUI allows only one
% ? ? ?instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help AMtiaozhi
% Last Modified by GUIDE v2.5 10-May-2010 16:42:40
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', ? ? ? mfilename, ...
? ? ? ? ? ? ? ? ? 'gui_Singleton', ?gui_Singleton, ...
? ? ? ? ? ? ? ? ? 'gui_OpeningFcn', @AMtiaozhi_OpeningFcn, ...
? ? ? ? ? ? ? ? ? 'gui_OutputFcn', ?@AMtiaozhi_OutputFcn, ...
? ? ? ? ? ? ? ? ? 'gui_LayoutFcn', ?[] , ...
? ? ? ? ? ? ? ? ? 'gui_Callback', ? []);
if nargin & isstr(varargin{1})
? ?gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
? ?[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
? ?gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before AMtiaozhi is made visible.
function AMtiaozhi_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject ? ?handle to figure
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ? ?structure with handles and user data (see GUIDATA)
% varargin ? command line arguments to AMtiaozhi (see VARARGIN)
% Choose default command line output for AMtiaozhi
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes AMtiaozhi wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = AMtiaozhi_OutputFcn(hObject, eventdata, handles)
% varargout ?cell array for returning output args (see VARARGOUT);
% hObject ? ?handle to figure
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ? ?structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject ? ?handle to popupmenu1 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ? ?empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% ? ? ? See ISPC and COMPUTER.
if ispc
? ?set(hObject,'BackgroundColor','white');
else
? ?set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
set(hObject, 'String', {'調(diào)制信號', '載波信號','已調(diào)波信號'});
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject ? ?handle to popupmenu1 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ? ?structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
% ? ? ? ?contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject ? ?handle to popupmenu2 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ? ?empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% ? ? ? See ISPC and COMPUTER.
if ispc
? ?set(hObject,'BackgroundColor','white');
else
? ?set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
set(hObject, 'String', {'高通濾波', '低通濾波','帶通濾波'});
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject ? ?handle to popupmenu2 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ? ?structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array
% ? ? ? ?contents{get(hObject,'Value')} returns selected item from popupmenu2
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
popup_sel_index = get(handles.popupmenu1, 'Value');
switch popup_sel_index
? ?case 1
? ? ? ?dt=0.01;
? ? ? ?t=0:dt:10;Fs=1/dt;
? ? ? ?e=sinc(t-5);%調(diào)制信號
? ? ? ?elength=length(e);%求采樣點(diǎn)個(gè)數(shù)
? ? ? ?E=fft(e,elength);%快速傅里葉變換
? ? ? ?%fe=-Fs/2:elength:Fs/2;
? ? ? ?En=fftshift(E);%對fft輸出進(jìn)行重新排列,將零頻分量移到頻譜中心
? ? ? ?axes(handles.axes1);
? ? ? ?plot(t,e);title('調(diào)制信號');
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?xlabel('時(shí)間s');
? ? ? ?ylabel('強(qiáng)度值');
? ? ? ?axis([0 10 1.1*min(e) 1.1*max(e)]);
? ? ? ?axes(handles.axes2);
? ? ? ?plot(abs(En));title('調(diào)制信號頻譜');
? ? ? ?axis([0 1000 1.1*min(abs(En)) 1.1*max(abs(En))]);
? ? ? ?set(handles.axes2,'Xticklabel',[-50,-30,-10,10,30,50])
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?xlabel('頻率Hz');
? ? ? ?ylabel('幅度值');
? ?case 2
? ? ? ?dt=0.01;
? ? ? ?t=0:dt:10;Fs=1/dt;
? ? ? ?s=cos(60*pi*t)+cos(40*pi*t)+cos(20*pi*t);%載波信號
? ? ? ?slength=length(s);%求采樣點(diǎn)個(gè)數(shù)
? ? ? ?S=fft(s);%快速傅里葉變換
? ? ? ?%fs=linspace(-Fs/2,Fs/2,slength);
? ? ? ?Sn=fftshift(S);
? ? ? ?axes(handles.axes3);
? ? ? ?plot(t,s);title('載波信號');
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?xlabel('時(shí)間s');
? ? ? ?ylabel('強(qiáng)度值');
? ? ? ?axes(handles.axes4);plot(abs(Sn));title('載波信號頻譜');
? ? ? ? ? ? ? ?axis([0 1000 1.1*min(abs(Sn)) 1.1*max(abs(Sn))]);
? ? ? ?set(handles.axes4,'Xticklabel',[-50,-30,-10,10,30,50])
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?xlabel('頻率Hz');
? ? ? ?ylabel('幅度值');
? ?case 3
? ? ? ?dt=0.01;
? ? ? ?t=0:dt:10;Fs=1/dt;
? ? ? ?s=cos(60*pi*t)+cos(40*pi*t)+cos(20*pi*t);%載波信號
? ? ? ?e=sinc(t-5);%調(diào)制信號
? ? ? ?p=e.*s;%調(diào)制
? ? ? ?plength=length(p);
? ? ? ?P=fft(p);
? ? ? ?%fp=linspace(-Fs/2,Fs/2,plength);
? ? ? ?Pn=fftshift(P);
? ? ? ?axes(handles.axes5);
? ? ? ?plot(t,p);title('調(diào)幅信號');
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?xlabel('時(shí)間s');
? ? ? ?ylabel('強(qiáng)度值');
? ? ? ?axis([0 10 1.1*min(p) 1.1*max(p)]);
? ? ? ?axes(handles.axes6);
? ? ? ?plot(abs(Pn));title('調(diào)幅信號頻譜');
? ? ? ? ? ? ? ? ? ? ? ?axis([0 1000 1.1*min(abs(Pn)) 1.1*max(abs(Pn))]);
? ? ? ?set(handles.axes6,'Xticklabel',[-50,-30,-10,10,30,50])
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?xlabel('頻率Hz');
? ? ? ?ylabel('幅度值');
end
% hObject ? ?handle to pushbutton1 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ? ?structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
p
end
% hObject ? ?handle to pushbutton2 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ? ?structure with handles and user data (see GUIDATA)
3 仿真結(jié)果



4 參考文獻(xiàn)
[1]王蔚. MATLAB環(huán)境下的數(shù)字濾波器設(shè)計(jì)及其應(yīng)用[D]. 蘇州大學(xué), 2002.
博主簡介:擅長智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測、信號處理、元胞自動(dòng)機(jī)、圖像處理、路徑規(guī)劃、無人機(jī)等多種領(lǐng)域的Matlab仿真,相關(guān)matlab代碼問題可私信交流。
部分理論引用網(wǎng)絡(luò)文獻(xiàn),若有侵權(quán)聯(lián)系博主刪除。
