function varargout = Maskingsounds(varargin)

%%%Dr. Ignacio Serrano-Pedraza 2018
%%%iserrano@ucm.es


% MASKINGSOUNDS MATLAB code for Maskingsounds.fig
%      MASKINGSOUNDS, by itself, creates a new MASKINGSOUNDS or raises the existing
%      singleton*.
%
%      H = MASKINGSOUNDS returns the handle to a new MASKINGSOUNDS or the handle to
%      the existing singleton*.
%
%      MASKINGSOUNDS('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MASKINGSOUNDS.M with the given input arguments.
%
%      MASKINGSOUNDS('Property','Value',...) creates a new MASKINGSOUNDS or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Maskingsounds_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Maskingsounds_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 Maskingsounds

% Last Modified by GUIDE v2.5 05-Dec-2017 15:19:36

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @Maskingsounds_OpeningFcn, ...
    'gui_OutputFcn',  @Maskingsounds_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 Maskingsounds is made visible.
function Maskingsounds_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 Maskingsounds (see VARARGIN)

% Choose default command line output for Maskingsounds
handles.output = hObject;
% Play_sound handles structure
guidata(hObject, handles);
playsound=0;
set(handles.radiobutton1,'Value',1);
Plot_figure(hObject, eventdata, handles,playsound)


function Plot_figure(hObject, eventdata, handles,playsound)
expt = getexpt(handles);
if isnan(expt.amplitude1)==1;expt.amplitude1=0;set(handles.Amplitude1,'string',0);end
if isnan(expt.amplitude2)==1;expt.amplitude2=0;set(handles.Amplitude2,'string',0);end

samplingfrequency=expt.Framerate;
if expt.Duration<=0;expt.Duration=0.001;set(handles.Duration,'string',0.001);end
duracion=expt.Duration; %seconds

t=[0:1/samplingfrequency:duracion-(1/samplingfrequency)]';
n=round(samplingfrequency*duracion);
if mod(n,2)>=1
n=n-1;
if length(t)>n
t(end)=[];
end
end

if length(t)<n
t=[0:1/samplingfrequency:duracion]';
end

freq=(-fix(n/2):fix((n-1)/2))/duracion;


if expt.radiobutton1==1
    y1=expt.amplitude1*cos(2*pi*expt.Temporal_frequency1*t+expt.PHASE1);
else
    y1=0*ones(n,1);
end
if expt.radiobutton2==1
    if expt.radiobuttongaussian==1
        y2= 0 + sqrt(expt.amplitude2)/2 * randn(n,1);
        
    else
        y2= 0 + sqrt(expt.amplitude2) * ((rand(n,1))-0.5)*2;
    end
    %%%%%%%%%%%%IDEAL FILTERS%%%%%%%%%%%%%%%%%%
   
    ucsup=expt.lowSF;
    ucinf=-expt.lowSF;
    
    I=find(freq>ucinf&freq<ucsup);
    filtroLP=0*ones(1,length(freq));
    filtroLP(I)=1;%%LOW-PASS filter
    
    ucsup=expt.highSF;
    ucinf=-expt.highSF;
    I=find(freq>ucinf&freq<ucsup);
    filtroHP=1*ones(1,length(freq));
    filtroHP(I)=0;%%High-PASS filter
    
    
    central=expt.centerBP;
    ucsupA=central-expt.bandwidth/2;
    ucsupB=central+expt.bandwidth/2;
    ucinfA=-ucsupB;
    ucinfB=-ucsupA;
    
    J=find(freq>ucinfA&freq<ucinfB|freq>ucsupA&freq<ucsupB);
    filtroBP=0*ones(1,length(freq));
    filtroBP(J)=1;%BAND-PASS filter
    
    central=expt.centerNN;
    ucsupA=central-expt.bandwidthNN/2;
    ucsupB=central+expt.bandwidthNN/2;
    ucinfA=-ucsupB;
    ucinfB=-ucsupA;
    
    J=find(freq>ucinfA&freq<ucinfB|freq>ucsupA&freq<ucsupB);
    filtroNN=1*ones(1,length(freq));
    filtroNN(J)=0;%%NOTCH filter
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if expt.radiobuttonLP==1
        filtro=filtroLP;
    end
    if expt.radiobuttonHP==1
        filtro=filtroHP;
    end
    if expt.radiobuttonBP==1
        filtro=filtroBP;
    end
    if expt.radiobuttonNN==1
        filtro=filtroNN;
    end
    
    Y=fftshift(fft(y2));
    modulo=abs(Y)';
    fase=angle(Y)';
    REALPROD=fftshift(modulo.*filtro.*cos(fase));
    IMAGPROD=fftshift(modulo.*filtro.*sin(fase));
    
    RESULTADO=(REALPROD+IMAGPROD*sqrt(-1));
    FINAL=(ifft(RESULTADO));
    y2=real(FINAL);
    
else
    y2=0*ones(1,n);
end


y=y1+y2';



axes(handles.Plot1);
cla;
plot(t,y1,'b-');
title('Signal')
xlabel('Time (msec)')
ylabel('Amplitude')
if sum(y1)==0
axis([0 expt.ejeX -0.1 0.1])
else
axis([0 expt.ejeX -(max(abs(y1))+0.5*max(abs(y1))) (max(abs(y1))+0.5*max(abs(y1)))])
end
if playsound==1
    sound(y,samplingfrequency)
end


axes(handles.Plot2);
cla;
plot(t,y2,'b-');
title('Noise')
xlabel('Time (msec)')
ylabel('Amplitude')
if sum(y2)==0
axis([0 expt.ejeX -0.1 0.1])
else
axis([0 expt.ejeX -(max(abs(y2))+0.3*max(abs(y2))) (max(abs(y2))+0.3*max(abs(y2)))])
end
axes(handles.Plot3);
cla;
plot(t,y,'b-');
title('Signal+Noise')
xlabel('Time (msec)')
ylabel('Amplitude')
if sum(y)==0
axis([0 expt.ejeX -0.1 0.1])
else
axis([0 expt.ejeX -(max(abs(y))+0.3*max(abs(y))) max(abs(y))+0.3*max(abs(y))])
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Y=fftshift(fft(y1));
modulo1=abs(Y)'*2*(1/length(y1));
fase=angle(Y)';



Y=fftshift(fft(y2));
modulo2=abs(Y)'*2*(1/length(y2));
fase=angle(Y)';
%freq=(-fix(n/2):fix((n-1)/2))/duracion;

Y=fftshift(fft(y));
modulo3=abs(Y)'*2*(1/length(y));
fase=angle(Y)';
%freq=(-fix(n/2):fix((n-1)/2))/duracion;

axes(handles.Plot4);
cla;

semilogx(freq([round(length(freq)/2+1):end]),modulo1([round(length(freq)/2+1):end]),'b-');
title('Amplitude spectrum')
xlabel('Temporal frequency (Hz)')
ylabel('Amplitude')
if sum(y1)==0
axis([20 15000 0 1])
else
axis([20 15000 0 max(modulo3([round(length(freq)/2+1):end]))+0.2*max(modulo3([round(length(freq)/2+1):end]))])
end

axes(handles.Plot5);
cla;
semilogx(freq([round(length(freq)/2+1):end]),modulo2([round(length(freq)/2+1):end]),'b-');
title('Amplitude spectrum')
xlabel('Temporal frequency (Hz)')
ylabel('Amplitude')
if sum(y2)==0
axis([20 15000 0 1])
else
axis([20 15000 0 max(modulo3([round(length(freq)/2+1):end]))+0.2*max(modulo3([round(length(freq)/2+1):end]))])
end


axes(handles.Plot6);
cla;

semilogx(freq([round(length(freq)/2+1):end]),modulo3([round(length(freq)/2+1):end]),'b-');
title('Amplitude spectrum')
xlabel('Temporal frequency (Hz)')
ylabel('Amplitude')
if sum(y)==0
axis([20 15000 0 1])
else
axis([20 15000 0 max(modulo3([round(length(freq)/2+1):end]))+0.2*max(modulo3([round(length(freq)/2+1):end]))])
end




% --- Outputs from this function are returned to the command line.
function varargout = Maskingsounds_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 Play_sound.
function Play_sound_Callback(hObject, eventdata, handles)
% hObject    handle to Play_sound (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
playsound=1;
Plot_figure(hObject, eventdata, handles,playsound)



% --------------------------------------------------------------------
function OpenMenuItem_Callback(hObject, eventdata, handles)
% hObject    handle to OpenMenuItem (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
file = uigetfile('*.fig');
if ~isequal(file, 0)
    open(file);
end


% --- Executes during object creation, after setting all properties.
function Amplitude1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Amplitude1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
function Amplitude1_Callback(hObject, eventdata, handles)
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

function expt = getexpt(handles)
% Reads off key data from GUI
%expt = handles.expt;
A = get(handles.Amplitude1,'string');
expt.amplitude1 = str2double(A);
A = get(handles.Amplitude2,'string');
expt.amplitude2 = str2double(A);
A = get(handles.lowSF,'string');
expt.lowSF = str2double(A);
A = get(handles.highSF,'string');
expt.highSF = str2double(A);
A = get(handles.centerBP,'string');
expt.centerBP = str2double(A);
A = get(handles.bandwidth,'string');
expt.bandwidth = str2double(A);
A = get(handles.centerNN,'string');
expt.centerNN = str2double(A);
A = get(handles.bandwidthNN,'string');
expt.bandwidthNN = str2double(A);

TF = get(handles.Temporal_frequency1,'string');
expt.Temporal_frequency1 = str2double(TF);

PHASE = get(handles.Phase1,'string');
expt.PHASE1 = str2double(PHASE);


Duration = get(handles.Duration,'string');
expt.Duration = str2double(Duration);
Framerate = get(handles.Framerate,'string');
expt.Framerate = str2double(Framerate);
expt.ejeX = get(handles.axisX,'value');

expt.radiobutton1= get(handles.radiobutton1,'value');
expt.radiobutton2= get(handles.radiobutton2,'value');
expt.radiobuttongaussian= get(handles.radiobuttongaussian,'value');
expt.radiobuttonuniform= get(handles.radiobuttonuniform,'value');
expt.radiobuttonLP= get(handles.radiobuttonLP,'value');
expt.radiobuttonHP= get(handles.radiobuttonHP,'value');
expt.radiobuttonBP= get(handles.radiobuttonBP,'value');
expt.radiobuttonNN= get(handles.radiobuttonNN,'value');



function Temporal_frequency1_Callback(hObject, eventdata, handles)
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function Temporal_frequency1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Temporal_frequency1 (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 Phase1_Callback(hObject, eventdata, handles)
% hObject    handle to Phase1 (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 Phase1 as text
%        str2double(get(hObject,'String')) returns contents of Phase1 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function Phase1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Phase1 (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


% --- Executes on button press in Plot_figure.
function Plot_figure_Callback(hObject, eventdata, handles)
% hObject    handle to Plot_figure (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)



function Duration_Callback(hObject, eventdata, handles)
% hObject    handle to Duration (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 Duration as text
%        str2double(get(hObject,'String')) returns contents of Duration as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function Duration_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Duration (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 Framerate_Callback(hObject, eventdata, handles)
% hObject    handle to Framerate (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 Framerate as text
%        str2double(get(hObject,'String')) returns contents of Framerate as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function Framerate_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Framerate (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 CloseMenuItem_Callback(hObject, eventdata, handles)
% hObject    handle to CloseMenuItem (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
selection = questdlg(['Close ' get(handles.axixX,'Name') '?'],...
    ['Close ' get(handles.axixX,'Name') '...'],...
    'Yes','No','Yes');
if strcmp(selection,'No')
    return;
end

delete(handles.axixX)
% --------------------------------------------------------------------
function PrintMenuItem_Callback(hObject, eventdata, handles)
% hObject    handle to PrintMenuItem (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
printdlg(handles.axixX)

% --------------------------------------------------------------------
function FileMenu_Callback(hObject, eventdata, handles)
% hObject    handle to FileMenu (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 Reset.
function Reset_Callback(hObject, eventdata, handles)
% hObject    handle to Reset (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


set(handles.Amplitude1, 'String', 0.3);
set(handles.Temporal_frequency1,  'String', 3000);
set(handles.Phase1, 'String', 0);

set(handles.Amplitude2, 'String', 15);

set(handles.Duration, 'String', 1);
set(handles.Framerate, 'String', 44100);
set(handles.axisX,'Value',0.005);

set(handles.radiobutton1,'Value',1);
set(handles.radiobutton2,'Value',0);
set(handles.radiobuttongaussian,'Value',1);
set(handles.radiobuttonuniform,'Value',0);
set(handles.radiobuttonLP,'Value',1);
set(handles.radiobuttonHP,'Value',0);
set(handles.radiobuttonBP,'Value',0);
set(handles.radiobuttonNN,'Value',0);

set(handles.lowSF, 'String', 500);
set(handles.highSF, 'String', 5000);
set(handles.centerBP, 'String', 3000);
set(handles.bandwidth, 'String', 500);
set(handles.centerNN, 'String', 3000);
set(handles.bandwidthNN, 'String', 2500);

playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

%set(handles.unitgroup, 'SelectedObject', handles.english);

%set(handles.text4, 'String', 'lb/cu.in');
%set(handles.text5, 'String', 'cu.in');
%set(handles.text6, 'String', 'lb');

% Update handles structure
%guidata(handles.axixX, handles);





% --- Executes on slider movement.
function axisX_Callback(hObject, eventdata, handles)
% hObject    handle to axisX (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%get(hObject,'Value')
% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function axisX_CreateFcn(hObject, eventdata, handles)
% hObject    handle to axisX (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 button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton1
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)




function Amplitude2_Callback(hObject, eventdata, handles)
% hObject    handle to Amplitude2 (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 Amplitude2 as text
%        str2double(get(hObject,'String')) returns contents of Amplitude2 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function Amplitude2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Amplitude2 (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



% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton2
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes on button press in radiobuttongaussian.
function radiobuttongaussian_Callback(hObject, eventdata, handles)
% hObject    handle to radiobuttongaussian (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobuttongaussian
set(handles.radiobuttonuniform,'Value',0);
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)



% --- Executes on button press in radiobuttonuniform.
function radiobuttonuniform_Callback(hObject, eventdata, handles)
% hObject    handle to radiobuttonuniform (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobuttonuniform
set(handles.radiobuttongaussian,'Value',0);
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes on button press in radiobuttonLP.
function radiobuttonLP_Callback(hObject, eventdata, handles)
% hObject    handle to radiobuttonLP (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobuttonLP
set(handles.radiobuttonHP,'Value',0);
set(handles.radiobuttonBP,'Value',0);
set(handles.radiobuttonNN,'Value',0);
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes on button press in radiobuttonHP.
function radiobuttonHP_Callback(hObject, eventdata, handles)
% hObject    handle to radiobuttonHP (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobuttonHP
set(handles.radiobuttonLP,'Value',0);
set(handles.radiobuttonBP,'Value',0);
set(handles.radiobuttonNN,'Value',0);
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes on button press in radiobuttonBP.
function radiobuttonBP_Callback(hObject, eventdata, handles)
% hObject    handle to radiobuttonBP (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobuttonBP
set(handles.radiobuttonLP,'Value',0);
set(handles.radiobuttonHP,'Value',0);
set(handles.radiobuttonNN,'Value',0);
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


function lowSF_Callback(hObject, eventdata, handles)
% hObject    handle to lowSF (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 lowSF as text
%        str2double(get(hObject,'String')) returns contents of lowSF as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function lowSF_CreateFcn(hObject, eventdata, handles)
% hObject    handle to lowSF (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 highSF_Callback(hObject, eventdata, handles)
% hObject    handle to highSF (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 highSF as text
%        str2double(get(hObject,'String')) returns contents of highSF as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function highSF_CreateFcn(hObject, eventdata, handles)
% hObject    handle to highSF (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 bandwidth_Callback(hObject, eventdata, handles)
% hObject    handle to bandwidth (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 bandwidth as text
%        str2double(get(hObject,'String')) returns contents of bandwidth as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function bandwidth_CreateFcn(hObject, eventdata, handles)
% hObject    handle to bandwidth (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 centerBP_Callback(hObject, eventdata, handles)
% hObject    handle to centerBP (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 centerBP as text
%        str2double(get(hObject,'String')) returns contents of centerBP as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function centerBP_CreateFcn(hObject, eventdata, handles)
% hObject    handle to centerBP (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


% --- Executes on button press in radiobuttonNN.
function radiobuttonNN_Callback(hObject, eventdata, handles)
% hObject    handle to radiobuttonNN (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobuttonNN
set(handles.radiobuttonLP,'Value',0);
set(handles.radiobuttonBP,'Value',0);
set(handles.radiobuttonHP,'Value',0);
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)



function centerNN_Callback(hObject, eventdata, handles)
% hObject    handle to centerNN (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 centerNN as text
%        str2double(get(hObject,'String')) returns contents of centerNN as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function centerNN_CreateFcn(hObject, eventdata, handles)
% hObject    handle to centerNN (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 bandwidthNN_Callback(hObject, eventdata, handles)
% hObject    handle to bandwidthNN (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 bandwidthNN as text
%        str2double(get(hObject,'String')) returns contents of bandwidthNN as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function bandwidthNN_CreateFcn(hObject, eventdata, handles)
% hObject    handle to bandwidthNN (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
