% user interface for sine-wave speech demos

fig=createmadfig('sws'); 
% MENUS

filemenu=uimenu('Parent',fig, 'Label','File');
  ud.save=uimenu('Parent',filemenu, 'Callback','sws saveSignal','Label','&save mix ...','Accelerator','S');
%fig=createmadloadmenu(fig);
fig=createmadmenus(fig);

% default uicontrol details

sp=0.015;
th=3*sp;		% default text height
eh=4.5*sp;		% default edit box height
ph=4*sp;		% default popup height
ch=3*sp;		% default check box height
bh=6*sp;		% default button height
hsh=5*sp;       % default horizontal slider height

height=0.23;
swsbase=0.63; swscontrols=swsbase+height+0.01;

left=0.025;
width=0.95;

% axes and controls for sws displays

ud.sws1axes = axes('Parent',fig,...
          'Position',[left swsbase width height],...
		  'DrawMode','fast',...
		  'NextPlot','replacechildren',...
		  'Box','on',...
		  'XTick',[],...
		  'YTick',[]);

ud1.loaded=0;

ud1.load=uicontrol('Parent',fig, ...
	'Callback','sws load',...
	'Position',[left swscontrols 0.1 ch], ...
	'String','load ...', ...
	'Style','pushbutton',...
	'UserData',ud.sws1axes);

uicontrol('Parent',fig, ...
	'Position',[left+0.11 swscontrols-0.01 0.08 th], ...
	'String','output:', ...
	'Style','text');


ud1.selectoutput=uicontrol('Parent',fig, ...
	'Callback','sws selectoutput', ...
	'Position',[left+0.2 swscontrols-0.01 0.14 ch], ...
	'String','sws|natural|silence', ...
	'Style','popupmenu', ...
	'Value',1,...
	'UserData',ud.sws1axes,...
	'Enable','off');

ud1.useam=uicontrol('Parent',fig, ...
	'Callback','sws useam',...
	'Position',[left+0.36 swscontrols 0.06 ch], ...
	'String','am', ...
	'Style','checkbox',...
	'UserData',ud.sws1axes,...
	'Enable','off');

ud1.amfreqbox=uicontrol('Parent',fig, ...
	'Callback','sws amfreqbox',...
	'Position',[left+0.43 swscontrols 0.07 ch+0.01], ...
	'String','', ...
	'Style','edit',...
	'UserData',ud.sws1axes,...
	'Enable','off');

    
uicontrol('Parent',fig, ...
	'Position',[left+0.51 swscontrols-0.01 0.03 th], ...
	'String','Hz', ...
	'Style','text');
	
ud1.setnat=uicontrol('Parent',fig, ...
	'Callback','sws setnat', ...
	'Position',[left+0.56 swscontrols 0.18 ch], ...
	'String','natural f & a|constant a|constant f', ...
	'Style','popupmenu', ...
	'Value',1,...
	'UserData',ud.sws1axes,...
	'Enable','off');

ud1.useleft=uicontrol('Parent',fig, ...
	'Callback','sws useleft',...
	'Position',[left+0.77 swscontrols 0.07 ch], ...
	'String','left', ...
	'Style','checkbox',...
	'UserData',ud.sws1axes,...
    'Value',1,...
	'Enable','off');
    
ud1.useright=uicontrol('Parent',fig, ...
	'Callback','sws useright',...
	'Position',[left+0.84 swscontrols 0.09 ch], ...
	'String','right', ...
	'Style','checkbox',...
	'UserData',ud.sws1axes,...
    'Value',1,...
	'Enable','off');
    
set(ud.sws1axes,'UserData',ud1);	

% ---- sws 2

swsbase=0.3; swscontrols=swsbase+height+0.01;

ud.sws2axes = axes('Parent',fig,...
          'Position',[left swsbase width height],...
		  'DrawMode','fast',...
		  'NextPlot','replacechildren',...
		  'Box','on',...
		  'XTick',[],...
		  'YTick',[]);

ud2.loaded=0;

ud2.load=uicontrol('Parent',fig, ...
	'Callback','sws load',...
	'Position',[left swscontrols 0.1 ch], ...
	'String','load ...', ...
	'Style','pushbutton',...
	'UserData',ud.sws2axes);
	
uicontrol('Parent',fig, ...
	'Position',[left+0.11 swscontrols-0.01 0.08 th], ...
	'String','output:', ...
	'Style','text');
	
ud2.selectoutput=uicontrol('Parent',fig, ...
	'Callback','sws selectoutput', ...
	'Position',[left+0.2 swscontrols-0.01 0.14 ch], ...
	'String','sws|natural|silence', ...
	'Style','popupmenu', ...
	'Value',1,...
	'UserData',ud.sws2axes,...
	'Enable','off');

ud2.useam=uicontrol('Parent',fig, ...
	'Callback','sws useam',...
	'Position',[left+0.36 swscontrols 0.06 ch], ...
	'String','am', ...
	'Style','checkbox',...
	'UserData',ud.sws2axes,...
	'Enable','off');

ud2.amfreqbox=uicontrol('Parent',fig, ...
	'Callback','sws amfreqbox',...
	'Position',[left+0.43 swscontrols 0.07 ch+0.01], ...
	'String','', ...
	'Style','edit',...
	'UserData',ud.sws2axes,...
	'Enable','off');

    
uicontrol('Parent',fig, ...
	'Position',[left+0.51 swscontrols-0.01 0.03 th], ...
	'String','Hz', ...
	'Style','text');
	
ud2.setnat=uicontrol('Parent',fig, ...
	'Callback','sws setnat', ...
	'Position',[left+0.56 swscontrols 0.18 ch], ...
	'String','natural f & a|constant a|constant f', ...
	'Style','popupmenu', ...
	'Value',1,...
	'UserData',ud.sws2axes,...
	'Enable','off');

ud2.useleft=uicontrol('Parent',fig, ...
	'Callback','sws useleft',...
	'Position',[left+0.77 swscontrols 0.07 ch], ...
	'String','left', ...
	'Style','checkbox',...
	'UserData',ud.sws2axes,...
    'Value',1,...
	'Enable','off');
    
ud2.useright=uicontrol('Parent',fig, ...
	'Callback','sws useright',...
	'Position',[left+0.84 swscontrols 0.09 ch], ...
	'String','right', ...
	'Style','checkbox',...
	'UserData',ud.sws2axes,...
    'Value',1,...
	'Enable','off');
    
set(ud.sws2axes,'UserData',ud2);	

swsbase=0.05;  swscontrols=swsbase+height+0.01;

ud.mixaxes = axes('Parent',fig,...
          'Position',[left swsbase width height],...
		  'DrawMode','fast',...
		  'NextPlot','replacechildren',...
		  'Box','on',...
		  'XTick',[],...
		  'YTick',[]);


 
set(fig,'UserData',ud);
% figure(fig);


