midi-vlq

Crates.iomidi-vlq
lib.rsmidi-vlq
version0.1.0
sourcesrc
created_at2022-01-22 17:00:42.690286
updated_at2022-01-22 17:00:42.690286
descriptionVariable-Length Quantity for the MIDI file format
homepage
repositoryhttps://github.com/m-rinaldi/midi-vlq
max_upload_size
id519228
size13,996
J. Rinaldi (m-rinaldi)

documentation

README

midi-vlq

The Variable-Length Quantities (VLQs) as defined by the Standard MIDI file format.

License: MIT Build Status Unsafety


From the Standard MIDI-File Format Spec. 1.1:

Some numbers in MIDI Files are represented in a form called a variable-length quantity. These numbers are represented 7 bits per byte, most significant bits first. All bytes except the last have bit 7 set, and the last byte has bit 7 clear. If the number is between 0 and 127, it is thus represented exactly as one byte.

Example

use midi_vlq::MidiVlq;

// encode 127 as VLQ
let vlq = MidiVlq::from(127u8);
// 127 is encoded with a single byte
assert_eq!(vlq, [127]);

// encode 128 as VLQ
let vlq = MidiVlq::from(128u8);
// 128 needs two bytes
assert_eq!(vlq, [0x81, 0x00]);
Commit count: 12

cargo fmt