% Stuart N Wrigley, July 1998
% modified MPC 11/6/99 for generic UI routines

% FOR V3
%   this needs tidying up to make it easier for a human (me)
%   to change

fig=createmadfig('auto'); 
fig=createmadloadmenu(fig);
fig=createmadmenus(fig);
ud=get(gcf,'UserData');

standcolor=[0.8 0.8 0.8];
framecolor=[0.75 0.75 0.75];
buttoncolor=[0.753 0.753 0.753];

h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',standcolor, ...
	'ListboxTop',0, ...
	'Position',[0.02852852852852853 0.03909465020576132 0.09009009009009009 0.0411522633744856], ...
	'Style','text', ...
	'Tag','ZOOMFigureState', ...
	'Visible','off');
  
h1 = axes('Parent',fig, ...
	'Box','on', ...
   'ButtonDownFcn','auto playSignal',...
	'CameraUpVector',[0 1 0], ...
	'CameraUpVectorMode','manual', ...
	'Color',[1 1 1], ...
	'DrawMode','fast', ...
	'NextPlot','add', ...
	'Position',[0.07682291666666666 0.7488151658767773 0.6510416666666666 0.2251184834123223], ...
	'Tag','signalAxes', ...
	'XColor',[0 0 0], ...
	'XLimMode','manual', ...
	'YColor',[0 0 0], ...
	'YLim',[-1.1 1.1], ...
	'YLimMode','manual', ...
	'ZColor',[0 0 0]);
h2 = text('Parent',h1, ...
	'Units','normalized', ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','center', ...
	'Position',[-0.04840319361277445 0.4947368421052631 0], ...
	'Rotation',90, ...
	'String','Signal', ...
	'Tag','Axes1Text3', ...
	'VerticalAlignment','baseline');
set(get(h2,'Parent'),'YLabel',h2);
h2 = line('Parent',h1, ...
   'ButtonDownFcn','auto playSignal',...
	'Color',[0 0 1], ...
	'Tag','signalLine', ...
	'XData',[], ...
	'YData',[]);
h2 = line('Parent',h1, ...
	'ButtonDownFcn','auto left', ...
	'Color',[1 0 0], ...
	'EraseMode','xor', ...
	'Tag','signalLC');
h2 = line('Parent',h1, ...
	'ButtonDownFcn','auto right', ...
	'Color',[1 0 0], ...
	'EraseMode','xor', ...
	'Tag','signalRC');
h2 = text('Parent',h1, ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','center', ...
	'Position',[0.498 -1.553191489361702 17.32050807568877], ...
	'Tag','signalAxesText3', ...
	'VerticalAlignment','cap');
set(get(h2,'Parent'),'XLabel',h2);
h2 = text('Parent',h1, ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','right', ...
	'Position',[-0.1180 1.1915 17.3205], ...
	'Tag','signalAxesText2', ...
	'Visible','off');
set(get(h2,'Parent'),'ZLabel',h2);
h2 = text('Parent',h1, ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','center', ...
	'Position',[0.498 1.148936170212766 17.32050807568877], ...
	'Tag','signalAxesText1', ...
	'VerticalAlignment','bottom');
set(get(h2,'Parent'),'Title',h2);
h1 = axes('Parent',fig, ...
	'Box','on', ...
	'CameraUpVector',[0 1 0], ...
	'CameraUpVectorMode','manual', ...
	'Color',[1 1 1], ...
	'DrawMode','fast', ...
	'NextPlot','replacechildren', ...
	'Position',[0.075 0.118 0.652 0.235], ...
	'Tag','autoAxes', ...
	'XColor',[0 0 0], ...
	'XLimMode','manual', ...
	'YColor',[0 0 0], ...
	'YLim',[-1.1 1.1], ...
	'YLimMode','manual', ...
	'ZColor',[0 0 0]);
h2 = text('Parent',h1, ...
	'Units','normalized', ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','center', ...
	'Position',[0.5 -0.255 0], ...
	'String','Lag (milliseconds)', ...
	'Tag','Axes2Text4', ...
	'VerticalAlignment','cap');
