Welcome Guest (Log in)

Variable-Length Quantity

StarStarStarStarStar
Music (9) | Sound (6) | MIDI (4)
General
Expander triangle
  • Author
  • Rating
  • Type
  • Revision
  • Downloaded
  • Updated
  • capellan2000@gmail.com
  • StarStarStarStarStar
  • Stack
  • 1
  • 512 Times
  • 30 August 2018
Variable-length quantity in Midi files
Recently, while looking at the binary data of MIDI files, I found about Variable Length Quantity, a clever method for storing very large quantities using just a few hexadecimal numbers.

Using a single byte (1 ascii character = 1 hexadecimal number)
we could represent quantities from 0 to 127 (In hexadecimal 00 to 7F)
With two bytes, from 0 to 16383 (hexadecimal 0000 to FF7F)
Three bytes, from 0 to 2,097,151 (hexadecimal from 000000 to FFFF7F)
Four bytes, from 0 to 268,435,455 (hexadecimal from 00000000 to FFFFFF7F)

This stack is a simple interface for code posted by Paul McCleman in Rosetta Code:
https://rosettacode.org/wiki/Variable-length_quantity#LiveCode
Ajax Loader
Tags
Expander triangle
User Comments
Expander triangle
User thumbnail
Paul McClernan
StarStarStarStarStar
Sep 7, 2018
See/hear this VLQ code in action with a crazy DataGrid here: https://github.com/PaulMcClernan/LCB_macAVMidiPlayer/tree/master/samples