function varargout = guide_vad(varargin)

%2008   Michal Adamec VUT Brno (v ramci Diplomove prace - Moderni rozpoznavace reci)

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

% Last Modified by GUIDE v2.5 11-Apr-2008 18:36:00

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

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

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes guide_vad wait for user response (see UIRESUME)
% uiwait(handles.figure1);
delka_ramce = 128;

% --- Outputs from this function are returned to the command line.
function varargout = guide_vad_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 checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox1 (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 checkbox1
if (get(handles.checkbox1,'Value') == get(handles.checkbox1,'Max'))
    i = 1;
else
    i = 0;
end


% --- Executes on selection change in popupmenu1.
function [delka_ramce]=popupmenu1_Callback(hObject, eventdata, handles,varargin)

if (get(handles.checkbox1,'Value') == get(handles.checkbox1,'Max'))  % podminka pro zaskrtnuty chceckbox

    delka_ramce = str2double(get(handles.popupmenu1,'String'));
    indexd = get(handles.popupmenu1,'Value');            % prislusny index
    switch indexd
        case 1
            delka_ramce = delka_ramce(1);
        case 2
            delka_ramce = delka_ramce(2);
    end
    %vadenerg('franek',delka_ramce,20,0,0)
    guidata(gcbo,handles);
    %else
    %set(handles.popupmenu1,'Value',1)
    %guidata(gcbo,handles.popupmenu1);

end
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1


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


% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu2


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


% hObject    handle to popupmenu3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu3


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



% hObject    handle to popupmenu4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu4 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu4


% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu4 (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 popupmenu6.
function popupmenu6_Callback(hObject, eventdata, handles)
delka_ramce = str2double(get(handles.popupmenu6,'String'));
indexd = get(handles.popupmenu6,'Value');            % prislusny index
switch indexd
    case 1
        delka_ramce = delka_ramce(1)
    case 2
        delka_ramce = delka_ramce(2)

end
% hObject    handle to popupmenu6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu6 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu6


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


% hObject    handle to popupmenu7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu7 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu7


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

% hObject    handle to popupmenu8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu8 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu8


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


% --- Executes on selection change in popupmenu9.
function popupmenu9_Callback(hObject, eventdata, handles)



% hObject    handle to popupmenu9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu9 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu9


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

% Hints: contents = get(hObject,'String') returns delkaramcekepstr contents as cell array
%        contents{get(hObject,'Value')} returns selected item from delkaramcekepstr


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

% Hints: contents = get(hObject,'String') returns pkepstr contents as cell array
%        contents{get(hObject,'Value')} returns selected item from pkepstr


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

% Hints: contents = get(hObject,'String') returns initkepstr contents as cell array
%        contents{get(hObject,'Value')} returns selected item from initkepstr


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


% --- Executes on selection change in alfakepstr.
function alfakepstr_Callback(hObject, eventdata, handles)
% hObject    handle to alfakepstr (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns alfakepstr contents as cell array
%        contents{get(hObject,'Value')} returns selected item from alfakepstr


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

% Hints: contents = get(hObject,'String') returns popupmenu14 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu14


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

% Hints: contents = get(hObject,'String') returns popupmenu15 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu15


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

% Hints: contents = get(hObject,'String') returns popupmenu16 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu16


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


% --- Executes on selection change in popupmenu17.
function popupmenu17_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu17 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu17 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu17


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


delka_ramce = 128;
init = 10;
p = 0;
alfa = 0;

%DELKA_RAMCE
delka_ramce = str2double(get(handles.popupmenu1,'String'));
indexd = get(handles.popupmenu1,'Value');            % prislusny index
switch indexd
    case 1
        delka_ramce = delka_ramce(1);
    case 2
        delka_ramce = delka_ramce(2);
end
%%%%%%%%%%%%%ENERGETICKY%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (get(handles.pushbutton1,'Value') == get(handles.pushbutton1,'Max'))
    %INIT
    init = str2double(get(handles.popupmenu2,'String'));  % hodnota prevedena na cislo
    indexi = get(handles.popupmenu2,'Value');            % prislusny index
    switch indexi
        case 1
            init = init(1);
        case 2
            init = init(2);
        case 3
            init = init(3);

    end
    %P
    p = str2double(get(handles.popupmenu3,'String'));
    indexp = get(handles.popupmenu3,'Value');            % prislusny index
    switch indexp
        case 1
            p = p(1);
        case 2
            p = p(2);
        case 3
            p = p(3);
        case 4
            p = p(4);
        case 5
            p = p(5);
        case 6
            p = p(6);
        case 7
            p = p(7);
        case 8
            p = p(8);
        case 9
            p = p(9);
        case 10
            p = p(10);
        case 11
            p = p(11);

    end
    %ALFA

    alfa = str2double(get(handles.popupmenu4,'String'));
    indexalfa = get(handles.popupmenu4,'Value');            % prislusny index
    switch indexalfa
        case 1
            alfa = alfa(1);
        case 2
            alfa = alfa(2);
        case 3
            alfa = alfa(3);
        case 4
            alfa = alfa(4);
        case 5
            alfa = alfa(5);
        case 6
            alfa = alfa(6);
        case 7
            alfa = alfa(7);
        case 8
            alfa = alfa(8);
        case 9
            alfa = alfa(9);
        case 10
            alfa = alfa(10);
        case 11
            alfa = alfa(11);

    end

    filename = get(handles.tlopen,'UserData');

    % VYKRESLENI
    if (get(handles.checkbox1,'Value') == get(handles.checkbox1,'Max'))

        if ((get(handles.checkbox6,'Value') == get(handles.checkbox6,'Max'))&& (get(handles.checkbox7,'Value') == get(handles.checkbox7,'Max')))
            vadenerg(filename,delka_ramce,init,p,alfa,1,1);

        elseif ((get(handles.checkbox6,'Value') == get(handles.checkbox6,'Min'))&& (get(handles.checkbox7,'Value') == get(handles.checkbox7,'Max')))
            vadenerg(filename,delka_ramce,init,p,alfa,0,1);

        elseif ((get(handles.checkbox6,'Value') == get(handles.checkbox6,'Max'))&& (get(handles.checkbox7,'Value') == get(handles.checkbox7,'Min')))
            vadenerg(filename,delka_ramce,init,p,alfa,1,0);
        elseif ((get(handles.checkbox6,'Value') == get(handles.checkbox6,'Min'))&& (get(handles.checkbox7,'Value') == get(handles.checkbox7,'Min')))
            vadenerg(filename,delka_ramce,init,p,alfa,0,0);

        end


    end
    delka_ramce = delka_ramce;
    init = init;
    p = p;
    alfa = alfa;

    %%%%%%%%%%%%%INTENZITY%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %INIT
    initi = str2double(get(handles.popupmenu7,'String'));  % hodnota prevedena na cislo
    indexi = get(handles.popupmenu7,'Value');            % prislusny index
    switch indexi
        case 1
            initi = initi(1);
        case 2
            initi = initi(2);
        case 3
            initi = initi(3);

    end

    %P
    pi = str2double(get(handles.popupmenu8,'String'));
    indexp = get(handles.popupmenu8,'Value');            % prislusny index
    switch indexp
        case 1
            pi = pi(1);
        case 2
            pi = pi(2);
        case 3
            pi = pi(3);
        case 4
            pi = pi(4);
        case 5
            pi = pi(5);
        case 6
            pi = pi(6);
        case 7
            pi = pi(7);
        case 8
            pi = pi(8);
        case 9
            pi = pi(9);
        case 10
            pi = pi(10);
        case 11
            pi = pi(11);

    end

    %ALFA
    alfai = str2double(get(handles.popupmenu9,'String'));
    indexalfai = get(handles.popupmenu9,'Value');            % prislusny index
    switch indexalfai
        case 1
            alfai = alfai(1);
        case 2
            alfai = alfai(2);
        case 3
            alfai = alfai(3);
        case 4
            alfai = alfai(4);
        case 5
            alfai = alfai(5);
        case 6
            alfai = alfai(6);
        case 7
            alfai = alfai(7);
        case 8
            alfai = alfai(8);
        case 9
            alfai = alfai(9);
        case 10
            alfai = alfai(10);
        case 11
            alfai = alfai(11);

    end


    % VYKRESLENI

    if (get(handles.checkbox2,'Value') == get(handles.checkbox2,'Max'))

        if ((get(handles.checkbox8,'Value') == get(handles.checkbox8,'Max'))&& (get(handles.checkbox9,'Value') == get(handles.checkbox9,'Max')))
            vadintenz(filename,delka_ramce,initi,pi,alfai,1,1);
        elseif ((get(handles.checkbox8,'Value') == get(handles.checkbox8,'Min'))&& (get(handles.checkbox9,'Value') == get(handles.checkbox9,'Max')))
            vadintenz(filename,delka_ramce,initi,pi,alfai,0,1);
        elseif ((get(handles.checkbox8,'Value') == get(handles.checkbox8,'Max'))&& (get(handles.checkbox9,'Value') == get(handles.checkbox9,'Min')))
            vadintenz(filename,delka_ramce,initi,pi,alfai,1,0);
        elseif ((get(handles.checkbox8,'Value') == get(handles.checkbox8,'Min'))&& (get(handles.checkbox9,'Value') == get(handles.checkbox9,'Min')))
            vadintenz(filename,delka_ramce,initi,pi,alfai,0,0);
        end

    end

    %%%%%%%%%%%%%KEPSTRALNI%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %INIT
    initc = str2double(get(handles.initkepstr,'String'));  % hodnota prevedena na cislo
    indexc = get(handles.initkepstr,'Value');            % prislusny index
    switch indexc
        case 1
            initc = initc(1);
        case 2
            initc = initc(2);
        case 3
            initc = initc(3);

    end

    %P
    pc = str2double(get(handles.pkepstr,'String'));
    indexc = get(handles.pkepstr,'Value');            % prislusny index
    switch indexc
        case 1
            pc = pc(1);
        case 2
            pc = pc(2);
        case 3
            pc = pc(3);
        case 4
            pc = pc(4);
        case 5
            pc = pc(5);
        case 6
            pc = pc(6);
        case 7
            pc = pc(7);
        case 8
            pc = pc(8);
        case 9
            pc = pc(9);
        case 10
            pc = pc(10);
        case 11
            pc = pc(11);

    end

    %ALFA
    alfac = str2double(get(handles.alfakepstr,'String'));
    indexalfac = get(handles.alfakepstr,'Value');            % prislusny index
    switch indexalfac
        case 1
            alfac = alfac(1);
        case 2
            alfac = alfac(2);
        case 3
            alfac = alfac(3);
        case 4
            alfac = alfac(4);
        case 5
            alfac = alfac(5);
        case 6
            alfac = alfac(6);
        case 7
            alfac = alfac(7);
        case 8
            alfac = alfac(8);
        case 9
            alfac = alfac(9);
        case 10
            alfac = alfac(10);
        case 11
            alfac = alfac(11);

    end


    % VYKRESLENI
    if (get(handles.checkbox3,'Value') == get(handles.checkbox3,'Max'))

        if ((get(handles.checkbox10,'Value') == get(handles.checkbox10,'Max'))&& (get(handles.checkbox11,'Value') == get(handles.checkbox11,'Max')))
            vadcepstralni(filename,delka_ramce,initc,pc,alfac,1,1);
        elseif ((get(handles.checkbox10,'Value') == get(handles.checkbox10,'Min'))&& (get(handles.checkbox11,'Value') == get(handles.checkbox11,'Max')))
            vadcepstralni(filename,delka_ramce,initc,pc,alfac,0,1);
        elseif ((get(handles.checkbox10,'Value') == get(handles.checkbox10,'Max'))&& (get(handles.checkbox11,'Value') == get(handles.checkbox11,'Min')))
            vadcepstralni(filename,delka_ramce,initc,pc,alfac,1,0);
        elseif ((get(handles.checkbox10,'Value') == get(handles.checkbox10,'Min'))&& (get(handles.checkbox11,'Value') == get(handles.checkbox11,'Min')))
            vadcepstralni(filename,delka_ramce,initc,pc,alfac,0,0);
        end

    end



    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%Modifikovany detektor%%%%%%%
    %INIT
    initd = str2double(get(handles.popupmenu28,'String'));  % hodnota prevedena na cislo
    indexd = get(handles.popupmenu28,'Value');            % prislusny index
    switch indexd
        case 1
            initd = initd(1);
        case 2
            initd = initd(2);
        case 3
            initd = initd(3);

    end
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%Vstupni parametry pro MODIFIKOVANY DETEKTOR
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %P
    pc = str2double(get(handles.pkepstr,'String'));
    indexc = get(handles.pkepstr,'Value');            % prislusny index
    switch indexc
        case 1
            pc = pc(1);
        case 2
            pc = pc(2);
        case 3
            pc = pc(3);
        case 4
            pc = pc(4);
        case 5
            pc = pc(5);
        case 6
            pc = pc(6);
        case 7
            pc = pc(7);
        case 8
            pc = pc(8);
        case 9
            pc = pc(9);
        case 10
            pc = pc(10);
        case 11
            pc = pc(11);

    end

    %ALFA
    alfac = str2double(get(handles.alfakepstr,'String'));
    indexalfac = get(handles.alfakepstr,'Value');            % prislusny index
    switch indexalfac
        case 1
            alfac = alfac(1);
        case 2
            alfac = alfac(2);
        case 3
            alfac = alfac(3);
        case 4
            alfac = alfac(4);
        case 5
            alfac = alfac(5);
        case 6
            alfac = alfac(6);
        case 7
            alfac = alfac(7);
        case 8
            alfac = alfac(8);
        case 9
            alfac = alfac(9);
        case 10
            alfac = alfac(10);
        case 11
            alfac = alfac(11);

    end
    %P
    pi = str2double(get(handles.popupmenu8,'String'));
    indexp = get(handles.popupmenu8,'Value');            % prislusny index
    switch indexp
        case 1
            pi = pi(1);
        case 2
            pi = pi(2);
        case 3
            pi = pi(3);
        case 4
            pi = pi(4);
        case 5
            pi = pi(5);
        case 6
            pi = pi(6);
        case 7
            pi = pi(7);
        case 8
            pi = pi(8);
        case 9
            pi = pi(9);
        case 10
            pi = pi(10);
        case 11
            pi = pi(11);

    end

    %ALFA
    alfai = str2double(get(handles.popupmenu9,'String'));
    indexalfai = get(handles.popupmenu9,'Value');            % prislusny index
    switch indexalfai
        case 1
            alfai = alfai(1);
        case 2
            alfai = alfai(2);
        case 3
            alfai = alfai(3);
        case 4
            alfai = alfai(4);
        case 5
            alfai = alfai(5);
        case 6
            alfai = alfai(6);
        case 7
            alfai = alfai(7);
        case 8
            alfai = alfai(8);
        case 9
            alfai = alfai(9);
        case 10
            alfai = alfai(10);
        case 11
            alfai = alfai(11);

    end
    %P
    pe = str2double(get(handles.popupmenu3,'String'));
    indexpe = get(handles.popupmenu3,'Value');            % prislusny index
    switch indexp
        case 1
            pe = pe(1);
        case 2
            pe = pe(2);
        case 3
            pe = pe(3);
        case 4
            pe = pe(4);
        case 5
            pe = pe(5);
        case 6
            pe = pe(6);
        case 7
            pe = pe(7);
        case 8
            pe = pe(8);
        case 9
            pe = pe(9);
        case 10
            pe = pe(10);
        case 11
            pe = pe(11);

    end
    %ALFA

    alfae = str2double(get(handles.popupmenu4,'String'));
    indexalfae = get(handles.popupmenu4,'Value');            % prislusny index
    switch indexalfae
        case 1
            alfae = alfae(1);
        case 2
            alfae = alfae(2);
        case 3
            alfae = alfae(3);
        case 4
            alfae = alfae(4);
        case 5
            alfae = alfae(5);
        case 6
            alfae = alfae(6);
        case 7
            alfae = alfae(7);
        case 8
            alfae = alfae(8);
        case 9
            alfae = alfae(9);
        case 10
            alfae = alfae(10);
        case 11
            alfae = alfae(11);

    end

    %%%%%%%%Vykresleni


    if (get(handles.checkbox12,'Value') == get(handles.checkbox12,'Max'))

        if (get(handles.radiobutton5,'Value') == get(handles.radiobutton5,'Max'))
            detektor(filename,delka_ramce,0,initd,1,0.5,0,0.1,0,0.2,1);
        end
        if (get(handles.radiobutton6,'Value') == get(handles.radiobutton6,'Max'))
            detektor(filename,delka_ramce,1,initd,pc,alfac,pi,alfai,pe,alfae,1);
        end

    end


    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%% G.729 %%%%%%%%%%%%%%%
    % Bef
    bef = str2double(get(handles.popupmenu18,'String'));
    indexbef = get(handles.popupmenu18,'Value');            % prislusny index
    switch indexbef
        case 1
            bef = bef(1);
        case 2
            bef = bef(2);
        case 3
            bef = bef(3);
        case 4
            bef = bef(4);
        case 5
            bef = bef(5);
        case 6
            bef = bef(6);
        case 7
            bef = bef(7);
        case 8
            bef = bef(8);
        case 9
            bef = bef(9);
        case 10
            bef = bef(10);
        case 11
            bef = bef(11);

    end

    % Bel
    bel = str2double(get(handles.popupmenu21,'String'));
    indexbel = get(handles.popupmenu21,'Value');            % prislusny index
    switch indexbel
        case 1
            bel = bel(1);
        case 2
            bel = bel(2);
        case 3
            bel = bel(3);
        case 4
            bel = bel(4);
        case 5
            bel = bel(5);
        case 6
            bel = bel(6);
        case 7
            bel = bel(7);
        case 8
            bel = bel(8);
        case 9
            bel = bel(9);
        case 10
            bel = bel(10);
        case 11
            bel = bel(11);

    end

    % BLSF
    blsf = str2double(get(handles.popupmenu22,'String'));
    indexblsf = get(handles.popupmenu22,'Value');            % prislusny index
    switch indexblsf
        case 1
            blsf = blsf(1);
        case 2
            blsf = blsf(2);
        case 3
            blsf = blsf(3);
        case 4
            blsf = blsf(4);
        case 5
            blsf = blsf(5);
        case 6
            blsf = blsf(6);
        case 7
            blsf = blsf(7);
        case 8
            blsf = blsf(8);
        case 9
            blsf = blsf(9);
        case 10
            blsf = blsf(10);
        case 11
            blsf = blsf(11);

    end

    %BZC
    bzc = str2double(get(handles.popupmenu23,'String'));
    indexbzc = get(handles.popupmenu23,'Value');            % prislusny index
    switch indexbzc
        case 1
            bzc = bzc(1);
        case 2
            bzc = bzc(2);
        case 3
            bzc = bzc(3);
        case 4
            bzc = bzc(4);
        case 5
            bzc = bzc(5);
        case 6
            bzc = bzc(6);
        case 7
            bzc = bzc(7);
        case 8
            bzc = bzc(8);
        case 9
            bzc = bzc(9);
        case 10
            bzc = bzc(10);
        case 11
            bzc = bzc(11);

    end

    if (get(handles.checkbox4,'Value') == get(handles.checkbox4,'Max'))
        g729(filename,bef,bel,blsf,bzc,1);
    end
end


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




% --------------------------------------------------------------------
function file_Callback(hObject, eventdata, handles)
% hObject    handle to file (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function close_Callback(hObject, eventdata, handles)

%[filename, pathname] = uigetfile('*.wav', 'Pick a WAV file');
close();
%dir('d:\missed\*.wav');
% hObject    handle to close (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 tlopen.
function tlopen_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile('*.wav', 'Pick a WAV file');





%set(handles.tlopen,'Cesta',pathname);
set(handles.tlopen,'UserData',[pathname filename]);

set(handles.edit1,'String',get(handles.tlopen,'UserData'));


% hObject    handle to tlopen (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)





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


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

clear all;
clc;
close all;
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)






% --- Executes on selection change in popupmenu18.
function popupmenu18_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu18 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu18 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu18


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

% Hints: contents = get(hObject,'String') returns popupmenu21 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu21


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

% Hints: contents = get(hObject,'String') returns popupmenu22 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu22


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

% Hints: contents = get(hObject,'String') returns popupmenu23 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu23


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

if ((get(handles.checkbox1,'Value') == get(handles.checkbox1,'Max')) &&  (get(handles.checkbox6,'Value') == get(handles.checkbox6,'Max')))
    close Figure 1;
end

if ((get(handles.checkbox1,'Value') == get(handles.checkbox1,'Max')) &&  (get(handles.checkbox7,'Value') == get(handles.checkbox7,'Max')))
    close Figure 2;
end

if ((get(handles.checkbox2,'Value') == get(handles.checkbox2,'Max')) &&  (get(handles.checkbox8,'Value') == get(handles.checkbox8,'Max')))
    close Figure 3;
end

if ((get(handles.checkbox2,'Value') == get(handles.checkbox2,'Max')) &&  (get(handles.checkbox9,'Value') == get(handles.checkbox9,'Max')))
    close Figure 4;
end

if ((get(handles.checkbox3,'Value') == get(handles.checkbox3,'Max')) &&  (get(handles.checkbox10,'Value') == get(handles.checkbox10,'Max')))
    close Figure 5;
end

if ((get(handles.checkbox3,'Value') == get(handles.checkbox3,'Max')) &&  (get(handles.checkbox11,'Value') == get(handles.checkbox11,'Max')))
    close Figure 6;
end

if (get(handles.checkbox4,'Value') == get(handles.checkbox4,'Max'))
    close Figure 7;
end

if (get(handles.checkbox12,'Value') == get(handles.checkbox12,'Max'))
    close Figure 8;
end

if (get(handles.checkboxroc,'Value') == get(handles.checkbox12,'Max'))
    close Figure 9;
end



% hObject    handle to zavrit_butoon (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 prehrat_butoon.
function prehrat_butoon_Callback(hObject, eventdata, handles)

filename = get(handles.tlopen,'UserData');
[y,fs]=wavread(filename);
sound(y,fs)


% hObject    handle to prehrat_butoon (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 checkbox6.
function checkbox6_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox6 (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 checkbox6


% --- Executes on button press in checkbox8.
function checkbox8_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox8 (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 checkbox8


% --- Executes on button press in checkbox9.
function checkbox9_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox9 (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 checkbox9


% --- Executes on button press in checkbox10.
function checkbox10_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox10 (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 checkbox10


% --- Executes on button press in checkbox11.
function checkbox11_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox11 (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 checkbox11


% --- Executes on button press in checkbox7.
function checkbox7_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox7 (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 checkbox7




% --- Executes on selection change in popupmenu27.
function popupmenu27_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu27 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu27 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu27


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

% Hints: contents = get(hObject,'String') returns popupmenu28 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu28


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


% --- Executes on selection change in popupmenu29.
function popupmenu29_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu29 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu29 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu29


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


% --- Executes on button press in checkbox14.
function checkbox14_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox14 (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 checkbox14




% --- Executes on button press in checkbox15.
function checkbox15_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox15 (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 checkbox15


% --- Executes on button press in checkbox16.
function checkbox16_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox16 (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 checkbox16





% --- Executes on button press in tldat.
function tldat_Callback(hObject, eventdata, handles)
% hObject    handle to tldat (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[datname, pathdatname] = uigetfile('*.dat', 'Pick a WAV file');
set(handles.tldat,'UserData',[pathdatname datname]);
set(handles.editdat,'String',get(handles.tldat,'UserData'));

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


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


% --- Executes on button press in roc.
function roc_Callback(hObject, eventdata, handles)
% hObject    handle to roc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if (get(handles.roc,'Value') == get(handles.roc,'Max'))

    %%%%%%%%%%%%%%%%%%%%%%%
    % Ziskani parametru%%%%

    delka_ramce = 128;
    init = 10;
    p = 0;
    alfa = 0;
    modifik = 0;
    zasum = 0;
    roc = 0;
    %DELKA_RAMCE
    delka_ramce = str2double(get(handles.popupmenu1,'String'));
    indexd = get(handles.popupmenu1,'Value');            % prislusny index
    switch indexd
        case 1
            delka_ramce = delka_ramce(1);
        case 2
            delka_ramce = delka_ramce(2);
    end
    %%%%%%%%%%%%%ENERGETICKY%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if (get(handles.pushbutton1,'Value') == get(handles.pushbutton1,'Max'))
        %INIT
        init = str2double(get(handles.popupmenu2,'String'));  % hodnota prevedena na cislo
        indexi = get(handles.popupmenu2,'Value');            % prislusny index
        switch indexi
            case 1
                init = init(1);
            case 2
                init = init(2);
            case 3
                init = init(3);

        end
    end
    %%%%%%%%%%%%%INTENZITY%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %INIT
    initi = str2double(get(handles.popupmenu7,'String'));  % hodnota prevedena na cislo
    indexi = get(handles.popupmenu7,'Value');            % prislusny index
    switch indexi
        case 1
            initi = initi(1);
        case 2
            initi = initi(2);
        case 3
            initi = initi(3);

    end

    %%%%%%%%%%%%%KEPSTRALNI%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %INIT
    initc = str2double(get(handles.initkepstr,'String'));  % hodnota prevedena na cislo
    indexc = get(handles.initkepstr,'Value');            % prislusny index
    switch indexc
        case 1
            initc = initc(1);
        case 2
            initc = initc(2);
        case 3
            initc = initc(3);

    end

    %INIT Modifikovany
    initd = str2double(get(handles.popupmenu28,'String'));  % hodnota prevedena na cislo
    indexd = get(handles.popupmenu28,'Value');            % prislusny index
    switch indexd
        case 1
            initd = initd(1);
        case 2
            initd = initd(2);
        case 3
            initd = initd(3);

    end

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%Vstupni parametry pro MODIFIKOVANY DETEKTOR
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %P
    pc = str2double(get(handles.pkepstr,'String'));
    indexc = get(handles.pkepstr,'Value');            % prislusny index
    switch indexc
        case 1
            pc = pc(1);
        case 2
            pc = pc(2);
        case 3
            pc = pc(3);
        case 4
            pc = pc(4);
        case 5
            pc = pc(5);
        case 6
            pc = pc(6);
        case 7
            pc = pc(7);
        case 8
            pc = pc(8);
        case 9
            pc = pc(9);
        case 10
            pc = pc(10);
        case 11
            pc = pc(11);

    end

    %ALFA
    alfac = str2double(get(handles.alfakepstr,'String'));
    indexalfac = get(handles.alfakepstr,'Value');            % prislusny index
    switch indexalfac
        case 1
            alfac = alfac(1);
        case 2
            alfac = alfac(2);
        case 3
            alfac = alfac(3);
        case 4
            alfac = alfac(4);
        case 5
            alfac = alfac(5);
        case 6
            alfac = alfac(6);
        case 7
            alfac = alfac(7);
        case 8
            alfac = alfac(8);
        case 9
            alfac = alfac(9);
        case 10
            alfac = alfac(10);
        case 11
            alfac = alfac(11);

    end
    %P
    pi = str2double(get(handles.popupmenu8,'String'));
    indexp = get(handles.popupmenu8,'Value');            % prislusny index
    switch indexp
        case 1
            pi = pi(1);
        case 2
            pi = pi(2);
        case 3
            pi = pi(3);
        case 4
            pi = pi(4);
        case 5
            pi = pi(5);
        case 6
            pi = pi(6);
        case 7
            pi = pi(7);
        case 8
            pi = pi(8);
        case 9
            pi = pi(9);
        case 10
            pi = pi(10);
        case 11
            pi = pi(11);

    end

    %ALFA
    alfai = str2double(get(handles.popupmenu9,'String'));
    indexalfai = get(handles.popupmenu9,'Value');            % prislusny index
    switch indexalfai
        case 1
            alfai = alfai(1);
        case 2
            alfai = alfai(2);
        case 3
            alfai = alfai(3);
        case 4
            alfai = alfai(4);
        case 5
            alfai = alfai(5);
        case 6
            alfai = alfai(6);
        case 7
            alfai = alfai(7);
        case 8
            alfai = alfai(8);
        case 9
            alfai = alfai(9);
        case 10
            alfai = alfai(10);
        case 11
            alfai = alfai(11);

    end
    %P
    pe = str2double(get(handles.popupmenu3,'String'));
    indexpe = get(handles.popupmenu3,'Value');            % prislusny index
    switch indexp
        case 1
            pe = pe(1);
        case 2
            pe = pe(2);
        case 3
            pe = pe(3);
        case 4
            pe = pe(4);
        case 5
            pe = pe(5);
        case 6
            pe = pe(6);
        case 7
            pe = pe(7);
        case 8
            pe = pe(8);
        case 9
            pe = pe(9);
        case 10
            pe = pe(10);
        case 11
            pe = pe(11);

    end
    %ALFA

    alfae = str2double(get(handles.popupmenu4,'String'));
    indexalfae = get(handles.popupmenu4,'Value');            % prislusny index
    switch indexalfae
        case 1
            alfae = alfae(1);
        case 2
            alfae = alfae(2);
        case 3
            alfae = alfae(3);
        case 4
            alfae = alfae(4);
        case 5
            alfae = alfae(5);
        case 6
            alfae = alfae(6);
        case 7
            alfae = alfae(7);
        case 8
            alfae = alfae(8);
        case 9
            alfae = alfae(9);
        case 10
            alfae = alfae(10);
        case 11
            alfae = alfae(11);

    end

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%% G.729 %%%%%%%%%%%%%%%
    % Bef
    bef = str2double(get(handles.popupmenu18,'String'));
    indexbef = get(handles.popupmenu18,'Value');            % prislusny index
    switch indexbef
        case 1
            bef = bef(1);
        case 2
            bef = bef(2);
        case 3
            bef = bef(3);
        case 4
            bef = bef(4);
        case 5
            bef = bef(5);
        case 6
            bef = bef(6);
        case 7
            bef = bef(7);
        case 8
            bef = bef(8);
        case 9
            bef = bef(9);
        case 10
            bef = bef(10);
        case 11
            bef = bef(11);

    end

    % Bel
    bel = str2double(get(handles.popupmenu21,'String'));
    indexbel = get(handles.popupmenu21,'Value');            % prislusny index
    switch indexbel
        case 1
            bel = bel(1);
        case 2
            bel = bel(2);
        case 3
            bel = bel(3);
        case 4
            bel = bel(4);
        case 5
            bel = bel(5);
        case 6
            bel = bel(6);
        case 7
            bel = bel(7);
        case 8
            bel = bel(8);
        case 9
            bel = bel(9);
        case 10
            bel = bel(10);
        case 11
            bel = bel(11);

    end

    % BLSF
    blsf = str2double(get(handles.popupmenu22,'String'));
    indexblsf = get(handles.popupmenu22,'Value');            % prislusny index
    switch indexblsf
        case 1
            blsf = blsf(1);
        case 2
            blsf = blsf(2);
        case 3
            blsf = blsf(3);
        case 4
            blsf = blsf(4);
        case 5
            blsf = blsf(5);
        case 6
            blsf = blsf(6);
        case 7
            blsf = blsf(7);
        case 8
            blsf = blsf(8);
        case 9
            blsf = blsf(9);
        case 10
            blsf = blsf(10);
        case 11
            blsf = blsf(11);

    end

    %BZC
    bzc = str2double(get(handles.popupmenu23,'String'));
    indexbzc = get(handles.popupmenu23,'Value');            % prislusny index
    switch indexbzc
        case 1
            bzc = bzc(1);
        case 2
            bzc = bzc(2);
        case 3
            bzc = bzc(3);
        case 4
            bzc = bzc(4);
        case 5
            bzc = bzc(5);
        case 6
            bzc = bzc(6);
        case 7
            bzc = bzc(7);
        case 8
            bzc = bzc(8);
        case 9
            bzc = bzc(9);
        case 10
            bzc = bzc(10);
        case 11
            bzc = bzc(11);

    end


    %%%%%%%%Vykresleni

    %%% rozhodnuti, jestli se budou brat pouze zadane parametry, nebo defaultni
    if (get(handles.checkbox12,'Value') == get(handles.checkbox12,'Max'))

        if (get(handles.radiobutton5,'Value') == get(handles.radiobutton5,'Max'))
            modifik = 0;
        end
        if (get(handles.radiobutton6,'Value') == get(handles.radiobutton6,'Max'))
            modifik = 1;
        end

    end

    if (get(handles.checkboxsum,'Value') == get(handles.checkbox12,'Max'))
        zasum=1;
    end
    if (get(handles.checkboxroc,'Value') == get(handles.checkbox12,'Max'))
        roc = 1;
    end


    numbervad = get(handles.popupmenutest,'Value');            % prislusny index
    datname = get(handles.tldat,'UserData');
    filename = get(handles.tlopen,'UserData');
    vyhodnotROC(filename,datname,numbervad,modifik,zasum,roc,delka_ramce,init,initi,initc,initd,pe,pi,pc,alfae,alfai,alfac,bef,bel,blsf,bzc);
end


% --- Executes on selection change in popupmenutest.
function popupmenutest_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenutest (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenutest contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenutest


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