set(get(h2,'Parent'),'XLabel',h2);
h2 = text('Parent',h1, ...
	'Units','normalized', ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','center', ...
	'Position',[-0.0484 0.5 0], ...
	'Rotation',90, ...
	'String','Autocorrelation', ...
	'Tag','Axes2Text3', ...
	'VerticalAlignment','baseline');
set(get(h2,'Parent'),'YLabel',h2);
h2 = line('Parent',h1, ...
	'Color',[0 0 1], ...
	'EraseMode','background', ...
	'Tag','autoLine', ...
	'XData',[], ...
	'YData',[]);
h2 = text('Parent',h1, ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','right', ...
	'Position',[-0.118 6.551 9.160], ...
	'Tag','autoAxesText2', ...
	'Visible','off');
set(get(h2,'Parent'),'ZLabel',h2);
h2 = text('Parent',h1, ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','center', ...
	'Position',[0.4980 1.1429 9.1603], ...
	'Tag','autoAxesText1', ...
	'VerticalAlignment','bottom');
set(get(h2,'Parent'),'Title',h2);
h1 = axes('Parent',fig, ...
	'Box','on', ...
	'CameraUpVector',[0 1 0], ...
	'CameraUpVectorMode','manual', ...
	'Color',[1 1 1], ...
	'Position',[0.0755 0.443 0.654 0.223], ...
	'Tag','contourAxes', ...
	'XColor',[0 0 0], ...
	'YColor',[0 0 0], ...
	'YLim',[-1 1], ...
	'YLimMode','manual', ...
	'ZColor',[0 0 0]);
h2 = line('Parent',h1, ...
	'Color',[0 0 1], ...
	'EraseMode','background', ...
	'Tag','contourLine', ...
	'XData',[], ...
	'YData',[]);
h2 = text('Parent',h1, ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','center', ...
	'Position',[0.5 -1.56 9.160], ...
	'Tag','Axes1Text5', ...
	'VerticalAlignment','cap');
set(get(h2,'Parent'),'XLabel',h2);
h2 = text('Parent',h1, ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','center', ...
	'Position',[-0.04790419161676647 -0.032258064516129 9.160254037844386], ...
	'Rotation',90, ...
	'String','Pitch Contour (ms)', ...
	'Tag','Axes1Text4', ...
	'VerticalAlignment','baseline');
set(get(h2,'Parent'),'YLabel',h2);
h2 = text('Parent',h1, ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','right', ...
	'Position',[-0.1177644710578842 4.010752688172043 9.160254037844386], ...
	'Tag','Axes1Text2', ...
	'Visible','off');
set(get(h2,'Parent'),'ZLabel',h2);
h2 = text('Parent',h1, ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','center', ...
	'Position',[0.499001996007984 1.150537634408602 9.160254037844386], ...
	'Tag','Axes1Text1', ...
	'VerticalAlignment','bottom');
set(get(h2,'Parent'),'Title',h2);


h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'ListboxTop',0, ...
	'Position',[0.745 0.7464454976303319 0.2493368700265252 0.2251184834123223], ...
	'Style','frame', ...
	'Tag','Frame1');
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'ListboxTop',0, ...
	'Position',[0.8249336870026525 0.9099526066350712 0.07957559681697612 0.04265402843601896], ...
	'String','Window', ...
	'Style','text', ...
	'Tag','WindowLabel');
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'Callback','auto changeWin', ...
	'ListboxTop',0, ...
	'Position',[0.77 0.78 0.16 0.06], ...
	'Style','popupmenu', ...
	'Tag','winSizePopup', ...
	'Value',6);
ud.windowtype = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'Callback','auto changeWin', ...
	'ListboxTop',0, ...
	'Position',[0.77 0.85 0.16 0.06], ...
	'Style','popupmenu', ...
	'Tag','windowType', ...
	'Value',4);



