Re: Unknown Code

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu