function L = remLPord(freq1, freq2, delta1, delta2 )
%REMLPORD FIR lowpass filter Length estimator
%
%	L = remLPord(freq1, freq2, dev1, dev2)
%
%	input:
%	  freq1: passband cutoff freq (NORMALIZED)
%	  freq2: stopband cutoff freq (NORMALIZED)
%	  dev1:  passband ripple (DESIRED)
%	  dev2:  stopband attenuation (not in dB)
%
%	output:
%	  L = filter Length (# of samples)
%         NOT the order N, which is N = L-1
%
%	NOTE: Will also work for highpass filters (i.e., f1 > f2)
% 	      Will not work well if transition zone is near f = 0, or
%	      near f = fs/2

%
% 	Author(s): J. H. McClellan, 10-28-91
%	Copyright (c) 1984-94 by The MathWorks, Inc.
%       $Revision: 1.4 $  $Date: 1994/01/25 17:59:46 $
	
%	References:
%	  [1] Rabiner & Gold, Theory and Appications of DSP, pp. 156-7.     

AA = [-4.278e-01  -4.761e-01  0;
      -5.941e-01   7.114e-02  0;
      -2.660e-03   5.309e-03  0 ];
d1 = log10(delta1);
d2 = log10(delta2);
D = [1 d1 d1*d1] * AA * [1; d2; d2*d2];
%
bb = [11.01217; 0.51244];
fK =  [1.0  (d1-d2)] * bb;
%
df = abs(freq2 - freq1);
%
L = D/df - fK*df + 1;
