% function which computes the lpc
% parameters
%
function gain = find_lpc(lp_order, rn)

% initialize the error_lp
%
error_lp(1) = rn(1);

% the Levinson Durbin recursion
%
for i=2:lp_order
% compute the reflection coefficients
%
refl_coeff(i) = 0;
for j=1:i-1
   refl_coeff(i) = refl_coeff(i) - error_lp(j) * rn(i-j);
end;

refl_coeff(i) = refl_coeff(i) + rn(i);
refl_coeff(i) = refl_coeff(i) / error_lp(i);

% predictor coefficients
%
lp_coeff(i) = refl_coeff(i);
for j=1:i-1,
   lp_coeff(j) = lp_coeff(j) - (refl_coeff(i) * error_lp(i-j));
end;

% update the LP error_lp
%
error_lp(i) = error_lp(i)*(1 - refl_coeff(i) * refl_coeff(i));

% update the predictor coefficients
%
for j=1:i,
   temp(j) = lp_coeff(j);
end;

% return the computed gain value
%
gain = (10 * log10(error_lp(lp_order)));
	
end;



	


