www.gusucode.com > 声音的处理有:LPC,FFT,共振峰,频谱源码程序 > siganlandsystemusingMatlab/SSUM/sws/lpcsynth.m

    function d = lpcsynth(a,g,e,h)
% d = lpcsynth(a,g,e,h)   Resynthesize from LPC representation
%    Each row of a is an LPC fit to a h-point (non-overlapping) 
%    frame of data.  g gives the overall gains for each frame and 
%    e is an excitation signal (if e is empty, white noise is used; 
%    if e is a scalar, a pulse train is used with that period).
%    Return d as the resulting LPC resynthesis.
% 2001-02-25 dpwe@ee.columbia.edu

if nargin < 3
  e = [];
end
if nargin < 4
  h = 128;
end

[nhops,p] = size(a);

npts = nhops*h;

if length(e) == 0
  e = randn(1,npts);
elseif length(e) == 1
  pd = e;
  e = sqrt(pd) * (rem(1:npts,pd) == 0);
else
	if (length(e) < npts)
		ptsdif = npts - length(e);
		while (ptsdif > 0)
			e = repmat(e,2,1);
			ptsdif = npts - length(e);
		end
	end
end

d = 0*e;

for hop = 1:nhops
  hbase = (hop-1)*h;
  aa = a(hop,:);
  G = g(hop);
  newbit = G*filter(1, aa, e(hbase + [1:h]));
  d(hbase + [1:h]) = newbit;
end

% De-emphasis (must match pre-emphasis in lpcfit)
pre = [1 -0.9];
d = filter(1,pre,d);