www.pudn.com > LPCToolbox.rar > MEANRC.M
% rc = meanrc(filelist, ncoeffs [,framedur, defaultFs])
%
% MEANRC computes & displays the mean and s.d. reflection coefficients
% for a set of sound files. For each sound file, a 10ms analysis frame
% is chosen from the middle of the file, preemphasized & hamming-windowed.
% Its reflection (aka PARCOR) coefficients are computed for 1...ncoeffs.
%
% MEAN also plots the average and stdev of the RCs. If rc(i,n) is the
% i'th reflection coeff for sound n, then for each i, MEANRC averages over
% rc(i,[1...numsounds]) and computes their s.d. The plot shows the
% means and a single s.d. for each i.
%
% filelist: A list of filenames (can be a array of strings, or a cell
% array). If a single filename is given and it has an extension of
% .DAT or .TXT, it is taken to be a file containing the list of
% sound filenames (one on each line). Currently, .WAV, .AU,
% and .RAW files are supported.
%
% ncoeffs : number of coefficients to compute for each frame.
%
% framedur : duration of the analysis frame (in msec).
% Default is 20ms.
%
% defaultFs: The sampling rate to use for .RAW files (in Hz).
% Default is 10000.
%
% rc : Matrix of reflection coefficients. rc(:,n) are the
% coeffs for filelist{n}.
%
% Gautam Vallabha (vallabha@walt.ccs.fau.edu), NOV-15-2000
% Center for Complex Systems, Florida Atlantic University.
function rcout = meanrc(filelst, ncoeffs, framedur, defaultFs)
if nargin < 4, defaultFs = 10000; end % in msec
if nargin < 3, framedur = 20; end % in msec
rc = [];
Filelist = loadfilelist(filelst);
if length(Filelist)==0,
fprintf(1, 'No sound files!\n');
return;
end
% -------
for i=1:length(Filelist),
[sndfilename, datfilename, ext] = fixfilename(Filelist{i});
[sig,Fs,err,msg] = getsound(sndfilename, ext, defaultFs);
if err,
fprintf(1, 'Error: %s\n', msg);
else
% pick a frame from the middle of the utterance
framelen = floor(Fs * (framedur/1000));
framestart = floor(length(sig)/2 - framelen/2);
xprhm = preham( sig(framestart:framestart+framelen-1) );
[a,k]=parcor(xprhm,ncoeffs);
rc(:,end+1) = k(:);
end
end
% -------
if isempty(rc), return; end
if nargout > 0, rcout = rc; end
figure; xval=1:ncoeffs;
if size(rc,2)==1,
plot(xval, rc, '-x');
else
m=mean(rc.'); sd = std(rc.');
errorbar(1:ncoeffs,m,sd);
end
hold on; axis tight; ax=axis;
plot(ax(1:2), [ 0 0 ], 'r--');
plot(ax(1:2), [ 0.2 0.2], 'r:');
plot(ax(1:2), [-0.2 -0.2], 'r:');
xlabel('lag (m)');
ylabel('mean k_m');