waveFile='sunday.wav'; au=myAudioRead(waveFile); y=au.signal; fs=au.fs; index1=9000; frameSize=512; index2=index1+frameSize-1; frame=y(index1:index2); maxShift=length(frame); method=1; acf=frame2acf(frame, maxShift, method); acf2=acf; maxFreq=1000; n1=floor(fs/maxFreq+1); acf2(1:n1)=-inf; minFreq=40; n2=ceil(fs/minFreq+1); acf2(n2:end)=-inf; [maxValue, maxIndex]=max(acf2); fprintf('Pitch = %f Hz = %f semitone\n', fs/(maxIndex-1), freq2pitch(fs/(maxIndex-1))); subplot(2,1,1); plot(frame, '.-'); title('Input frame'); subplot(2,1,2); xVec=1:length(acf); plot(xVec, acf, '.-', xVec, acf2, 'm.-', maxIndex, maxValue, 'ksquare'); axisLimit=axis; line(n1*[1 1]+0.5, axisLimit(3:4), 'color', 'r'); line(n2*[1 1]-0.5, axisLimit(3:4), 'color', 'r'); title(sprintf('ACF vector (method = %d)', method)); legend('Original ACF', 'Truncated ACF', 'ACF pitch point');