function wdetail(vysH, info,cesta,handles)
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Decription: Creates a visual interface to fully or selectively play a portion of a wave file.
%             
%             This script will load a wave  file (mono or stereo)
%             and creates a figure with a plotting of the wave data. 
%             If the wave file has more than one channel then separate 
%             figures for each channel will be created. Each figure is      
%             created with additional toolbar buttons for playing the wave
%             data 'fully' or a 'selected region' in the respective channel.
%             
%             In addition it shows how to create toolbar buttons.
%
%
% Usage: 1. Type "pw" on the command line with no argument, or
%           Type pw('wavefile.wav') with wave filename as an argument
%           -  After loading a wave file a figure will be created with 
%              a plot of the wave file (for each channel).
%        2. To play the whole wave just click ">>" on the toolbar of the figure
%        3. To play a selected region just click "|>>|" on the toolbar
%           after selecting a region to play
%
%           - To select a region, do the following 
%                  First make sure the +/- zoom buttons are off (not depressed) on the toolbar]
%
%              (i)  left click   : to define the starting of the selection
%                                        (shown as solid  vertical red line)
%              (ii) right click  : to define the end of the selection region
%                                        (shown as dotted vertical red line)
%
% Author: Laine Berhane Kahsay
%         March 2005, Uni-Ulm
%
% To get this help: > help pw
%

% originál získán z webu
% http://www.mathworks.com/matlabcentral/fileexchange/7408
delkaS=120;%(s)      delka zpracovavaneho useku v (s) default 2min


% save roots ShowHiddenHandles status
RootSHH = get(0, 'ShowHiddenHandles');
%
% create a figure for the channel
   
    load('wicons.mat');
    fig=figure;
    % make all figure visible
    h.fig = fig;
    % set figure properties
    set(fig, 'WindowButtonDownFcn', 'wmouseclickext( guidata(gcbo) )', ...
             'KeyPressFcn', 'return', ...
             'UserData', [0 0], ...
             'NumberTitle', 'off', ...
             'Name', ['Zobrazení všech vybraných výsledků']);

    % get handle of toolbar
    set(0, 'showhiddenhandles', 'on');
    ut = findobj(fig,'type','uitoolbar');
    set(0, 'showhiddenhandles', RootSHH);
    % modify toolbar
%     uipushtool('cdata',Ico.PlayAll, 'parent', ut,'clickedcallback','wplaysoundext(guidata(gcbo), 1)', 'tooltipstring','play all'); 
    uipushtool('cdata',Ico.PlaySel, 'parent', ut,'clickedcallback','wplaysoundext(guidata(gcbo))', 'tooltipstring','play selection'); 
    
    % plot wave data

    
    % compute  time scale
if sum(info)==0
        % initialize two (left and right) vertical lines for selective playing 
    h.v1 = plot(NaN, NaN, 'r');
    h.v2 = plot(NaN, NaN, 'r--');
    h.vp = plot(NaN, NaN, 'r-.'); 
    
    part=round(get(handles.slider1, 'Value'));
    [x,fs]=readwav(cesta,'s',120*16000,120*16000*(part-1));
    ns=length(x)
    t =([1:ns]/fs);
    h.p2=plot(t, x(:), 'b');
    % find absolute maximum :- used to define 'YLim'
    amax = max(abs(x(:)));
    hold on;
    grid on;
else
    cislo_plotu=1;
    pocet=sum(info)+1;
    subplot(pocet,1,cislo_plotu)
    cislo_plotu=cislo_plotu+1;
    % initialize two (left and right) vertical lines for selective playing
    hold on 

        part=round(get(handles.slider1, 'Value'));
        [x,fs,]=readwav(cesta,'s',delkaS*16000,delkaS*16000*(part-1));
        ns=length(x);
        t =([1:ns]/fs);
        h.p2=plot(t, x(:), 'b');
        % find absolute maximum :- used to define 'YLim'
        grid on;
        h.v1 = plot(NaN, NaN, 'r','LineWidth',2);
        h.v2 = plot(NaN, NaN, 'r--','LineWidth',2);
        h.vp = plot(NaN, NaN, 'r-.','LineWidth',2); 
        title('Vstupni signal')    
        
    if get(handles.checkbox5,'Value')==1  %urceni poradi vykreslovani
        subplot(pocet,1,cislo_plotu);
        cislo_plotu=cislo_plotu+1;
        bar(vysH(part).hymna(2,:),vysH(part).hymna(1,:))   
        xmax=max(vysH(part).hymna(2,:));
        xmin=min(vysH(part).hymna(2,:));
        set(gca,'XLim',[xmin xmax]);
        title('detekce hymny')
        grid on
%         subplot(pocet,1,1)
%         set(gca,'XLim',[xmin xmax]);    
        
    end
    if get(handles.checkbox6,'Value')==1
        subplot(pocet,1,cislo_plotu);
        cislo_plotu=cislo_plotu+1;
        index=find(vysH(part).F0(1,:)>ones(1,length(vysH(part).F0(1,:))));
        plot(vysH(part).F0(2,index),vysH(part).F0(1,index),'*k');
        xmax=max(vysH(part).F0(2,:));
        xmin=min(vysH(part).F0(2,:));
        set(gca,'XLim',[xmin xmax]);
        
        title('Určení zakladního tónu')
%         subplot(pocet,1,1)   %dodatecne urceni mezi prvniho grafu 
%         set(gca,'XLim',[xmin xmax]);
        grid on
               
    end
    
    if get(handles.checkbox7,'Value')==1
        subplot(pocet,1,cislo_plotu);
        cislo_plotu=cislo_plotu+1;
        bar(vysH(part).time,vysH(part).res,'k');
        xmax=max(vysH(part).time);
        xmin=min(vysH(part).time);
        set(gca,'XLim',[xmin xmax]);
        
        title('Detekce hvizdu')
        grid on
    end
    if get(handles.checkbox8,'Value')==1
        subplot(pocet,1,cislo_plotu);
        cislo_plotu=cislo_plotu+1;
        
        plot(vysH(part).F0(2,:),vysH(part).E);
        xmax=max(vysH(part).F0(2,:));
        xmin=min(vysH(part).F0(2,:));
        set(gca,'XLim',[xmin xmax]);
        
        title('Energie')
        grid on      
    end
end
    
    % save "wave data" in handle
    h.x = x(:);
    h.fs = fs;
    h.bps = 16;
    h.ns = ns;
    
    % save handle in figure
    guidata(fig, h);
    
    
    
%       set(h.p2, 'Color', 'b');
% %     title( ['loaded wave file: ' wavefile ' channel ' num2str(i)], 'Interpreter', 'none');
%     ylabel('amp'); xlabel('Time (secs)');
%     axColor = [0.5 0.5 0.5];
%     set(gca, 'Color', 'w', ...
%              'Xlim', [ t(1) t(end)+10], 'Ylim', [-1.2*amax 1.2*amax], ..., 
%              'XColor', axColor, 'YColor', axColor, ...
%              'FontSize', 9);
