% Construct an mfir from a standard types
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FUNCTION:    fromStandard
%
% DESCRIPTION: Construct an mfir from a standard types
%
% CALL:        f = fromStandard(f, pli)
%
% PARAMETER:   type:     String with filter type description
%              pli:       Parameter list object
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function f = fromStandard(f, pli)
  
  VERSION = '$Id: fromStandard.m,v 1.15 2011/08/15 11:42:53 hewitson Exp $';
  
  ii = mfir.getInfo('mfir', 'From Standard Type');
  % Set the method version string in the minfo object
  ii.setMversion([VERSION '-->' ii.mversion]);
  
  % Add default values
  pl = applyDefaults(ii.plists, pli);
  
  % Get parameters
  type = find(pl, 'type');
  
  % check and fill parameter list
  plo = mfir.parseFilterParams(pl);
  switch lower(type)
    case {'lowpass', 'low-pass', 'low pass'}
      f = mklowpass(f, plo);
    case {'highpass' 'high-pass', 'high pass'}
      f = mkhighpass(f, plo);
    case {'bandpass', 'band-pass', 'band pass'}
      f = mkbandpass(f, plo);
    case {'bandreject', 'band-reject', 'band reject'}
      f = mkbandreject(f, plo);
    otherwise
      error('### unknown standard filter type in mfir constructor.');
  end
  
  if isempty(pl.find('name'))
    pl.pset('name', type);
  end
  
  % Add history
  f.addHistory(ii, pl, [], []);
  
  % Set object properties
  f.setObjectProperties(pl);
  
end % function f = mfirFromStandardType(type, pli, version, algoname)
