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

% Last Modified by GUIDE v2.5 22-May-2014 13:56:10

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

% Choose default command line output for objectivegui
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes objectivegui wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = objectivegui_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)

% nacitanie suboru
clc

[filename pathname] = uigetfile({'*.wav'},'Select impulse response file')
fullpathname=strcat(pathname,filename);
[IR, Fvz]=wavread(fullpathname);

% prenos premennych medzi callbackmi
handles.IR=IR;
handles.Fvz=Fvz;

%vykresli impulznu odozvu
n=(1:length(IR))/Fvz;
plot(handles.impz,n,IR)
h=title(handles.impz,'\bfImpulzná odozva');
xlabel(handles.impz,'{{\itt}} (s) \rightarrow')
ylabel(handles.impz,'\ith(-) \rightarrow')

%vypis do labelu
set(handles.prikaz,'String','Impulzná odozva načítaná.')


guidata(hObject, handles);

% --- 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)

IR = handles.IR;
Fvz = handles.Fvz;

[RT,EDT,C7,C50,C80,D50,H,itdg,BR,HFR,Ts,IACCE,EKdelta,doz] = objective(IR,Fvz);

D50=D50*100;
EK=max(EKdelta);

% krivka doby dozvuku
E1=vektorplus(doz(4,:,1),doz(3,:,1));
E2=vektorplus(doz(2,:,1),doz(5,:,1));
E=vektorplus(E1,E2)/4;
n=(1:length(E))/Fvz;
plot(handles.dozvuk,n,E);
h=title(handles.dozvuk,'\bfKrivka doby dozvuku');
xlabel(handles.dozvuk,'{{\itt}} (s) \rightarrow')
ylabel(handles.dozvuk,'\its(dB) \rightarrow')
set(handles.dozvuk,'ylim',[-80 0]);


set(handles.RT,'String',num2str(RT,3));
set(handles.EDT,'String',num2str(EDT,3));
set(handles.BR,'String',num2str(BR,3));
set(handles.HFR,'String',num2str(HFR,3));
set(handles.C7,'String',num2str(C7,3));
set(handles.C50,'String',num2str(C50,3));
set(handles.C80,'String',num2str(C80,3));
set(handles.H,'String',num2str(H,3));
set(handles.ts,'String',num2str(Ts,3));
set(handles.D50,'String',num2str(D50,3));
set(handles.ITDG,'String',num2str(itdg,3));
set(handles.EK,'String',num2str(EK,3));
set(handles.IACCE,'String',num2str(IACCE,3));

function RT_Callback(hObject, eventdata, handles)
% hObject    handle to RT (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 RT as text
%        str2double(get(hObject,'String')) returns contents of RT as a double


% --- Executes during object creation, after setting all properties.
function RT_CreateFcn(hObject, eventdata, handles)
% hObject    handle to RT (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 EDT_Callback(hObject, eventdata, handles)
% hObject    handle to EDT (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 EDT as text
%        str2double(get(hObject,'String')) returns contents of EDT as a double


% --- Executes during object creation, after setting all properties.
function EDT_CreateFcn(hObject, eventdata, handles)
% hObject    handle to EDT (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 BR_Callback(hObject, eventdata, handles)
% hObject    handle to BR (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 BR as text
%        str2double(get(hObject,'String')) returns contents of BR as a double


% --- Executes during object creation, after setting all properties.
function BR_CreateFcn(hObject, eventdata, handles)
% hObject    handle to BR (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 HFR_Callback(hObject, eventdata, handles)
% hObject    handle to HFR (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 HFR as text
%        str2double(get(hObject,'String')) returns contents of HFR as a double


% --- Executes during object creation, after setting all properties.
function HFR_CreateFcn(hObject, eventdata, handles)
% hObject    handle to HFR (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 C7_Callback(hObject, eventdata, handles)
% hObject    handle to C7 (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 C7 as text
%        str2double(get(hObject,'String')) returns contents of C7 as a double


% --- Executes during object creation, after setting all properties.
function C7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to C7 (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 C50_Callback(hObject, eventdata, handles)
% hObject    handle to C50 (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 C50 as text
%        str2double(get(hObject,'String')) returns contents of C50 as a double


% --- Executes during object creation, after setting all properties.
function C50_CreateFcn(hObject, eventdata, handles)
% hObject    handle to C50 (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 C80_Callback(hObject, eventdata, handles)
% hObject    handle to C80 (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 C80 as text
%        str2double(get(hObject,'String')) returns contents of C80 as a double


% --- Executes during object creation, after setting all properties.
function C80_CreateFcn(hObject, eventdata, handles)
% hObject    handle to C80 (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 D50_Callback(hObject, eventdata, handles)
% hObject    handle to D50 (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 D50 as text
%        str2double(get(hObject,'String')) returns contents of D50 as a double


% --- Executes during object creation, after setting all properties.
function D50_CreateFcn(hObject, eventdata, handles)
% hObject    handle to D50 (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 H_Callback(hObject, eventdata, handles)
% hObject    handle to H (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 H as text
%        str2double(get(hObject,'String')) returns contents of H as a double


% --- Executes during object creation, after setting all properties.
function H_CreateFcn(hObject, eventdata, handles)
% hObject    handle to H (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 ts_Callback(hObject, eventdata, handles)
% hObject    handle to ts (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 ts as text
%        str2double(get(hObject,'String')) returns contents of ts as a double


% --- Executes during object creation, after setting all properties.
function ts_CreateFcn(hObject, eventdata, handles)
% hObject    handle to ts (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 ITDG_Callback(hObject, eventdata, handles)
% hObject    handle to ITDG (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 ITDG as text
%        str2double(get(hObject,'String')) returns contents of ITDG as a double


% --- Executes during object creation, after setting all properties.
function ITDG_CreateFcn(hObject, eventdata, handles)
% hObject    handle to ITDG (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 IACCE_Callback(hObject, eventdata, handles)
% hObject    handle to IACCE (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 IACCE as text
%        str2double(get(hObject,'String')) returns contents of IACCE as a double


% --- Executes during object creation, after setting all properties.
function IACCE_CreateFcn(hObject, eventdata, handles)
% hObject    handle to IACCE (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 EK_Callback(hObject, eventdata, handles)
% hObject    handle to EK (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 EK as text
%        str2double(get(hObject,'String')) returns contents of EK as a double


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





