private void readFrom(FileInputStream fis) throws Exception
    {
        int flen = fis.read();
        int flags = flen&0xF;
        int length = flen>>4;
        System.out.format("Sample: %02X Length %X flags %X\n", flen, length, flags);

        if (flags != 0xA || length < 2 || length > 4)
        {
            //throw new Exception("malformed sample: missing flags");

        
            int maxlen = 4;
            int hdrlen = 6;


            FileChannel fc = fis.getChannel();
            int skip = 0;
            do {
                long pos = fc.position();
                byte buf[] = new byte[maxlen + hdrlen + 1];
                fis.read(buf);

                fc.position(pos + 1);

                flen = ((int)buf[0])&0xFF;
                flags = flen&0xF;
                length = flen>>4;

                if (flags == 0xA && length<=4 && (buf[hdrlen + length]&0xF)==0xA)
                {
                    System.out.format("\rResync input: skipped %d bytes\n", skip);
                    break;
                }
                ++skip;
                System.out.format("[skip %d]\r", skip);
            } while (fis.available() > 0);
        }

        this.p  = fis.read();

        byte tsbytes[] = new byte[4];
        int r = fis.read(tsbytes);
        if (r != 4)
        {
            throw new Exception ("Incomplete timestamp");
        }        
        this.time = new SampleTime(tsbytes);

//        System.out.format(" Param %02X time %s ", this.p, this.time.toString());


        byte sdata[] = new byte[length];
        r = fis.read(sdata);
        if (r != length)
        {
            System.out.format("!!!! length error: %d %d\n", r, length);            
            throw new Exception ("sample data missing");
        }
        this.raw = sdata;
        //convertFromRaw();            
    }