


LPCIFILT Apply inverse filter to speech signal U=(S,AR,T,DC,FADE)
Inputs: S speech signal
AR(nf,p+1) array of ar coefficients; one row per frame
T column vector giving the index of the first sample in each frame
DC(nf) optional dc component will be subtracted from the signal
FADE AR coefficients will be linearly interpolated for FADE samples
either side of frame boundaries

0001 function u=lpcifilt(s,ar,t,dc,fade) 0002 %LPCIFILT Apply inverse filter to speech signal U=(S,AR,T,DC,FADE) 0003 % 0004 % Inputs: S speech signal 0005 % AR(nf,p+1) array of ar coefficients; one row per frame 0006 % T column vector giving the index of the first sample in each frame 0007 % DC(nf) optional dc component will be subtracted from the signal 0008 % FADE AR coefficients will be linearly interpolated for FADE samples 0009 % either side of frame boundaries 0010 % 0011 0012 % Example: estimate the 2nd derivative of glotttal flow from a speech signal sp with sample freq fs 0013 % 0014 % spp=filter([1 -exp(-2*pi*50/fs)],1,sp); % preemphasis zero is at 50 Hz 0015 % [lpar,lpe,lpk]=lpcauto(spp,lpcord,floor([0.01 0.02]*fs)); % 20ms frame with 10ms frame increment 0016 % overlap=k(1,2)-k(2,1)+1; % overlap between adjacent frames 0017 % u=lpcifilt(sp,ar,k(:,1)+floor(overlap/2),0,overlap/4); % do inverse filtering 0018 0019 % Copyright (C) Mike Brookes 1997 0020 % Version: $Id: lpcifilt.m 713 2011-10-16 14:45:43Z dmb $ 0021 % 0022 % VOICEBOX is a MATLAB toolbox for speech processing. 0023 % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 0024 % 0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0026 % This program is free software; you can redistribute it and/or modify 0027 % it under the terms of the GNU General Public License as published by 0028 % the Free Software Foundation; either version 2 of the License, or 0029 % (at your option) any later version. 0030 % 0031 % This program is distributed in the hope that it will be useful, 0032 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0033 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0034 % GNU General Public License for more details. 0035 % 0036 % You can obtain a copy of the GNU General Public License from 0037 % http://www.gnu.org/copyleft/gpl.html or by writing to 0038 % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 0039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0040 0041 [nf,p1]=size(ar); 0042 if nargin<4 | isempty(dc) 0043 dc=zeros(nf,1); 0044 elseif length(dc)==1 0045 dc=dc(ones(nf,1)); 0046 end 0047 if nf==1 0048 u=filter(ar,1,s-dc); 0049 else 0050 p=p1-1; 0051 ns=length(s); 0052 if nargin<5 | isempty(fade) 0053 fade=0; 0054 if nargin<3 | isempty(t) 0055 t=p1+(0:nf-1)*(ns-p)/nf; 0056 end 0057 end 0058 u=zeros(ns,1); 0059 if fade<1 0060 x0=(max(1,ceil(t(nf)-p)):ns)'; 0061 u(x0)=filter(ar(nf,:),1,s(x0)-dc(nf)); 0062 for i=nf-1:-1:2 0063 x0=(max(1,ceil(t(i)-p)):ceil(t(i+1)-1))'; 0064 u(x0)=filter(ar(i,:),1,s(x0)-dc(i)); 0065 end 0066 x0=(1:ceil(t(2)-1))'; 0067 u(x0)=filter(ar(1,:),1,s(x0)-dc(1)); 0068 0069 else 0070 tb=min(t(nf)+fade,(t(nf)+ns)/2); 0071 ta=max(t(nf)-fade,(t(nf-1)+t(nf))/2); 0072 t0=max(1,ceil(ta)-p); 0073 x0=(t0:ns)'; 0074 xb=x0-tb; 0075 u(x0)=filter(ar(nf,:),1,s(x0)-dc(nf)).*max((1+(xb-abs(xb))/(2*(tb-ta))),0); 0076 for i=nf-1:-1:2 0077 td=tb; 0078 tc=ta; 0079 tb=min(t(i)+fade,ta); 0080 ta=max(t(i)-fade,(t(i-1)+t(i))/2); 0081 t1=floor(td); 0082 t0=max(1,ceil(ta)-p); 0083 x0=(t0:t1)'; 0084 xb=x0-tb; 0085 xc=x0-tc; 0086 u(x0)=u(x0)+filter(ar(i,:),1,s(x0)-dc(i)).*max((1+(xb-abs(xb))/(2*(tb-ta))-(xc+abs(xc))/(2*(td-tc))),0); 0087 end 0088 t1=floor(tb); 0089 x0=(1:t1)'; 0090 xc=x0-ta; 0091 u(x0)=u(x0)+filter(ar(1,:),1,s(x0)-dc(1)).*(1-(xc+abs(xc))/(2*(tb-ta))); 0092 0093 end 0094 end 0095