Re: Unknown Code
- Posted by timmy <tim781 at PACBELL.NET> Feb 06, 2001
- 480 views
Thanks :) ..timmy euphoria_coder at HOTMAIL.COM wrote: > timmy wrote: > > >unsigned long ReadVarLen() > > Untested, but it *should* work. Variable length data is stored as 7 bits of > data, with the 8th bit set high if there is more data following. > > function ReadVarLen() > -- read variable length data from a midi file > > atom value > integer c > > -- clear accumulator > value = 0 > > -- read bytes from infile > while 1 do > -- read a byte > c = getc(infile) > -- add low 7 bits to accumulator > value += and_bits(c,#7F) > -- high 8th bit not set? > if not and_bits(c,#80) then > -- return accumulated value > return value > end if > -- right shift the 7 bits > c *= power(2,7) > end while > end function