www.pudn.com > CELP.ZIP > postfilt.m


function [ s, powerin, powerout, dp1, dp2, dp3 ] = ... 
         postfilt( s, l, alpha, beta, powerin, powerout, dp1, dp2, ... 
                   dp3, lpc_coef, no ) 
 
global TC ipZ opZ 
 
ast = zeros( 1, 2 );      % Initialize local filter memory 
 
% Estimate input power 
[ newpowerin, ipZ ] = filter( [TC 0], [1 -1+TC], ( s .* s ), ipZ ); 
powerin = newpowerin(l); 
 
pcexp1 = wcoff( beta, lpc_coef );               % Do bandwinth expansion on predictor poles 
pcexp2 = wcoff( alpha, lpc_coef ); 
 
 
[ s, dp1 ] = FIRfilter( pcexp1, dp1, s );        % Apply pole-zero postfilter 
[ s, dp2 ] = lpcr( pcexp2, dp2, s ); 
 
 
rcexp2 = poly2rc( pcexp2 );                      % Convert LPC to RC (MATLAB high level command) 
rcexp2 = -rcexp2'; 
 
 
% Add tilt compensation 
ast(1) = 1.0; 
if rcexp2(1) > 0.0 
    ast(2) = -0.5 * rcexp2(1); 
else 
    ast(2) = 0.00; 
end 
[ s, dp3 ] = FIRfilter( ast, dp3, s, 1); 
 
% Estimate output power 
[ newpowerout, opZ ] = filter( [TC 0], [1 -1+TC], ( s .* s ), opZ ); 
powerout = newpowerout(l); 
 
% Incorporate automatic gain control 
agcUnity = find( newpowerout <= 0 ); 
newpowerout( agcUnity ) = ones( length( agcUnity ), 1 ); 
agcScale = sqrt( newpowerin ./ newpowerout ); 
agcScale( agcUnity ) = ones( length( agcUnity ), 1 ); 
s = s .* agcScale;