function [heading, enc, timestamp, error]=omnibikego(filename) 

    blocksize=1000000;
    baudperiod=5;

    wavsize=wavread(filename,'size');
    
    heading=[];
    enc=[];
    timestamp=[];
    error=[];
    
    fprintf('size is %i\n',wavsize(1));

    h = fir1(20,9600/24000);

    
    for (startpos=1:blocksize:wavsize(1)-blocksize)
       fprintf('offset %i\n',startpos);
       
       y=loadaudio(filename,startpos, blocksize);
       y = filtfilt(h,1,y);
       y = y>0;
       
       [v,vts]=serialdecode(y, baudperiod);
       
       [thisheading, thisenc, thists, thiserror]=omnibikeserialdecode(v,vts);
       
       thists=thists+(startpos-1);
       heading=[heading thisheading];
       enc=[enc thisenc];
       timestamp=[timestamp thists];
       error=[error thiserror];
       
       subplot(3,1,1);
       plot(heading);
       subplot(3,1,2);
       plot(enc);
       subplot(3,1,3);
       plot(timestamp);

       drawnow;
    end
    
    
    % unwrap and catch errors in the enc
    denc = diff(enc([1 1:end]));
    g = find(denc<0);
    denc(g) = denc(g) + 256;
    enc = cumsum(denc);
    
    menc = medfilt1(enc,7);
    b = find(abs(menc-enc)>2);
    nz = denc~=0;
    nz(b) = 0;
    
    b = find(isnan(timestamp));
    if (~isempty(b))
        timestamp(b) = .5*(timestamp(b-1)+timestamp(b+1));
    end 

    enc(~nz) = interp1(timestamp(nz),enc(nz),timestamp(~nz),'linear','extrap');
    enc(find(isnan(enc)))=0;
    b = find(diff(enc)<0);
    if ~isempty(b), enc(b:end) = enc(b); end