function varargout = filterfile(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @filterfile_OpeningFcn, ...
'gui_OutputFcn', @filterfile_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 filterfile is made visible.
function filterfile_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for filterfile
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = filterfile_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on selection change in algotype.
function algotype_Callback(hObject, eventdata, handles)
% Hints: contents = get(hObject,'String') returns algotype contents as cell array
% contents{get(hObject,'Value')} returns selected item from algotype
s=1;
s = get(hObject,'Value');
assignin('base','s',s);
handles.s=s;
switch(s)
case(1)
set(handles.pass,'Enable','off');
set(handles.pr,'Enable','off');
set(handles.stop,'Enable','off');
set(handles.sr,'Enable','off');
case(2)
set(handles.pass,'Enable','on');
set(handles.pr,'Enable','on');
set(handles.stop,'Enable','off');
set(handles.sr,'Enable','off');
otherwise
set(handles.pass,'Enable','on');
set(handles.pr,'Enable','on');
set(handles.stop,'Enable','on');
set(handles.sr,'Enable','on');
end
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function algotype_CreateFcn(hObject, eventdata, handles)
% Hint: popupmenu controls usually have a white background on Windows.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in filtertype.
function filtertype_Callback(hObject, eventdata, handles)
% Hints: contents = get(hObject,'String') returns filtertype contents as cell array
% contents{get(hObject,'Value')} returns selected item from filtertype
s1=1;
s1 = get(hObject,'Value');
handles.s1=s1;
switch(s1)
case(1)
set(handles.low,'Enable','on');
set(handles.lf,'Enable','on');
set(handles.high,'Enable','off');
set(handles.hf,'Enable','off');
case(2)
set(handles.high,'Enable','on');
set(handles.hf,'Enable','on');
set(handles.low,'Enable','off');
set(handles.lf,'Enable','off');
otherwise
set(handles.high,'Enable','on');
set(handles.hf,'Enable','on');
set(handles.low,'Enable','on');
set(handles.lf,'Enable','on');
end
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function filtertype_CreateFcn(hObject, eventdata, handles)
% Hint: popupmenu controls usually have a white background on Windows.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in order.
function order_Callback(hObject, eventdata, handles)
% Hints: contents = get(hObject,'String') returns order contents as cell array
% contents{get(hObject,'Value')} returns selected item from order
ord = get(hObject,'Value');
handles.ord=ord;
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function order_CreateFcn(hObject, eventdata, handles)
% Hint: popupmenu controls usually have a white background on Windows.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in okbutton.
function okbutton_Callback(hObject, eventdata, handles)
final=(handles.s*10)+handles.s1;
handles.final=final;
Fs = evalin('base', 'Fs');
handles.Fs=Fs;
switch(final)
case(11)
fpass = str2num(get(handles.lf,'String'));
n=handles.ord +1;
wn=fpass*2/handles.Fs;
[b,a]=butter(n,wn,'low');
case(12)
fpass = str2num(get(handles.hf,'String'));
n=handles.ord +1;
wn=fpass*2/handles.Fs;
[b,a]=butter(n,wn,'high');
case(13)
fpass = str2num(get(handles.lf,'String'));
fstop = str2num(get(handles.hf,'String'));
n=handles.ord +1;
wp=fpass*2/handles.Fs;
ws=fstop*2/handles.Fs;
[b,a]=butter(n,[wp ws],'bandpass');
case(14)
fpass = str2num(get(handles.lf,'String'));
fstop = str2num(get(handles.hf,'String'));
n=handles.ord +1;
wp=fpass*2/handles.Fs;
ws=fstop*2/handles.Fs;
[b,a]=butter(n,[wp ws],'stop');
case(21)
fpass = str2num(get(handles.lf,'String'));
r=str2num(get(handles.pass,'String'));
n=handles.ord +1;
wn=fpass*2/handles.Fs;
[b,a]=cheby1(n,r,wn,'low');
case(22)
fpass = str2num(get(handles.hf,'String'));
r=str2num(get(handles.pass,'String'));
n=handles.ord +1;
wn=fpass*2/handles.Fs;
[b,a]=cheby1(n,r,wn,'high');
case(23)
fpass = str2num(get(handles.lf,'String'));
fstop = str2num(get(handles.hf,'String'));
r=str2num(get(handles.pass,'String'));
n=handles.ord +1;
wp=fpass*2/handles.Fs;
ws=fstop*2/handles.Fs;
[b,a]=cheby1(n,r,[wp ws],'bandpass');
case(24)
fpass = str2num(get(handles.lf,'String'));
fstop = str2num(get(handles.hf,'String'));
r=str2num(get(handles.pass,'String'));
n=handles.ord +1;
wp=fpass*2/handles.Fs;
ws=fstop*2/handles.Fs;
[b,a]=cheby1(n,r,[wp ws],'stop');
case(31)
fpass = str2num(get(handles.lf,'String'));
rp=str2num(get(handles.pass,'String'));
rs=str2num(get(handles.stop,'String'));
n=handles.ord +1;
wn=fpass*2/handles.Fs;
[b,a]=ellip(n,rp,rs,wn,'low');
case(32)
fpass = str2num(get(handles.hf,'String'));
rp=str2num(get(handles.pass,'String'));
rs=str2num(get(handles.stop,'String'));
n=handles.ord +1;
wn=fpass*2/handles.Fs;
[b,a]=ellip(n,rp,rs,wn,'high');
case(33)
fpass = str2num(get(handles.lf,'String'));
fstop = str2num(get(handles.hf,'String'));
rp=str2num(get(handles.pass,'String'));
rs=str2num(get(handles.stop,'String'));
n=handles.ord +1;
wp=fpass*2/handles.Fs;
ws=fstop*2/handles.Fs;
[b,a]=ellip(n,rp,rs,[wp ws],'bandpass');
case(34)
fpass = str2num(get(handles.lf,'String'));
fstop = str2num(get(handles.hf,'String'));
rp=str2num(get(handles.pass,'String'));
rs=str2num(get(handles.stop,'String'));
n=handles.ord +1;
wp=fpass*2/handles.Fs;
ws=fstop*2/handles.Fs;
[b,a]=ellip(n,rp,rs,[wp ws],'stop');
end
x = evalin('base', 'x');
handles.x=x;
x1=filter(b,a,handles.x);
assignin('base','x1',x1);
assignin('base','b',b);
assignin('base','a',a);
guidata(hObject, handles);
filterdsound(handles);
function lf_Callback(hObject, eventdata, handles)
% Hints: get(hObject,'String') returns contents of lf as text
% str2double(get(hObject,'String')) returns contents of lf as a double
% --- Executes during object creation, after setting all properties.
function lf_CreateFcn(hObject, eventdata, handles)
% Hint: edit controls usually have a white background on Windows.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function hf_Callback(hObject, eventdata, handles)
% Hints: get(hObject,'String') returns contents of hf as text
% str2double(get(hObject,'String')) returns contents of hf as a double
% --- Executes during object creation, after setting all properties.
function hf_CreateFcn(hObject, eventdata, handles)
% Hint: edit controls usually have a white background on Windows.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function pass_Callback(hObject, eventdata, handles)
% Hints: get(hObject,'String') returns contents of pass as text
% str2double(get(hObject,'String')) returns contents of pass as a double
% --- Executes during object creation, after setting all properties.
function pass_CreateFcn(hObject, eventdata, handles)
% Hint: edit controls usually have a white background on Windows.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function stop_Callback(hObject, eventdata, handles)
% Hints: get(hObject,'String') returns contents of stop as text
% str2double(get(hObject,'String')) returns contents of stop as a double
% --- Executes during object creation, after setting all properties.
function stop_CreateFcn(hObject, eventdata, handles)
% Hint: edit controls usually have a white background on Windows.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end