function a=lsf_to_a(f); % Syntax: a=lsf_to_a(f); % % Computes prediction coefficients from Line Spectral Frequencies (LSF) % f is the vector of P normalized frequencies (Fe=1), where P is the % order of the polynomial A(z)=[1 a1 a2 ... aP]. % Vector a has P+1 elements (contains a0=1). % Vectors f and a are COLUMN M=length(f); if (M/2)==floor(M/2), % M even - P and Q will have odd no. of roots, % in addition to f, P will have root at 0, % Q at 1/2. fq=f(1:2:M-1); fq=[-fq; 0.5; fq]; % Q will have the 1st freq from f fp=f(2:2:M); fp=[-fp; 0 ; fp]; % P will have the 2nd else % M odd - P and Q will have even no. of roots. % P will have additional roots at 0 and 1/2, % Q is taking more frequencies from f fq=f(1:2:M); fq=[-fq; fq]; % Q will have the 1st freq from f, no other fp=f(2:2:M-1); fp=[-fp; 0; fp; 0.5]; % P will have the 2nd, additional at 0 and 1/2 end fp=fp*2*pi; fq=fq*2*pi; % denormalize rp=exp(i*fp); rq=exp(i*fq); % roots %[rp rq] P=real(poly(rp))'; Q=real(poly(rq))'; % polynomials %[P Q] a=(P+Q)/2; a=a(1:M+1); % a must be shortened