www.pudn.com > audioProcessingtoolbox.rar > frame2acfOverSmdf.m


function [acfOverSmdf, acf, smdf]=frame2acfOverSmdf(frame, maxShift, method, plotOpt) 
% frame2acfOverSmdf: ACF/SMDF of a given frame (primarily for pitch tracking) 
%	Usage: out=frame2acfOverSmdf(frame, maxShift, method, plotOpt); 
%		maxShift: no. of shift operations, which is equal to the length of the output vector 
%		method: 1 for using the whole frame for shifting 
%			2 for using the whole frame for shifting, but normalize the sum by it's overlap area 
%			3 for using frame(1:frameSize-maxShift) for shifting 
%			4 for using frame(1:maxShift) for shifting 
%		plotOpt: 0 for no plot, 1 for plotting the frame and ACF output 
%		out: the returned ACF/SMDF vector 
% 
%	See also FRAME2ACF, FRAME2SMDF. 
 
%	Roger Jang 20020404, 20041013, 20060313 
 
if nargin<1, selfdemo; return; end 
if nargin<2, maxShift=floor(length(frame)/2); end 
if nargin<3, method=3; end 
if nargin<4, plotOpt=0; end 
 
acf =frame2acf (frame, maxShift, method); 
smdf=frame2smdf(frame, maxShift, method); 
acfOverSmdf=0*acf; 
acfOverSmdf(2:end)=acf(2:end)./smdf(2:end); 
 
if plotOpt 
	plotNum=4; 
	subplot(plotNum,1,1); 
	set(plot(frame, '.-'), 'tag', 'frame'); 
	axis tight; 
	title('Frame'); 
	subplot(plotNum,1,2); 
	plot(acf, '.-'); 
	axis tight; 
	title(sprintf('ACF vector (method = %d)', method)); 
	subplot(plotNum,1,3); 
	plot(smdf, '.-'); 
	axis tight; 
	title(sprintf('SMDF vector (method = %d)', method)); 
	subplot(plotNum,1,4); 
	plot(acfOverSmdf, '.-'); 
	axis tight 
	title(sprintf('ACF/SMDF vector (method = %d)', method)); 
end 
 
% ====== Self demo 
function selfdemo 
waveFile='soo.wav'; 
[y, fs, nbits]=wavReadInt(waveFile); 
framedY=buffer(y, 256, 0); 
frame=framedY(:, 290); 
plotOpt=1; 
feval(mfilename, frame, 128, 3, plotOpt);