hao.zip

  • 时而学习之
    了解作者
  • matlab
    开发工具
  • 588KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 10 积分
    下载积分
  • 1
    下载次数
  • 2016-11-01 11:21
    上传日期
对音频信号进行滤波,适用不同的窗函数,程序中可以自己录取声音,也可以加载已有的音频文件
hao.zip
  • hao
  • Bin.wav
    78.2KB
  • Hao.fig
    31.4KB
  • Rui.wav
    78.2KB
  • afd_buttap.m
    447B
  • HaoRuibin.fig
    15.6KB
  • UntilYou.mp3
    440.8KB
  • buttap_o.m
    183B
  • HaoRuibin.m
    5.9KB
  • Hao.m
    8.5KB
  • freqz_m.m
    242B
  • ideal_lp.m
    140B
内容介绍
function varargout = Hao(varargin) % HAO MATLAB code for Hao.fig % HAO, by itself, creates a new HAO or raises the existing % singleton*. % % H = HAO returns the handle to a new HAO or the handle to % the existing singleton*. % % HAO('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in HAO.M with the given input arguments. % % HAO('Property','Value',...) creates a new HAO or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before Hao_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to Hao_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 Hao % Last Modified by GUIDE v2.5 05-Jun-2015 18:41:41 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Hao_OpeningFcn, ... 'gui_OutputFcn', @Hao_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(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 Hao is made visible. function Hao_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 Hao (see VARARGIN) % Choose default command line output for Hao handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes Hao wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = Hao_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 on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % 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) Fs=8000; % 用哈明窗函数法来设计FIR滤波器 选N=51 wp=0.2*pi; ws=0.35*pi; N=51; n=[0:1:N-1]; wc=(ws+wp)/2; % 理想低通的截止频率 hd=ideal_lp(wc,N); % 理想低通的冲激响应 w_ham=(boxcar(N))'; h=hd.*w_ham % FIR滤波器的冲激响应 [db,mag,pha,grd,w]=freqz_m(h,[1]); delta_w=2*pi/1000; Rp=-(min(db(1:1:wp/delta_w+1))); % 实际的通带衰减 As=-round(max(db(ws/delta_w+1:1:501))); % 实际的阻带衰减 filename='U.mp3'; [y1,Fs]=audioread(filename); y=filter(h,[1],y1);Y=fft(y); filename='li.wav'; audiowrite('li.wav',y,Fs); axes(handles.axes1); plot(y);grid; axes(handles.axes2); plot(abs(Y));grid; filename='li.wav'; [x,Fs]=audioread(filename); sound(x,Fs); % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % 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) Fs=8000; % 用哈明窗函数法来设计FIR滤波器 选N=51 wp=0.2*pi; ws=0.35*pi; N=51; n=[0:1:N-1]; wc=(ws+wp)/2; % 理想低通的截止频率 hd=ideal_lp(wc,N); % 理想低通的冲激响应 w_ham=(bartlett(N))'; h=hd.*w_ham % FIR滤波器的冲激响应 [db,mag,pha,grd,w]=freqz_m(h,[1]); delta_w=2*pi/1000; Rp=-(min(db(1:1:wp/delta_w+1))); % 实际的通带衰减 As=-round(max(db(ws/delta_w+1:1:501))); % 实际的阻带衰减 filename='U.mp3'; [y1,Fs]=audioread(filename); y=filter(h,[1],y1);Y=fft(y); filename='li.wav'; audiowrite('li.wav',y,Fs); axes(handles.axes3); plot(y);grid; axes(handles.axes4); plot(abs(Y));grid; filename='li.wav'; [x,Fs]=audioread(filename); sound(x,Fs); % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Fs=8000; % 用哈明窗函数法来设计FIR滤波器 选N=51 wp=0.2*pi; ws=0.35*pi; N=51; n=[0:1:N-1]; wc=(ws+wp)/2; % 理想低通的截止频率 hd=ideal_lp(wc,N); % 理想低通的冲激响应 w_ham=(hanning(N))'; h=hd.*w_ham % FIR滤波器的冲激响应 [db,mag,pha,grd,w]=freqz_m(h,[1]); delta_w=2*pi/1000; Rp=-(min(db(1:1:wp/delta_w+1))); % 实际的通带衰减 As=-round(max(db(ws/delta_w+1:1:501))); % 实际的阻带衰减 filename='U.mp3'; [y1,Fs]=audioread(filename); y=filter(h,[1],y1);Y=fft(y); filename='li.wav'; audiowrite('li.wav',y,Fs); axes(handles.axes5); plot(y);grid; axes(handles.axes6); plot(abs(Y));grid; filename='li.wav'; [x,Fs]=audioread(filename); sound(x,Fs); % --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Fs=8000; % 用哈明窗函数法来设计FIR滤波器 选N=51 wp=0.2*pi; ws=0.35*pi; N=51; n=[0:1:N-1]; wc=(ws+wp)/2; % 理想低通的截止频率 hd=ideal_lp(wc,N); % 理想低通的冲激响应 w_ham=(hamming(N))'; h=hd.*w_ham % FIR滤波器的冲激响应 [db,mag,pha,grd,w]=freqz_m(h,[1]); delta_w=2*pi/1000; Rp=-(min(db(1:1:wp/delta_w+1))); % 实际的通带衰减 As=-round(max(db(ws/delta_w+1:1:501))); % 实际的阻带衰减 filename='U.mp3'; [y1,Fs]=audioread(filename); y=filter(h,[1],y1);Y=fft(y); filename='li.wav'; audiowrite('li.wav',y,Fs); axes(handles.axes7); plot(y);grid; axes(handles.axes8); plot(abs(Y));grid; filename='li.wav'; [x,Fs]=audioread(filename); sound(x,Fs); % --- Executes on button press in pushbutton5. function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Fs=8000; % 用哈明窗函数法来设计FIR滤波器 选N=51 wp=0.2*pi; ws=0.35*pi; N=51; n=[0:1:N-1]; wc=(ws+wp)/2; % 理想低通的截止频率 hd=ideal_lp(wc,N); % 理想低通的冲激响应 w_ham=(blackman(N))'; h=hd.*w_ham % FIR滤波器的冲激响应 [db,mag,pha,grd,w]=freqz_m(h,[1]); delta_w=2*pi/1000; Rp=-(min(db(1:1:wp/delta_w+1))); % 实际的通带衰减 As=-round(max(db(ws/delta_w+1:1:501))); % 实际的阻带衰减 filename='U.mp3'; [y1,Fs]=audioread(filename); y=filter(h,[1],y1);Y=fft(y); filename='li.wav'; audiowrite('li.wav',y,Fs); axes(handles.axes9); plot(y);grid; axes(handles.axes10); plot(abs(Y));grid; filename='li.wav'; [x,Fs]=audioread(filename); sound(x,Fs); % --- Executes on button press in pushbutton6. function pushbutton6_Callback(hObject, eventdata, handles) % hObject handle to pushbutton6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Fs=8000; % 用哈明窗函数法来设计FIR滤波器 选N=51 wp=0.2*pi; ws=0.35*pi; N=51; n=[0:1:N-1]; wc=(ws+wp)/2; % 理想低通的截止频率 hd=ideal_lp(wc,N); % 理想低通的冲激响应 w_ham=(kaiser(N,8))'; h=hd.*w_ham % FIR滤波器的冲激响应 [db,mag,pha,grd,w]=freqz_m(h,[1]); delta_w=2*pi/1000; Rp=-(min(db(1:1:wp/delta_w+1))); % 实际的通带衰减 As=-round(max(db(ws/delta_w+1:1:501))); % 实际的阻带衰减 filename='U.mp3'; [y
评论
    相关推荐