
% FINDPITCH takes in a signal(vector) and computes the mean pitch for that signal
% using the cepstrum.
%
%  [meanpitchfreq, Tp] =  It retuns the mean pitch frequency and the pitch period.


function [meanpitchfreq,Tp] = findpitch(signal)

framed = enframe(signal,1024,512);

n=1;
for k=1:size(framed,1)
	cc = abs(rceps(framed(k,:)));
	if (max(cc(52:200)) > 0.1)
	  [x,Tp(n)] = max(cc(52:200));
    n = n + 1;
  end
end

meanpitchfreq = 16000/mean(Tp+52);
