wolffd@0: function synWave = synlpc(aCoeff,source,sr,G,fr,fs,preemp) wolffd@0: % USAGE: synWave = synlpc(aCoeff,source,sr,G,fr,fs,preemp); wolffd@0: % wolffd@0: % This function synthesizes a (speech) signal based on a LPC (linear- wolffd@0: % predictive coding) model of the signal. The LPC coefficients are a wolffd@0: % short-time measure of the speech signal which describe the signal as the wolffd@0: % output of an all-pole filter. This all-pole filter provides a good wolffd@0: % description of the speech articulators; thus LPC analysis is often used in wolffd@0: % speech recognition and speech coding systems. The LPC analysis is done wolffd@0: % using the proclpc routine. This routine can be used to verify that the wolffd@0: % LPC analysis produces the correct answer, or as a synthesis stage after wolffd@0: % first modifying the LPC model. wolffd@0: % wolffd@0: % The results of LPC analysis are a new representation of the signal wolffd@0: % s(n) = G e(n) - sum from 1 to L a(i)s(n-i) wolffd@0: % where s(n) is the original data. a(i) and e(n) are the outputs of the LPC wolffd@0: % analysis with a(i) representing the LPC model. The e(n) term represents wolffd@0: % either the speech source's excitation, or the residual: the details of the wolffd@0: % signal that are not captured by the LPC coefficients. The G factor is a wolffd@0: % gain term. wolffd@0: % wolffd@0: % LPC synthesis produces a monaural sound vector (synWave) which is wolffd@0: % sampled at a sampling rate of "sr". The following parameters are mandatory wolffd@0: % aCoeff - The LPC analysis results, a(i). One column of L+1 numbers for each wolffd@0: % frame of data. The number of rows of aCoeff determines L. wolffd@0: % source - The LPC residual, e(n). One column of sr*fs samples representing wolffd@0: % the excitation or residual of the LPC filter. wolffd@0: % G - The LPC gain for each frame. wolffd@0: % wolffd@0: % The following parameters are optional and default to the indicated values. wolffd@0: % fr - Frame time increment, in ms. The LPC analysis is done starting every wolffd@0: % fr ms in time. Defaults to 20ms (50 LPC vectors a second) wolffd@0: % fs - Frame size in ms. The LPC analysis is done by windowing the speech wolffd@0: % data with a rectangular window that is fs ms long. Defaults to 30ms wolffd@0: % preemp - This variable is the epsilon in a digital one-zero filter which wolffd@0: % serves to preemphasize the speech signal and compensate for the 6dB wolffd@0: % per octave rolloff in the radiation function. Defaults to .9378. wolffd@0: % wolffd@0: % This code was graciously provided by: wolffd@0: % Delores Etter (University of Colorado, Boulder) and wolffd@0: % Professor Geoffrey Orsak (Southern Methodist University) wolffd@0: % It was first published in wolffd@0: % Orsak, G.C. et al. "Collaborative SP education using the Internet and wolffd@0: % MATLAB" IEEE SIGNAL PROCESSING MAGAZINE Nov. 1995. vol.12, no.6, pp. wolffd@0: % 23-32. wolffd@0: % Modified and debugging plots added by Kate Nguyen and Malcolm Slaney wolffd@0: wolffd@0: % (c) 1998 Interval Research Corporation wolffd@0: % A more complete set of routines for LPC analysis can be found at wolffd@0: % http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html wolffd@0: wolffd@0: wolffd@0: wolffd@0: if (nargin < 5), fr = 20; end; wolffd@0: if (nargin < 6), fs = 30; end; wolffd@0: if (nargin < 7), preemp = .9378; end; wolffd@0: wolffd@0: msfs = round(sr*fs/1000); wolffd@0: msfr = round(sr*fr/1000); wolffd@0: msoverlap = msfs - msfr; wolffd@0: ramp = [0:1/(msoverlap-1):1]'; wolffd@0: [L1 nframe] = size(aCoeff); % L1 = 1+number of LPC coeffs wolffd@0: wolffd@0: [row col] = size(source); wolffd@0: if(row==1 | col==1) % continous stream; must be wolffd@0: % windowed wolffd@0: postFilter = 0; duration = length(source); frameIndex = 1; wolffd@0: for sampleIndex=1:msfr:duration-msfs+1 wolffd@0: resid(:,frameIndex) = source(sampleIndex:(sampleIndex+msfs-1))'; wolffd@0: frameIndex = frameIndex+1; wolffd@0: end wolffd@0: else wolffd@0: postFilter = 1; resid = source; wolffd@0: end wolffd@0: wolffd@0: [row col] = size(resid); wolffd@0: %if ~(col==nframe) wolffd@0: % error('synLPC: numbers of LPC frames and source frames do not match'); wolffd@0: if col