% user interface for auditory (temporal) induction demos

fig=createmadfig('ti'); 
fig=createmadloadmenu(fig);

% PRESETS
presetmenu=uimenu('Parent',fig,'Label','Preset');
  uimenu('Parent',presetmenu,'Label','tone','Tag','loadmenu','Callback','ti preset');
  uimenu('Parent',presetmenu,'Label','siren','Tag','loadmenu','Callback','ti preset');
  uimenu('Parent',presetmenu,'Label','speech','Tag','loadmenu','Callback','ti preset');
  uimenu('Parent',presetmenu,'Label','broadbandnoise','Tag','loadmenu','Callback','ti preset');
  uimenu('Parent',presetmenu,'Label','narrowbandnoise','Tag','loadmenu','Callback','ti preset');
  uimenu('Parent',presetmenu,'Label','music','Tag','loadmenu','Callback','ti preset');
  %uimenu('Parent',presetmenu,'Label','CV','Tag','loadmenu','Callback','ti load');

  ud.presetmenu=presetmenu;

%savemenu=uimenu('Parent',fig,'Label','Save');
%    uimenu('Parent',savemenu, 'Callback','ti saveSignal','Label','&save signal ...');
  
% MASKER details

ud.cfmenu=uimenu('Parent',fig,'Label','noise CF');
for i=[100 500 1000 2000 4000]
  uimenu('Parent',ud.cfmenu,'Label',num2str(i),...
         'Callback','ti noisecfchanged','Tag','noisecf','Enable','off');
end

ud.cf=1000;
set(findobj('Tag','noisecf','Label','1000'),'Checked','on');

ud.bwmenu=uimenu('Parent',fig,'Label','noise bw');
for i=[100 500 1000 2000]
  uimenu('Parent',ud.bwmenu,'Label',num2str(i),...
         'Callback','ti noisebwchanged','Tag','noisebw','Enable','off');
end
uimenu('Parent',ud.bwmenu,'Label','full band',...
         'Callback','ti noisebwchanged','Tag','noisebw','Enable','off');
ud.fullband=1;
set(findobj('Tag','noisebw','Label','full band'),'Checked','on');

% multiple interrruptions

repeatsmenu=uimenu('Parent',fig,'Label','multiple?');
  uimenu('Parent',repeatsmenu,'Label','once',...
         'Callback','ti repeatschanged','Tag','repeats');
  uimenu('Parent',repeatsmenu,'Label','regular',...
         'Callback','ti repeatschanged','Tag','repeats','Checked','on');
  uimenu('Parent',repeatsmenu,'Label','random',...
         'Callback','ti repeatschanged','Tag','repeats');

ud.repeats='regular';

 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

% major row & column positions

left=0.1;
top=0.9;
bottom=0.1;
right=0.75;

% column positions
c1l=0.00;    c1w=0.5;
c3l=c1l+c1w; c3w=1.0-c3l;

% test & label axes

ud.testAxes = axes('Parent',fig,...
          'Position',[0.3 0.5 0.4 0.45],...
          'Tag','TestAxes',...
		  'DrawMode','fast',...
		  'NextPlot','replacechildren',...
		  'Box','on',...
          'XGrid','on',...
          'YGrid','on',...
		  'XLim',[1 500],...
		  'YLim',[-40 20]);
ud.cp=plot(0,0,'r+');
		  
ylabel('noise level re: signal mean (dB)');
xlabel('noise duration (ms)');

ud.spectAxes = ...
   axes('Parent',fig,...
        'Position',[0.1 0.05 0.8 0.35],...
        'Tag','spectAxes',...
        'DrawMode','fast',...
        'NextPlot','replacechildren',...
        'Box','on',...
		'XTick',[],...
		'YTick',[]);

xlabel('time');
ylabel('frequency')


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


