waveFile='soo.wav'; au=myAudioRead(waveFile); y=au.signal; fs=au.fs; y=y-mean(y); frameDuration=32; % Duration (in ms) of a frame frameSize=round(frameDuration*fs/1000); overlap=0; maxShift=frameSize; maxFreq=1000; minFreq=40; n1=round(fs/maxFreq); % pdf(1:n1) will not be used n2=round(fs/minFreq); % pdf(n2:end) will not be used frameMat=enframe(y, frameSize, overlap); frameNum=size(frameMat, 2); volume=frame2volume(frameMat); volumeTh=max(volume)/10; pitch=0*volume; for i=1:frameNum % fprintf('%d/%d\n', i, frameNum); frame=frameMat(:, i); pdf=frame2acf(frame, maxShift, 1); pdf(1:n1)=-inf; pdf(n2:end)=-inf; [maxValue, maxIndex]=max(pdf); freq=fs/(maxIndex-1); pitch(i)=freq2pitch(freq); end frameTime=frame2sampleIndex(1:frameNum, frameSize, overlap)/fs; subplot(3,1,1); plot((1:length(y))/fs, y); set(gca, 'xlim', [-inf inf]); title('Waveform'); subplot(3,1,2); plot(frameTime, volume, '.-'); set(gca, 'xlim', [-inf inf]); line([0, length(y)/fs], volumeTh*[1, 1], 'color', 'r'); title('Volume'); subplot(3,1,3); pitch2=pitch; pitch2(volume