h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'ListboxTop',0, ...
	'Position',[0.745 0.4407582938388626 0.2493368700265252 0.2725118483412323], ...
	'Style','frame', ...
	'Tag','Frame2');
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'ListboxTop',0, ...
	'Position',[0.8103448275862069 0.6469194312796209 0.1206896551724138 0.04265402843601896], ...
	'String','Signal Zoom', ...
	'Style','text', ...
	'Tag','Zoom label');
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',buttoncolor, ...
	'Callback','auto zoom', ...
	'Enable','off', ...
	'ListboxTop',0, ...
	'Position',[0.8249336870026525 0.59478672985782 0.03050397877984085 0.04502369668246446], ...
	'String','+', ...
	'Tag','zoomButton');
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',buttoncolor, ...
	'Callback','auto unzoom', ...
	'Enable','off', ...
	'ListboxTop',0, ...
	'Position',[0.8766578249336869 0.59478672985782 0.02917771883289124 0.04502369668246446], ...
	'String','-', ...
	'Tag','unzoomButton');
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',buttoncolor, ...
	'Callback','auto zoomToCursors', ...
	'Enable','off', ...
	'ListboxTop',0, ...
	'Position',[0.8 0.53 0.12 0.05], ...
	'String','to cursors', ...
	'Tag','zoomToCursorsButton');
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',buttoncolor, ...
	'Callback','auto showall', ...
	'Enable','off', ...
	'ListboxTop',0, ...
	'Position',[0.8 0.47 0.12 0.05], ...
	'String','show all', ...
	'Tag','showallButton');


h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'ListboxTop',0, ...
	'Position',[0.745 0.08378672985781991 0.25 0.3227962085308057], ...
	'Style','frame', ...
	'Tag','Frame3');
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'ListboxTop',0, ...
	'Position',[0.8275862068965517 0.3388625592417062 0.07161803713527851 0.04265402843601896], ...
	'String','Signal', ...
	'Style','text', ...
	'Tag','Sound label');

lpos=0.747;  lwid=0.24;
  
  h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'ListboxTop',0, ...
	'Position',[lpos 0.2796 lwid 0.0379], ...
	'String','play on release', ...
	'Style','checkbox', ...
	'Tag','playCheck', ...
	'Value',1);
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'Callback','auto useClip', ...
	'ListboxTop',0, ...
	'Position',[lpos 0.2417061611374408 0.13 0.03317535545023697], ...
	'String','centre clip:', ...
	'Style','checkbox', ...
	'Tag','clipCheck');
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'Callback','auto linkCursors', ...
	'ListboxTop',0, ...
	'Position',[lpos 0.2037914691943128 lwid 0.03080568720379147], ...
	'String','link cursors', ...
	'Style','checkbox', ...
	'Tag','linkCursorsCheck');
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'ListboxTop',0, ...
	'Position',[lpos 0.1588 lwid 0.0427], ...
	'String','add existing', ...
	'Style','checkbox', ...
	'Tag','accumulateCheck');
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'Callback','auto recalc', ...
	'ListboxTop',0, ...
	'Position',[lpos 0.1282227488151659 lwid 0.03317535545023697], ...
	'String','recalc. autocorrelation', ...
	'Style','checkbox', ...
	'Tag','recalcCheck', ...
	'Value',1);
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',framecolor, ...
	'Callback','auto recalcContour', ...
	'ListboxTop',0, ...
	'Position',[lpos 0.092 lwid 0.03317535545023697], ...
	'String','recalc. contour', ...
	'Style','checkbox', ...
	'Tag','recalcContourCheck', ...
	'Value',1);
h1 = uicontrol('Parent',fig, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Callback','auto changeClip', ...
	'Enable','off', ...
	'ListboxTop',0, ...
	'Position',[0.9045092838196286 0.2322274881516588 0.0636604774535809 0.04502369668246446], ...
	'String','30', ...
	'Style','edit', ...
	'Tag','clipAmount', ...
	'Value',1);
h1 = uicontrol('Parent',fig, ...
   'Units','normalized', ...
   'Callback','auto plotContour',...
	'BackgroundColor',buttoncolor, ...
	'ListboxTop',0, ...
	'Position',[0.745 0.01  0.25 0.055], ...
	'String','Calculate pitch contour', ...
	'Tag','calcContour');

  set(gcf,'UserData',ud);
  
