function [ sam, dyd]=readadf( samfile)
% 
% read sample file
%

fid=fopen( samfile, 'r', 'ieee-le');
line=fgetl( fid);
line=fgetl( fid); % disp(line);
while strcmp( line, '*DATA*') == 0
  line=fgetl( fid); % disp(line);
  off=findstr( line, 'start_time');
  if off
    yr=str2num(line(off+14:off+15));
    yd=str2num(line(off+17:off+19));
    hr=str2num(line(off+21:off+22));
    mn=str2num(line(off+24:off+25));
    sc=str2num(line(off+27:off+28));
  end
end

start=ftell(fid); fseek(fid,0,'eof'); stop=ftell(fid);
fseek(fid,start,'bof'); sizs=(stop-start)/2;

%samr=fread( fid, sizs/2, 'double');
%sami=fread( fid, sizs/2, 'double');
%sam=samr+sqrt(-1)*sami; sam=sam(:);

sam=fread( fid, sizs, 'short'); sam=sam(:);

fclose( fid);

dyd=yd+hr/24+mn/60/24+sc/60/60/24;

return

