Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function varargout = DSP_Equalizer(varargin)
- % DSP_EQUALIZER MATLAB code for DSP_Equalizer.fig
- % DSP_EQUALIZER, by itself, creates a new DSP_EQUALIZER or raises the existing
- % singleton*.
- %
- % H = DSP_EQUALIZER returns the handle to a new DSP_EQUALIZER or the handle to
- % the existing singleton*.
- %
- % DSP_EQUALIZER('CALLBACK',hObject,eventData,handles,...) calls the local
- % function named CALLBACK in DSP_EQUALIZER.M with the given input arguments.
- %
- % DSP_EQUALIZER('Property','Value',...) creates a new DSP_EQUALIZER or raises the
- % existing singleton*. Starting from the left, property value pairs are
- % applied to the GUI before DSP_Equalizer_OpeningFcn gets called. An
- % unrecognized property name or invalid value makes property application
- % stop. All inputs are passed to DSP_Equalizer_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 DSP_Equalizer
- % Last Modified by GUIDE v2.5 13-May-2019 22:10:28
- % Begin initialization code - DO NOT EDIT
- gui_Singleton = 1;
- gui_State = struct('gui_Name', mfilename, ...
- 'gui_Singleton', gui_Singleton, ...
- 'gui_OpeningFcn', @DSP_Equalizer_OpeningFcn, ...
- 'gui_OutputFcn', @DSP_Equalizer_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 DSP_Equalizer is made visible.
- function DSP_Equalizer_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 DSP_Equalizer (see VARARGIN)
- % Choose default command line output for DSP_Equalizer
- global C Fs;
- Fs=str2double(get(handles.samplefreq,'string'));
- if isempty(Fs)
- Fs = 40000;
- set(handles.samplefreq,'string',40000)
- end
- C=zeros(1,9);
- set(handles.slider1,'min',-25);
- set(handles.slider1,'max',25);
- set(handles.slider1,'value',0);
- set(handles.slider1,'SliderStep',[0.025,0.05]);
- set(handles.slider1,'string',num2str(0));
- set(handles.slider2,'min',-25);
- set(handles.slider2,'max',25);
- set(handles.slider2,'value',0);
- set(handles.slider2,'SliderStep',[0.025,0.05]);
- set(handles.slider2,'string',num2str(0));
- set(handles.slider3,'min',-25);
- set(handles.slider3,'max',25);
- set(handles.slider3,'value',0);
- set(handles.slider3,'SliderStep',[0.025,0.05]);
- set(handles.slider3,'string',num2str(0));
- set(handles.slider4,'min',-25);
- set(handles.slider4,'max',25);
- set(handles.slider4,'value',0);
- set(handles.slider4,'SliderStep',[0.025,0.05]);
- set(handles.slider4,'string',num2str(0));
- set(handles.slider5,'min',-25);
- set(handles.slider5,'max',25);
- set(handles.slider5,'value',0);
- set(handles.slider5,'SliderStep',[0.025,0.05]);
- set(handles.slider5,'string',num2str(0));
- set(handles.slider6,'min',-25);
- set(handles.slider6,'max',25);
- set(handles.slider6,'value',0);
- set(handles.slider6,'SliderStep',[0.025,0.05]);
- set(handles.slider6,'string',num2str(0));
- set(handles.slider7,'min',-25);
- set(handles.slider7,'max',25);
- set(handles.slider7,'value',0);
- set(handles.slider7,'SliderStep',[0.025,0.05]);
- set(handles.slider7,'string',num2str(0));
- set(handles.slider8,'min',-25);
- set(handles.slider8,'max',25);
- set(handles.slider8,'value',0);
- set(handles.slider8,'SliderStep',[0.025,0.05]);
- set(handles.slider8,'string',num2str(0));
- set(handles.slider9,'min',-25);
- set(handles.slider9,'max',25);
- set(handles.slider9,'value',0);
- set(handles.slider9,'SliderStep',[0.025,0.05]);
- set(handles.slider9,'string',num2str(0));
- set(handles.gain1,'enable','off')
- set(handles.gain2,'enable','off')
- set(handles.gain3,'enable','off')
- set(handles.gain4,'enable','off')
- set(handles.gain5,'enable','off')
- set(handles.gain6,'enable','off')
- set(handles.gain7,'enable','off')
- set(handles.gain8,'enable','off')
- set(handles.gain9,'enable','off')
- set(handles.gain1,'string','1')
- set(handles.gain2,'string','1')
- set(handles.gain3,'string','1')
- set(handles.gain4,'string','1')
- set(handles.gain5,'string','1')
- set(handles.gain6,'string','1')
- set(handles.gain7,'string','1')
- set(handles.gain8,'string','1')
- set(handles.gain9,'string','1')
- set(handles.pop1,'enable','off')
- set(handles.playinputbutton,'enable','off')
- set(handles.playoutputbutton,'enable','off')
- set(handles.savebutton,'enable','off')
- set(handles.inputplotbutton,'enable','off')
- set(handles.outputplotbutton,'enable','off')
- set(handles.analyzebutton,'enable','off')
- set(handles.samplefreq,'enable','off')
- axes(handles.inputplot_time);
- title('Input: Time Domain');
- grid on;
- axes(handles.inputplot_freq);
- title('Input: Frequency Domain');
- grid on;
- axes(handles.outputplot_time);
- title('Output: Time Domain');
- grid on;
- axes(handles.outputplot_freq);
- title('Output: Frequency Domain');
- grid on;
- handles.output = hObject;
- % Update handles structure
- guidata(hObject, handles);
- % UIWAIT makes DSP_Equalizer wait for user response (see UIRESUME)
- % uiwait(handles.figure1);
- % --- Outputs from this function are returned to the command line.
- function varargout = DSP_Equalizer_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 slider movement.
- function slider1_Callback(hObject, eventdata, handles)
- % hObject handle to slider1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'Value') returns position of slider
- % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
- global C;
- C(1)=get(hObject,'value');
- set(handles.gain1,'string',num2str(C(1)));
- % --- Executes during object creation, after setting all properties.
- function slider1_CreateFcn(hObject, eventdata, handles)
- % hObject handle to slider1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: slider controls usually have a light gray background.
- if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor',[.9 .9 .9]);
- end
- % --- Executes on slider movement.
- function slider2_Callback(hObject, eventdata, handles)
- % hObject handle to slider2 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'Value') returns position of slider
- % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
- global C;
- C(2)=get(hObject,'value');
- set(handles.gain2,'string',num2str(C(2)));
- % --- Executes during object creation, after setting all properties.
- function slider2_CreateFcn(hObject, eventdata, handles)
- % hObject handle to slider2 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: slider controls usually have a light gray background.
- if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor',[.9 .9 .9]);
- end
- % --- Executes on slider movement.
- function slider3_Callback(hObject, eventdata, handles)
- % hObject handle to slider3 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'Value') returns position of slider
- % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
- global C;
- C(3)=get(hObject,'value');
- set(handles.gain3,'string',num2str(C(3)));
- % --- Executes during object creation, after setting all properties.
- function slider3_CreateFcn(hObject, eventdata, handles)
- % hObject handle to slider3 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: slider controls usually have a light gray background.
- if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor',[.9 .9 .9]);
- end
- % --- Executes on slider movement.
- function slider4_Callback(hObject, eventdata, handles)
- % hObject handle to slider4 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'Value') returns position of slider
- % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
- global C;
- C(4)=get(hObject,'value');
- set(handles.gain4,'string',num2str(C(4)));
- % --- Executes during object creation, after setting all properties.
- function slider4_CreateFcn(hObject, eventdata, handles)
- % hObject handle to slider4 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: slider controls usually have a light gray background.
- if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor',[.9 .9 .9]);
- end
- % --- Executes on slider movement.
- function slider5_Callback(hObject, eventdata, handles)
- % hObject handle to slider5 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'Value') returns position of slider
- % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
- global C;
- C(5)=get(hObject,'value');
- set(handles.gain5,'string',num2str(C(5)));
- % --- Executes during object creation, after setting all properties.
- function slider5_CreateFcn(hObject, eventdata, handles)
- % hObject handle to slider5 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: slider controls usually have a light gray background.
- if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor',[.9 .9 .9]);
- end
- % --- Executes on slider movement.
- function slider6_Callback(hObject, eventdata, handles)
- % hObject handle to slider6 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'Value') returns position of slider
- % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
- global C;
- C(6)=get(hObject,'value');
- set(handles.gain6,'string',num2str(C(6)));
- % --- Executes during object creation, after setting all properties.
- function slider6_CreateFcn(hObject, eventdata, handles)
- % hObject handle to slider6 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: slider controls usually have a light gray background.
- if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor',[.9 .9 .9]);
- end
- % --- Executes on slider movement.
- function slider7_Callback(hObject, eventdata, handles)
- % hObject handle to slider7 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'Value') returns position of slider
- % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
- global C;
- C(7)=get(hObject,'value');
- set(handles.gain7,'string',num2str(C(7)));
- % --- Executes during object creation, after setting all properties.
- function slider7_CreateFcn(hObject, eventdata, handles)
- % hObject handle to slider7 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: slider controls usually have a light gray background.
- if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor',[.9 .9 .9]);
- end
- % --- Executes on slider movement.
- function slider8_Callback(hObject, eventdata, handles)
- % hObject handle to slider8 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'Value') returns position of slider
- % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
- global C;
- C(8)=get(hObject,'value');
- set(handles.gain8,'string',num2str(C(8)));
- % --- Executes during object creation, after setting all properties.
- function slider8_CreateFcn(hObject, eventdata, handles)
- % hObject handle to slider8 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: slider controls usually have a light gray background.
- if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor',[.9 .9 .9]);
- end
- % --- Executes on slider movement.
- function slider9_Callback(hObject, eventdata, handles)
- % hObject handle to slider9 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'Value') returns position of slider
- % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
- global C;
- C(9)=get(hObject,'value');
- set(handles.gain9,'string',num2str(C(9)));
- % --- Executes during object creation, after setting all properties.
- function slider9_CreateFcn(hObject, eventdata, handles)
- % hObject handle to slider9 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: slider controls usually have a light gray background.
- if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor',[.9 .9 .9]);
- end
- % --- Executes on selection change in pop1.
- function pop1_Callback(hObject, eventdata, handles)
- % hObject handle to pop1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: contents = cellstr(get(hObject,'String')) returns pop1 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from pop1
- % --- Executes during object creation, after setting all properties.
- function pop1_CreateFcn(hObject, eventdata, handles)
- % hObject handle to pop1 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes on selection change in pop2.
- function pop2_Callback(hObject, eventdata, handles)
- % hObject handle to pop2 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: contents = cellstr(get(hObject,'String')) returns pop2 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from pop2
- % --- Executes during object creation, after setting all properties.
- function pop2_CreateFcn(hObject, eventdata, handles)
- % hObject handle to pop2 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes on selection change in pop3.
- function pop3_Callback(hObject, eventdata, handles)
- % hObject handle to pop3 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: contents = cellstr(get(hObject,'String')) returns pop3 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from pop3
- % --- Executes during object creation, after setting all properties.
- function pop3_CreateFcn(hObject, eventdata, handles)
- % hObject handle to pop3 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes on selection change in pop4.
- function pop4_Callback(hObject, eventdata, handles)
- % hObject handle to pop4 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: contents = cellstr(get(hObject,'String')) returns pop4 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from pop4
- % --- Executes during object creation, after setting all properties.
- function pop4_CreateFcn(hObject, eventdata, handles)
- % hObject handle to pop4 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes on selection change in pop5.
- function pop5_Callback(hObject, eventdata, handles)
- % hObject handle to pop5 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: contents = cellstr(get(hObject,'String')) returns pop5 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from pop5
- % --- Executes during object creation, after setting all properties.
- function pop5_CreateFcn(hObject, eventdata, handles)
- % hObject handle to pop5 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes on selection change in pop6.
- function pop6_Callback(hObject, eventdata, handles)
- % hObject handle to pop6 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: contents = cellstr(get(hObject,'String')) returns pop6 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from pop6
- % --- Executes during object creation, after setting all properties.
- function pop6_CreateFcn(hObject, eventdata, handles)
- % hObject handle to pop6 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes on selection change in pop7.
- function pop7_Callback(hObject, eventdata, handles)
- % hObject handle to pop7 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: contents = cellstr(get(hObject,'String')) returns pop7 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from pop7
- % --- Executes during object creation, after setting all properties.
- function pop7_CreateFcn(hObject, eventdata, handles)
- % hObject handle to pop7 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes on selection change in pop8.
- function pop8_Callback(hObject, eventdata, handles)
- % hObject handle to pop8 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: contents = cellstr(get(hObject,'String')) returns pop8 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from pop8
- % --- Executes during object creation, after setting all properties.
- function pop8_CreateFcn(hObject, eventdata, handles)
- % hObject handle to pop8 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes on selection change in pop9.
- function pop9_Callback(hObject, eventdata, handles)
- % hObject handle to pop9 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: contents = cellstr(get(hObject,'String')) returns pop9 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from pop9
- % --- Executes during object creation, after setting all properties.
- function pop9_CreateFcn(hObject, eventdata, handles)
- % hObject handle to pop9 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes on button press in loadbutton.
- function loadbutton_Callback(hObject, eventdata, handles)
- % hObject handle to loadbutton (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global file_name;
- [filename, pathname] = uigetfile('*wav','Load a .wav file');
- file_name = strcat(pathname,filename)
- Nowplaying = strcat('Now Playing: ',filename)
- if ~isempty(file_name)
- set(handles.gain1,'enable','on')
- set(handles.gain2,'enable','on')
- set(handles.gain3,'enable','on')
- set(handles.gain4,'enable','on')
- set(handles.gain5,'enable','on')
- set(handles.gain6,'enable','on')
- set(handles.gain7,'enable','on')
- set(handles.gain8,'enable','on')
- set(handles.gain9,'enable','on')
- set(handles.pop1,'enable','on')
- set(handles.playinputbutton,'enable','on')
- set(handles.playoutputbutton,'enable','on')
- set(handles.savebutton,'enable','on')
- set(handles.inputplotbutton,'enable','on')
- set(handles.outputplotbutton,'enable','on')
- set(handles.analyzebutton,'enable','on')
- set(handles.samplefreq,'enable','on')
- set(handles.filename,'string',Nowplaying)
- end
- % --- Executes on button press in playinputbutton.
- function playinputbutton_Callback(hObject, eventdata, handles)
- % hObject handle to playinputbutton (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global file_name;
- [y,Fs]=audioread(file_name);
- sound(y,Fs);
- % --- Executes on button press in inputplotbutton.
- function inputplotbutton_Callback(hObject, eventdata, handles)
- % hObject handle to inputplotbutton (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global file_name;
- [y,Fs]=audioread(file_name);
- y = y(:,1);
- s_length = length(y);
- frameSize = fix(y*0.001*Fs);
- dt = 1/Fs;
- t = 0:dt:(length(y)*dt)-dt;
- axes(handles.inputplot_time);
- plot(t,y);
- grid on;
- xlabel('Seconds');
- ylabel('Amplitude');
- axes(handles.inputplot_freq);
- plot(psd(spectrum.periodogram,y,'Fs',Fs,'NFFT',length(y)));
- % --- Executes on button press in outputplotbutton.
- function outputplotbutton_Callback(hObject, eventdata, handles)
- % hObject handle to outputplotbutton (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global file_name C;
- [x,Fs]=audioread(file_name);
- dt = 1/Fs;
- allItems = handles.pop1.String; % A cell array of all strings in the popup.
- selectedIndex = handles.pop1.Value; % An integer saying which item has been selected.
- selectedfilter = allItems{selectedIndex};
- if strcmp(selectedfilter, 'IIR') == 1
- [a,b]=coef();
- foo=2*Fs;
- Nb=round(length(x)/foo);
- y=0;
- for i=1:floor(Nb)
- part=x((i-1)*foo+1:i*foo);
- for k=1:9
- y=[y filter(C(k)*b{k},a{k},part)];
- end
- t = 0:dt:(length(y)*dt)-dt;
- axes(handles.outputplot_time);
- plot(t,y);
- grid on;
- xlabel('Seconds');
- ylabel('Amplitude');
- axes(handles.outputplot_freq);
- plot(psd(spectrum.periodogram,y,'Fs',Fs,'NFFT',length(y)));
- y=0;
- grid on;
- end
- end
- function [a,b]=coef()
- global Fs;
- %Filter 1
- Rp1 = 0.5;
- Rs1 = 30;
- Fp1 = 170/(Fs/2)
- Fs1 = 200/(Fs/2)
- n1 = cheb1ord(Fp1,Fs1,Rp1,Rs1);
- [b1,a1] = cheby1(n1,Rp1,Fp1,'low');
- %Filter 2
- Rp2=0.5;
- Rs2=30;
- Fp2=[170,310]/(Fs/2);
- Fs2=[100,390]/(Fs/2);
- n2=cheb1ord(Fp2,Fs2,Rp2,Rs2);
- [b2,a2]=cheby1(n2,Rp2,Fp2);
- %Filter 3
- Rp3=0.5;
- Rs3=30;
- Fp3=[310,600]/(Fs/2);
- Fs3=[250,640]/(Fs/2);
- n3=cheb2ord(Fp3,Fs3,Rp3,Rs3);
- [b3,a3]=cheby2(n3,Rp3,Fp3);
- %Filter 4
- Rp4=0.5;
- Rs4=30;
- Fp4=[600,1000]/(Fs/2);
- Fs4=[400,1100]/(Fs/2);
- n4=cheb2ord(Fp4,Fs4,Rp4,Rs4);
- [b4,a4]=cheby2(n4,Rp4,Fp4);
- %Filter 5
- Rp5=0.5;
- Rs5=30;
- Fp5=[1000,3000]/(Fs/2);
- Fs5=[800,3200]/(Fs/2);
- n5=cheb2ord(Fp5,Fs5,Rp5,Rs5);
- [b5,a5]=cheby2(n5,Rp5,Fp5);
- %Filter 6
- Rp6=0.5;
- Rs6=30;
- Fp6=[3000,6000]/(Fs/2);
- Fs6=[2960,6040]/(Fs/2);
- n6=cheb2ord(Fp6,Fs6,Rp6,Rs6);
- [b6,a6]=cheby2(n6,Rp6,Fp6);
- %Filter 7
- Rp7=0.5;
- Rs7=30;
- Fp7=[6000,12000]/(Fs/2);
- Fs7=[5500,12500]/(Fs/2);
- n7=cheb2ord(Fp7,Fs7,Rp7,Rs7);
- [b7,a7]=cheby2(n7,Rp7,Fp7);
- %Filter 8
- Rp8=0.5;
- Rs8=30;
- Fp8=[12000,14000]/(Fs/2);
- Fs8=[10000,17000]/(Fs/2);
- n8=cheb2ord(Fp8,Fs8,Rp8,Rs8);
- [b8,a8]=cheby2(n8,Rp8,Fp8);
- %Filter 9
- Rp9=0.5;
- Rs9=30;
- Fp9=16000/(Fs/2);
- Fs9=16500/(Fs/2);
- n9=cheb2ord(Fp9,Fs9,Rp9,Rs9);
- [b9,a9]=cheby2(n9,Rp9,Fp9,'high');
- a = {a1,a2,a3,a4,a5,a6,a7,a8,a9};
- b = {b1,b2,b3,b4,b5,b6,b7,b8,b9};
- % --- Executes on button press in savebutton.
- function savebutton_Callback(hObject, eventdata, handles)
- % hObject handle to savebutton (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 analyzebutton.
- function analyzebutton_Callback(hObject, eventdata, handles)
- % hObject handle to analyzebutton (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 playoutputbutton.
- function playoutputbutton_Callback(hObject, eventdata, handles)
- % hObject handle to playoutputbutton (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global file_name C;
- [x,Fs]=audioread(file_name);
- allItems = handles.pop1.String; % A cell array of all strings in the popup.
- selectedIndex = handles.pop1.Value; % An integer saying which item has been selected.
- selectedfilter = allItems{selectedIndex};
- if strcmp(selectedfilter, 'IIR') == 1
- [a,b]=coef();
- foo=2*Fs;
- Nb=round(length(x)/foo);
- y=0;
- for i=1:floor(Nb)
- part=x((i-1)*foo+1:i*foo);
- for k=1:9
- y=y+filter(C(k)*b{k},a{k},part);
- end
- sound(y,Fs);
- y=0;
- end
- end
- function samplefreq_Callback(hObject, eventdata, handles)
- % hObject handle to samplefreq (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'String') returns contents of samplefreq as text
- % str2double(get(hObject,'String')) returns contents of samplefreq as a double
- % --- Executes during object creation, after setting all properties.
- function samplefreq_CreateFcn(hObject, eventdata, handles)
- % hObject handle to samplefreq (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: edit controls usually have a white background on Windows.
- % See ISPC and COMPUTER.
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- function gain1_Callback(hObject, eventdata, handles)
- % hObject handle to gain1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'String') returns contents of gain1 as text
- % str2double(get(hObject,'String')) returns contents of gain1 as a double
- % --- Executes during object creation, after setting all properties.
- function gain1_CreateFcn(hObject, eventdata, handles)
- % hObject handle to gain1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: edit controls usually have a white background on Windows.
- % See ISPC and COMPUTER.
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- function gain2_Callback(hObject, eventdata, handles)
- % hObject handle to gain2 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'String') returns contents of gain2 as text
- % str2double(get(hObject,'String')) returns contents of gain2 as a double
- % --- Executes during object creation, after setting all properties.
- function gain2_CreateFcn(hObject, eventdata, handles)
- % hObject handle to gain2 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: edit controls usually have a white background on Windows.
- % See ISPC and COMPUTER.
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- function gain3_Callback(hObject, eventdata, handles)
- % hObject handle to gain3 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'String') returns contents of gain3 as text
- % str2double(get(hObject,'String')) returns contents of gain3 as a double
- % --- Executes during object creation, after setting all properties.
- function gain3_CreateFcn(hObject, eventdata, handles)
- % hObject handle to gain3 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: edit controls usually have a white background on Windows.
- % See ISPC and COMPUTER.
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- function gain4_Callback(hObject, eventdata, handles)
- % hObject handle to gain4 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'String') returns contents of gain4 as text
- % str2double(get(hObject,'String')) returns contents of gain4 as a double
- % --- Executes during object creation, after setting all properties.
- function gain4_CreateFcn(hObject, eventdata, handles)
- % hObject handle to gain4 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: edit controls usually have a white background on Windows.
- % See ISPC and COMPUTER.
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- function gain5_Callback(hObject, eventdata, handles)
- % hObject handle to gain5 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'String') returns contents of gain5 as text
- % str2double(get(hObject,'String')) returns contents of gain5 as a double
- % --- Executes during object creation, after setting all properties.
- function gain5_CreateFcn(hObject, eventdata, handles)
- % hObject handle to gain5 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: edit controls usually have a white background on Windows.
- % See ISPC and COMPUTER.
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- function gain6_Callback(hObject, eventdata, handles)
- % hObject handle to gain6 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'String') returns contents of gain6 as text
- % str2double(get(hObject,'String')) returns contents of gain6 as a double
- % --- Executes during object creation, after setting all properties.
- function gain6_CreateFcn(hObject, eventdata, handles)
- % hObject handle to gain6 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: edit controls usually have a white background on Windows.
- % See ISPC and COMPUTER.
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- function gain7_Callback(hObject, eventdata, handles)
- % hObject handle to gain7 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'String') returns contents of gain7 as text
- % str2double(get(hObject,'String')) returns contents of gain7 as a double
- % --- Executes during object creation, after setting all properties.
- function gain7_CreateFcn(hObject, eventdata, handles)
- % hObject handle to gain7 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: edit controls usually have a white background on Windows.
- % See ISPC and COMPUTER.
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- function gain8_Callback(hObject, eventdata, handles)
- % hObject handle to gain8 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'String') returns contents of gain8 as text
- % str2double(get(hObject,'String')) returns contents of gain8 as a double
- % --- Executes during object creation, after setting all properties.
- function gain8_CreateFcn(hObject, eventdata, handles)
- % hObject handle to gain8 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: edit controls usually have a white background on Windows.
- % See ISPC and COMPUTER.
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- function gain9_Callback(hObject, eventdata, handles)
- % hObject handle to gain9 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: get(hObject,'String') returns contents of gain9 as text
- % str2double(get(hObject,'String')) returns contents of gain9 as a double
- % --- Executes during object creation, after setting all properties.
- function gain9_CreateFcn(hObject, eventdata, handles)
- % hObject handle to gain9 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles empty - handles not created until after all CreateFcns called
- % Hint: edit controls usually have a white background on Windows.
- % See ISPC and COMPUTER.
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement