V_LPCRR2AR convert reflection coefs to autocorrelation coefs [RR,AR]=(RF,P) Inputs: rf(:,n+1) reflection coefficients: one row per frame p specifies number of rr coefficients to calculate (default=n) Outputs: rr(:,p+1) autocorrelation coefficients ar(:,n+1) AR filter coefficients
0001 function [rr,ar]=v_lpcrf2rr(rf,p); 0002 %V_LPCRR2AR convert reflection coefs to autocorrelation coefs [RR,AR]=(RF,P) 0003 % 0004 % Inputs: rf(:,n+1) reflection coefficients: one row per frame 0005 % p specifies number of rr coefficients to calculate (default=n) 0006 % Outputs: rr(:,p+1) autocorrelation coefficients 0007 % ar(:,n+1) AR filter coefficients 0008 0009 % Copyright (C) Mike Brookes 1997 0010 % Version: $Id: v_lpcrf2rr.m 10865 2018-09-21 17:22:45Z dmb $ 0011 % 0012 % VOICEBOX is a MATLAB toolbox for speech processing. 0013 % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 0014 % 0015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0016 % This program is free software; you can redistribute it and/or modify 0017 % it under the terms of the GNU General Public License as published by 0018 % the Free Software Foundation; either version 2 of the License, or 0019 % (at your option) any later version. 0020 % 0021 % This program is distributed in the hope that it will be useful, 0022 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0023 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0024 % GNU General Public License for more details. 0025 % 0026 % You can obtain a copy of the GNU General Public License from 0027 % http://www.gnu.org/copyleft/gpl.html or by writing to 0028 % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 0029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0030 0031 [nf,p1]=size(rf); 0032 p0=p1-1; 0033 if p0 0034 a = rf(:,2); 0035 rr=[ones(nf,1) -a zeros(nf,p0-1)]; 0036 e = (a.^2-1); 0037 for n = 2:p0 0038 k=rf(:,n+1); 0039 rr(:,n+1) =k.*e - sum(rr(:,n:-1:2).*a,2); 0040 a = [a+k(:,ones(1,n-1)).*a(:,n-1:-1:1) k]; 0041 e = e.*(1-k.^2); 0042 end 0043 ar = [ones(nf,1) a]; 0044 r0=sum(rr.*ar,2).^(-1); 0045 rr=rr.*r0(:,ones(1,p1)); 0046 if nargin>1 && ~isempty(p) 0047 if p<p0 0048 rr(:,p+2:p1)=[]; 0049 else 0050 rr=[rr zeros(nf,p-p0)]; 0051 af=-ar(:,p1:-1:2); 0052 for i=p0+1:p 0053 rr(:,i+1)=sum(af.*rr(:,i-p0+1:i),2); 0054 end 0055 end 0056 end 0057 else 0058 rr=ones(nf,1); 0059 ar=rr; 0060 end 0061