clear
n=1152;
ff= 941/8000;
sigsoll=5000*cos(n*ff*2*%pi*(0:n-1)/n);
n=length(sigsoll);
plot(abs(fft(sigsoll)),'.-')

nn=512;
d=2;
wind=window('kr',nn,16);

sp1=fft(sigsoll(1   : nn).*wind);
sp2=fft(sigsoll(1+d:nn+d).*wind);


[m,ind] = max(abs(sp1(1:length(sp1)/2)));


dw=atan(imag(sp2(ind)/sp1(ind)), real(sp2(ind)/sp1(ind)));


fg=(dw/d/(2*%pi));

sp=fft(cos(2*nn*fg*%pi*(0:nn-1)/nn).*wind);

ph=atan(imag(sp1(ind)/sp(ind)), real(sp1(ind)/sp(ind)));