
% polezero interface
% Martin, September 1998

fig=createmadfig('polezero'); 
fig=createmadloadmenu(fig);
% filemenu = uimenu('Parent',fig,'Label','File');
% uimenu('Parent',filemenu, 'Callback','polezero load','Label','signal ...');
% uimenu('Parent',filemenu, 'Callback','polezero load','Label','tone ...');
% uimenu('Parent',filemenu, 'Callback','polezero load','Label','noise ...');
% uimenu('Parent',filemenu, 'Callback','polezero load','Label','impulses ...');


presetsmenu = uimenu('Parent',fig, 'Label','&Presets');
uimenu('Parent',presetsmenu, 'Label','bEEt', 'Callback', 'polezero vowel');
uimenu('Parent',presetsmenu, 'Label','bIt', 'Callback', 'polezero vowel');
uimenu('Parent',presetsmenu, 'Label','bEt', 'Callback', 'polezero vowel');
uimenu('Parent',presetsmenu, 'Label','bAt', 'Callback', 'polezero vowel');
uimenu('Parent',presetsmenu, 'Label','bOOt', 'Callback', 'polezero vowel');
uimenu('Parent',presetsmenu, 'Label','bUt', 'Callback', 'polezero vowel');
uimenu('Parent',presetsmenu, 'Label','bERt', 'Callback', 'polezero vowel');
uimenu('Parent',presetsmenu, 'Label','bORt', 'Callback', 'polezero vowel');
uimenu('Parent',presetsmenu, 'Label','bARt', 'Callback', 'polezero vowel');

fig=createmadmenus(fig);
             
ud.signaldir=fullfile(matlabroot,'toolbox','MAD','data','sounds');

% major row & column positions

left=0.05;
top=0.95;
bottom=0.05;
right=0.99;


% pole-zero display

pzbottom=0.4;
pzright=0.6;
ud.pzAxes = ...
axes('Parent',fig,...
'Position',[-0.07 0.0 0.9 0.98],...
'Tag','pzAxes',...
'DrawMode','fast',...
'NextPlot','replacechildren',...
'Box','on',...
'XLim', [-1.3 1.3],...
'YLim', [-1.3 1.3]);

cax=ud.pzAxes;
% define a circle
th = 0:pi/50:2*pi;
xunit = cos(th);
yunit = sin(th);
rmax=1;
tc = get(cax,'xcolor');

% now really force points on x/y axes to lie on them exactly
inds = 1:(length(th)-1)/4:length(th);
xunit(inds(2:2:4)) = zeros(2,1);
yunit(inds(1:2:5)) = zeros(3,1);

patch('xdata',xunit*rmax,'ydata',yunit*rmax, ...
'edgecolor',tc,'facecolor',get(gca,'color'),...
'ButtonDownFcn','polezero unselectall');

line([-1.1 1.1],[0 0]);
line([0 0],[-1.1 1.1]);
axis(rmax*[-1 1 -1.15 1.15]);
axis image; 
axis off; 

rightcol=0.75;
btop=0.9;
bheight=0.05;
bspace=0.05;
bwidth=0.2;
ud.addpole=uicontrol('Parent',fig, ...
'Callback','polezero addpole',...
'Position',[rightcol btop bwidth bheight], ...
'String','add pole', ...
'Style','pushbutton');

btop=btop-bheight-bspace;
ud.addzero=uicontrol('Parent',fig, ...
'Callback','polezero addzero',...
'Position',[rightcol btop bwidth bheight], ...
'String','add zero', ...
'Style','pushbutton');

btop=btop-bheight-bspace;
ud.playorig=uicontrol('Parent',fig, ...
'Callback','polezero playOriginal',...
'Position',[rightcol btop bwidth bheight], ...
'String','play original', ...
'Style','pushbutton',...
'Enable','off');

btop=btop-bheight-bspace;
ud.playfilt=uicontrol('Parent',fig, ...
'Callback','polezero playFiltered',...
'Position',[rightcol btop bwidth bheight], ...
'String','play filtered', ...
'Style','pushbutton',...
'Enable','off');

btop=btop-bheight-bspace;

% magnitude and phase axis

ud.magAxes = ...
axes('Parent',fig,...
'Position',[0.72 0.05 0.26 0.25],...
'Tag','magAxes',...
'DrawMode','fast',...
'NextPlot','replacechildren',...
'Box','off');

set(gcf,'UserData',ud);
