Home > voicebox > lpcar2am.m

lpcar2am

PURPOSE ^

LPCAR2AM Convert ar coefs to ar coef matrix [AM,EM]=(AR,P)

SYNOPSIS ^

function [am,em]=lpcar2am(ar,p);

DESCRIPTION ^

LPCAR2AM Convert ar coefs to ar coef matrix [AM,EM]=(AR,P)
AM is a 3-dimensional matrix of size (p+1,p+1,nf) where p is the lpc order
and nf the number of frames.
The matrix AM(:,:,*) is upper triangular with 1's on the main diagonal
and contains the lpc coefficients for all orders from p down to 0.

For lpc order p+1-r, AM(r,r:p+1,*), AM(p+1:-1:r,p+1,*) and EM(*,r) contain
the lpc coefficients, reflection coefficients and the residual energy respectively.
EM(:,1) is always 1.

If A=am(:,:,*), R=toeplitz(rr(*,:)) and E=diag(em(*,:)), then
 A*R*A'=E; inv(R)=A'*(1/E)*A; A*R is lower triangular with the same diagonal as E

 For each j in 1:P we have AM(j:end:-1:j+1,*) = AM(j:end-1,end,*)'*am(j+1:end,j+1:end,*)

 Also em(*,1:end)' = em(*,2:end)'.*(1-am(1:end-1,end,*).^2)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [am,em]=lpcar2am(ar,p);
0002 %LPCAR2AM Convert ar coefs to ar coef matrix [AM,EM]=(AR,P)
0003 %AM is a 3-dimensional matrix of size (p+1,p+1,nf) where p is the lpc order
0004 %and nf the number of frames.
0005 %The matrix AM(:,:,*) is upper triangular with 1's on the main diagonal
0006 %and contains the lpc coefficients for all orders from p down to 0.
0007 %
0008 %For lpc order p+1-r, AM(r,r:p+1,*), AM(p+1:-1:r,p+1,*) and EM(*,r) contain
0009 %the lpc coefficients, reflection coefficients and the residual energy respectively.
0010 %EM(:,1) is always 1.
0011 %
0012 %If A=am(:,:,*), R=toeplitz(rr(*,:)) and E=diag(em(*,:)), then
0013 % A*R*A'=E; inv(R)=A'*(1/E)*A; A*R is lower triangular with the same diagonal as E
0014 %
0015 % For each j in 1:P we have AM(j:end:-1:j+1,*) = AM(j:end-1,end,*)'*am(j+1:end,j+1:end,*)
0016 %
0017 % Also em(*,1:end)' = em(*,2:end)'.*(1-am(1:end-1,end,*).^2)
0018 
0019 % we should be able to do this more directly using the step down algorithm
0020 
0021 %      Copyright (C) Mike Brookes 1997
0022 %      Version: $Id: lpcar2am.m 713 2011-10-16 14:45:43Z dmb $
0023 %
0024 %   VOICEBOX is a MATLAB toolbox for speech processing.
0025 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
0026 %
0027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0028 %   This program is free software; you can redistribute it and/or modify
0029 %   it under the terms of the GNU General Public License as published by
0030 %   the Free Software Foundation; either version 2 of the License, or
0031 %   (at your option) any later version.
0032 %
0033 %   This program is distributed in the hope that it will be useful,
0034 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0035 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0036 %   GNU General Public License for more details.
0037 %
0038 %   You can obtain a copy of the GNU General Public License from
0039 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0040 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0041 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0042 
0043 [nf,p1] = size(ar);
0044 if any(ar(:,1)~=1)
0045   ar=ar./ar(:,ones(1,p1));
0046 end
0047 p0=p1-1;
0048 if nargin < 2
0049    p=p0;
0050 end
0051 am=zeros(nf,p+1,p+1);
0052 em=ones(nf,p+1);
0053 e=ones(nf,1);
0054 rf=ar;
0055 if p>=p0
0056    for jj=1:p+1-p0
0057       am(:,jj:jj+p0,jj)=ar;
0058    end
0059 else
0060    for j=p0:-1:p+2
0061       k = rf(:,j+1);
0062       d = (1-k.^2).^(-1);
0063       e = e.*d;
0064       wj=ones(1,j-1);
0065       rf(:,2:j) = (rf(:,2:j)-k(:,wj).*rf(:,j:-1:2)).*d(:,wj);
0066    end
0067    jj=0;
0068 end
0069 for jj=jj+1:p  
0070    j = p+2-jj;
0071    k = rf(:,j+1);
0072    d = (1-k.^2).^(-1);
0073    e = e.*d;
0074    wj=ones(1,j-1);
0075    rf(:,2:j) = (rf(:,2:j)-k(:,wj).*rf(:,j:-1:2)).*d(:,wj);
0076    am(:,jj:end,jj)=rf(:,1:j);
0077    em(:,jj)=e;
0078 end
0079 em(:,end)=e./(1-rf(:,2).^2);
0080 am(:,end,end)=1;
0081 am=permute(am,[3 2 1]);
0082

Generated on Tue 10-Oct-2017 08:30:10 by m2html © 2003