function x=ista(wave,fs,window,start,lagstep)
%X=ISTA(WAVE,FS,WINSIZE,START,LAGSTEP)    Instantaneous autocorrelation 
%  Autocorrelation of WAVE frame START:START+WINSIZE-1. 
%  Window specifies the windowing vector.
%  Lag range of 1:WINSIZE.
% 
%  Author: Stuart N Wrigley       
%  MAD - Matlab Auditory Demonstrations
%  (c) University of Sheffield 1998
%  Revision 0.01: 8 July 1998

error(nargchk(1,5,nargin));
%wave=normalise(wave);  we expect to receive a normalised signal!
winSize=length(window);

base=wave(start:start+winSize-1).*window;
% calculate the autocorrelation function with lag k
n=1;
for k=1:lagstep:winSize
   x(n)=(sum(base.*(wave(start+k:start+k+winSize-1).*window)));
   n=n+1;
end   
x=normalise(x);
