Variable-length quantity

Variable-length quantity

A variable-length quantity (VLQ) is a universal code that uses an arbitrary number of binary octets (eight-bit bytes) to represent an infinitely large integer. It was defined for use in the standard MIDI file format [ [http://www.borg.com/~jglatt/tech/midifile/vari.htm MIDI File Format: Variable Quantities] ] to save additional space for a resource constrained system, and is also used in the later Extensible Music Format (XMF).It is also used in the WAP environment to represent unsigned integers of arbitrary length, where it is called variable length unsigned integer or uintvar.

General structure

The encoding assumes an octet where the most significant bit (MSB), also commonly known as the sign bit, is reserved to indicate whether another octet follows. If the MSB is 0, then this is the last octet of the integer, otherwise another binary octet follows.The octets within an integer are arranged most significant first.

Examples

Here we work an example with the number 137:

* Represent the value in binary notation (e.g. 137 as 10001001)
* Break it up in groups of 7 bits starting from the lowest significant bit (e.g. 137 as 0000001 0001001). This is equivalent to representing the number in base 128.
* Take the lowest 7 bits and that gives you the least significant byte (0000 1001). This byte comes last.
* For all the other groups of 7 bits (in the example, this is 000 0001), set the MSB to 1 (which gives 1000 0001 in our example). Thus 137 becomes 1000 0001 0000 1001 where the bits in boldface are something we added. These added bits denote if there is another byte to follow or not. Thus, by definition, the very last byte of a variable length integer will have 0 as its MSB.

The Standard MIDI File format specification gives more examples:Verify source|date=February 2008

References

External links

Official MIDI Standards Organizations

* [http://www.midi.org/ MIDI Manufacturers Association] (MMA) - Source for English-language MIDI specs
* [http://www.amei.or.jp/index_e.html Association of Musical Electronics Industry] (AMEI) -Source for Japanese-language MIDI specs


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • variable — adj. & n. adj. 1 a that can be varied or adapted (a rod of variable length; the pressure is variable). b (of a gear) designed to give varying speeds. 2 apt to vary; not constant; unsteady (a variable mood; variable fortunes). 3 Math. (of a… …   Useful english dictionary

  • Variable speed of light — The variable speed of light (VSL) concept states that the speed of light in a vacuum, usually denoted by c , may not be constant in some cases. In most situations in condensed matter physics when light is traveling through a medium, it… …   Wikipedia

  • Variable — A variable (pronEng|ˈvɛərɪəbl) is an attribute of a physical or an abstract system which may change its value while it is under observation. Examples include the height of a child, the temperature across a state, or the input to a function. This… …   Wikipedia

  • Variable (mathematics) — In mathematics, a variable is a value that may change within the scope of a given problem or set of operations. In contrast, a constant is a value that remains unchanged, though often unknown or undetermined.[1] The concepts of constants and… …   Wikipedia

  • variable — variability, variableness, n. variably, adv. /vair ee euh beuhl/, adj. 1. apt or liable to vary or change; changeable: variable weather; variable moods. 2. capable of being varied or changed; alterable: a variable time limit for completion of a… …   Universalium

  • Variable range hopping — IntroductionVariable range hopping or Mott variable range hopping, is a model describing low temperature conduction in strongly disordered systems with localized states. [Mott, N.F., Phil. Mag. ,19,835,1969] It has a characteristic temperature… …   Wikipedia

  • UTF-7 — (7 bit Unicode Transformation Format) is a variable length character encoding that was proposed for representing Unicode text using a stream of ASCII characters. It was originally intended to provide a means of encoding Unicode text for use in… …   Wikipedia

  • climate — /kluy mit/, n. 1. the composite or generally prevailing weather conditions of a region, as temperature, air pressure, humidity, precipitation, sunshine, cloudiness, and winds, throughout the year, averaged over a series of years. 2. a region or… …   Universalium

  • information theory — the mathematical theory concerned with the content, transmission, storage, and retrieval of information, usually in the form of messages or data, and esp. by means of computers. [1945 50] * * * ▪ mathematics Introduction       a mathematical… …   Universalium

  • Mathematics and Physical Sciences — ▪ 2003 Introduction Mathematics       Mathematics in 2002 was marked by two discoveries in number theory. The first may have practical implications; the second satisfied a 150 year old curiosity.       Computer scientist Manindra Agrawal of the… …   Universalium

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”