# how to understand Linear prediction coefficient code.

2 views (last 30 days)
john karli on 22 Dec 2018
Edited: John D'Errico on 22 Dec 2018
I have given this code but i'm not really understand each line of code. .
function [ar,xi,e,m] = lpcauto(x,M,win,Olap)
% lpcauto --> Linear Predictor Coefficients.
% Check the required input arguments.
if (nargin < 4)
error('Not enough input arguments.')
end
% Number of data points.
Nx = length(x);
% Frame length is given by the window length.
N = length(win);
if (N == 1)
N = win; % If win is a scalar, then use
win = ones(N,1); % a rectangular window of this length.
end
if (Nx < N)
error('The window length cannot be larger than the signal length.')
elseif (N <= Olap)
error('The overlap must be smaller than the window length.')
end
% Number of frames.
F = fix((Nx-Olap)/(N-Olap));
% Initialize output arguments.
ar = zeros(M+1,F);
xi = zeros(M+1,F);
e = zeros(Nx,1);
m = zeros(F,1);
% Time index vectors.
n = 1:N; % Index of current speech frame.
n1 = 1:Olap; % Overlap in start of frame.
n2 = N-Olap+1:N; % Overlap in end of frame.
n3 = Olap+1:N; % From overlap in start to end of frame.
% Overlap-add weights in start and end of frame, respectively.
win1 = win(n1)./(win(n1)+win(n2)+eps);
win2 = win(n2)./(win(n1)+win(n2)+eps);
for (f=1:F)
% Short-term autocorrelation.
[r,eta] = xcorr(x(n).*win,M,'biased');
% LP analysis based on Levinson-Durbin recursion.
[a,xi(:,f),kappa] = durbin(r(M+1:2*M+1),M);
ar(:,f) = [1; -a];
% Prediction error signal obtained by inverse filtering.
ehat = filter(ar(:,f),1,x(n));
e(n) = [e(n(n1)).*win2 + ehat(n1).*win1; ehat(n3)]; % Overlap-add.
m(f) = n(N); % Time index of last point in frame.
n = n + (N-Olap); % Shift time index to next speech frame.
end
%-----------------------------------------------------------------------
% End of function lpcauto
John D'Errico on 22 Dec 2018
Edited: John D'Errico on 22 Dec 2018
Sorry, but this would be a large project, for someone to write a detailed explanation of every line in a long code, especially when moderately detailed comments are already provided, and to do that for someone who apparently has not even aclue about MATLAB. Do some work yourself. (Learn MATLAB, and learn about the field you are working in. We cannot teach you acomplete course in the comments. Sorry, but that is not the purpose of Answers.) If you have SPECIFIC questions about a SPECIFIC line or two, then ask. Otherwise, this becomes too large a task to ask of someone.