
fig=createmadfig('lpcspect'); 
fig=createmadloadmenu(fig);
fig=createmadmenus(fig);

figcol=get(fig,'Color');
bc=figcol;
wc=[1.0 1.0 1.0];

left=0.05;
right=1.0;
mainbase=0.85;
gutter=0.01;
maincontrolbase=mainbase-0.05;

% main waveform display & UI controls
ud.wavAxes = axes('Parent',fig,...
   'Position',[left mainbase 0.75 0.99-mainbase],...
   'DrawMode','fast', 'NextPlot','replacechildren', 'Box','on','XTick',[]);
   
ud.gapstring=uicontrol('Parent',fig, ...
    'Position',[left maincontrolbase 0.17 0.03], 'String','', ...
    'HorizontalAlignment','left', 'Style','text','BackgroundColor',bc,'Enable','on',...
    'FontSize',10);
   
uicontrol('Parent',fig, ...
	'Callback','lpcspect preemphChecked', ...
      'Position',[0.81 mainbase 0.18 0.04], ...
	'String','preemphasise', 'Style','checkbox', 'Tag','preemphCheck','Value',0);
   
uicontrol('Parent',fig, ...
	'Position',[0.81 mainbase+0.05 0.18 0.04], ...
	'String','play on release', 'Style','checkbox', 'Tag','playCheck','Value',0);

uicontrol('Parent',fig, ...
	'Callback','lpcspect linkCursors',...
       'Position',[0.81 mainbase+0.1 0.18 0.04], ...
	'String','link cursors', 'Style','checkbox', 'Tag','linkCursorsCheck','Value',0);  
		
uicontrol('Parent',fig, ...
	'Position',[0.22 maincontrolbase 0.1 0.04], 'Callback','lpcspect zoom',...
	'String','zoom', 'Style','pushbutton', 'Tag','zoomButton');
	
uicontrol('Parent',fig, ...
	'Position',[0.32 maincontrolbase 0.1 0.04], 'Callback','lpcspect unzoom',...
	'String','unzoom', 'Style','pushbutton', 'Tag','unzoomButton');

uicontrol('Parent',fig, ...
	'Position',[0.42 maincontrolbase 0.1 0.04], 'Callback','lpcspect zoomToCursors',...
	'String','to cursor', 'Style','pushbutton', 'Tag','zoomToCursorsButton');

uicontrol('Parent',fig, ...
	'Position',[0.52 maincontrolbase 0.1 0.04], ...
	'Callback','lpcspect showall','String','show all', 'Style','pushbutton', 'Tag','showallButton');

% wave segment and error signal & UI controls

base=0.05;
wavheight=0.3;
wavgutter=0.05;
wavwidth=0.5;

ud.wavsegAxes = axes('Parent',fig,...
   'Position',[left base+wavheight+wavgutter+0.15 wavwidth wavheight-0.1 ],...
   'DrawMode','fast', 'NextPlot','replacechildren', 'Box','on');

uicontrol('Parent',fig, ...
    'Callback','lpcspect useHamming',...
    'Position',[left+0.01 base+2*wavheight+0.06 0.13 0.03], ...
    'String','Hamming', 'Style','checkbox', 'Tag','useHammingCheck',...
    'BackgroundColor',wc);

uicontrol('Parent',fig, ...
    'Position',[left+0.29 base+2*wavheight+0.06 0.2 0.03], 'String','waveform & residual', ...
    'HorizontalAlignment','right', 'Style','text','BackgroundColor',wc);
   
ud.totalerror=uicontrol('Parent',fig, ...
    'Position',[left+0.01 base+wavheight+0.21 0.25 0.03], 'String','', ...
    'HorizontalAlignment','left', 'Style','text',...
    'BackgroundColor',wc,'FontSize',10);

		   
% DFT/LPC and error signal spectra displays

ud.spectAxes = axes('Parent',fig,...
   'Position',[left base+0.01 wavwidth wavheight+0.15 ],...
    'DrawMode','fast','NextPlot','replacechildren', 'Box','on');

uicontrol('Parent',fig, ...
    'Position',[left+0.29 base+wavheight+0.1 0.2 0.03], 'String','dft, lpc & residual spectra', ...
    'HorizontalAlignment','right', 'Style','text','BackgroundColor',wc);

% Z-plane poles and LPC UI controls

ud.PZAxes = axes('Parent',fig,...
   'Position',[left+wavwidth+0.05 base+0.07 0.4 0.55], 'DrawMode','fast',...
   'NextPlot','replacechildren', 'Box','on', 'XTick',[],'YTick',[]); 

uicontrol('Parent',fig, ...
    'Position',[left+wavwidth+0.05 base+2*wavheight+0.04 0.17 0.05], 'String','LPC order:', ...
    'HorizontalAlignment','right', 'Style','text','BackgroundColor',bc);
    
ud.lpcordermenu=uicontrol('Parent',fig, ...
    'Position',[left+wavwidth+0.23 base+2*wavheight+0.04 0.1 0.05], 'Callback','lpcspect lpcorderchanged',...
    'String',num2cell(2:2:40), 'Style','popupmenu', 'Value',5,...
    'Enable','off','BackgroundColor',bc);
   
ud.freqstring=uicontrol('Parent',fig, ...
    'Position',[left+wavwidth+0.055 base+0.57 0.115 0.03], 'String','', ...
    'HorizontalAlignment','left', 'Style','text','BackgroundColor',wc,'Enable','off');

set(gcf,'UserData',ud);
