function specsmode = determine_specsmode(frame,method,filterOrder,window)
%DETERMINE_SPECSMODE   Determine the correct freg and mag specs mode
%                      depending on the method and whether we are
%                      using minimum order or not.

%   Author(s): R. Losada
%   Copyright 1988-2000 The MathWorks, Inc.
%   $Revision: 1.3 $  $Date: 2000/06/13 21:23:02 $ 

switch lower(method),
case {'remez','firls','cremez','fircls'},
    freq_specs_mode = 'passStop';
    mag_specs_mode  = 'passStop';
    
case {'gremez'},
    freq_specs_mode = 'passStop';
    mag_specs_mode  = 'passStop';
    
case {'iirlpnorm','iirlpnormc'},
    freq_specs_mode = 'passStop';
    mag_specs_mode  = 'passStop';
    
case {'fir2','yulewalk'},
    freq_specs_mode = 'passStop';
    mag_specs_mode  = '';
    
case {'maxflat'},
    freq_specs_mode = 'cutoff';
    mag_specs_mode  = 'butter';
   
case {'butter'},
    switch filterOrder,
    case 'minimum order',
        freq_specs_mode = 'passStop';
        mag_specs_mode  = 'passStop';
    otherwise,
        freq_specs_mode = 'cutoff';
        mag_specs_mode  = 'butter';
    end
    
case {'ellip'},
    switch filterOrder,
    case 'minimum order',
        freq_specs_mode = 'passStop';
        mag_specs_mode  = 'passStop';
    otherwise,
        freq_specs_mode = 'pass';
        mag_specs_mode  = 'ellip';
    end
    
case {'fir1'},
    % Setup cell array of windows with minimum order option
    minordwins = {'kaiser','chebwin'};
    if strcmpi(filterOrder,'minimum order') & any(strcmpi(window,minordwins)),
        freq_specs_mode = 'passStop';
        mag_specs_mode  = 'passStop';
    else,
        freq_specs_mode = 'cutoff';
        mag_specs_mode  = 'fircutoff';
    end
               
case {'cheb1'},
    switch filterOrder,
    case 'minimum order',
        freq_specs_mode = 'passStop';
        mag_specs_mode  = 'passStop';
    otherwise,
        freq_specs_mode = 'pass';
        mag_specs_mode  = 'cheby1';
    end
    
case {'cheb2'},
    switch filterOrder,
    case 'minimum order',
        freq_specs_mode = 'passStop';
        mag_specs_mode  = 'passStop';
    otherwise,
        freq_specs_mode = 'stop';
        mag_specs_mode  = 'cheby2';
    end
end

% Assign output given the input frame
switch frame,
case 'freq',
    specsmode = freq_specs_mode;
case 'mag',
    specsmode  = mag_specs_mode;
case 'freqmag',
    % We simply use the method for this case
    specsmode = lower(method); 
end


