function [alphap, alphaq] = levinson_anti(cor); % Syntax: [alphap, alphaq] = levinson_anti(cor); % % calculates the alphap and alphaq coefficients of Split Levinson Algortihm % from speech autocorrelation coefficients. Called by lsf_saoudi. % % Function based on article Saoudi, Boucher, Guyader: % "A new efficient algorithm to compute the LSP parameters for speech coding" % Signal Processing, no. 28, 1992, pp. 201-212. % % cor is the vector of correlation coefficients c0...cP, where P is the % order of the prediction filter % alphap is vector of reccurence coefficients of the symetric polynomial, % size P+1, value of alpha(1) without importance (alpha0 does not exist) % alphaq is vector of reccurence coefficients of the antisymetric polynomial, % size P+1, value of alpha(1) without importance (alpha0 does not exist) % - all vectors are COLUMN % - The function works only for P even % % The algorithm uses only one form of split lev. algorithm (antisym) to % compute both the alphaq and alphaq. % % The implementation in Matlab is not "vectorized", so it may be very slow P=length(cor)-1; if(P/2 ~= floor(P/2) ) error ('P is not even'); end %%%% init %%% alphap=zeros(P+1,1); alphaq=zeros(P+1,1); % 1st element for nothing taup=zeros(P+1,1); lambda=zeros(P+1,1); p=zeros(P+1, P/2); p(1,1)=0; p(2,2)=-1; for i=1:P, p(i+1, 1)=1; end taup(1)=cor(1); lambda(1)=1; %%%% cycle %%% for i=1:P, t=floor(i/2); l=2*t; % so for i even, i=l taup(i+1)=0; if (i==l), % for i even for j=0:t-1, taup(i+1)=taup(i+1) + ( cor(j+1) - cor(i-j+1) ) * p(i+1,j+1); end else for j=0:t, taup(i+1)=taup(i+1) + ( cor(j+1) - cor(i-j+1) ) * p(i+1,j+1); end end % de if alphaq(i+1)=taup(i+1) / taup(i); lambda(i+1)=2-alphaq(i+1) / lambda(i); alphap(i+1)=lambda(i+1) * (2-lambda(i)); for j=1:t, p(i+2,j+1)=p(i+1,j+1) + p(i+1,j) - alphaq(i+1) * p(i,j); % reccurence end % formula p(i+2,t+2) = 0; end % de for i