function [L,R]=pitchcor(x,lmin,lmax,thr) % % Syntax: [L,R]=pitchcor(x,lmin,lmax,thr) % % Computes pitch using autocorrelation method. % x is the signal frame % lmin is minimal lag in samples % lmax is maximal lag in samples % thr is a relative threshold Rmax/R0 >= thr => voiced % Rmax/R0 < thr => unvoiced % L is lag in samples for voiced, 0 for unvoiced frame % R (facultative) is the vector of autocorrelation coefficients N=length(x); aaa=xcorr(x); R=aaa(N:(2*N-1)); [Rmax,ii]=max(R(lmin+1:lmax+1)); if Rmax/R(1) >= thr, L=ii+lmin-1; else L=0; end