

function [cepsmat] = cepstrogram(x,fftsize,fs,win,overlap)
%cepstral analysis of wav file fn


if nargin<2 || length(fftsize)==0
  fftsize=512;
end

if nargin<3 || length(fs)==0
  fs=8000;
end

if nargin<4 || length(win)==0
  win=hamming(1,fftsize);
end

if nargin<5 || length(overlap)==0
  overlap=64;
end

framejump=fftsize-overlap;
nframes=floor((length(x)-framejump)/framejump);
cepsmat=zeros(fftsize/2,nframes);
st=1;
for f=1:nframes
  en=st+512-1;
  this_x=x(st:en).*win;
  y=real(ifft(log(abs(fft(this_x)))));   
  y=y(1:256);
  cepsmat(:,f)=y';
  st=st+framejump;
end



if nargout<1
  cutpts=ceil(fftsize*.05)
  ax1=[1:nframes]*framejump;

  ax2=[1:fftsize/2]/fs * 1000;
  ax2=ax2(cutpts+1:end);
  surf(ax1,ax2,cepsmat(cutpts+1:end,:));view(2);shading('interp')
  axis([min(ax1),max(ax1),min(ax2),max(ax2)])
  ylabel('Quefrency (ms)')
  xlabel('Txime')
  clear cepsmat;
end



