Documentation
¶
Overview ¶
VLQ (Variable Length Quantity) is an unsigned integer encoding scheme designed for the MIDI file format.
It encodes a value into a sequence of bytes where the lower 7 bits contain data and the high bit is used as a "continuation" bit. A decoder reads encoded bytes, filling a decoded unsigned integer 7 bits at a time in big endian order, until it encounters a byte with the high "continuation" bit cleared.
Index ¶
- Constants
- func Extend(buffer []byte, groupCount int) (bytesEncoded int, err error)
- func IsExtended(buffer []byte) bool
- func MaxValueInBytes(byteCount int) uint64
- type Lvlq
- func (this *Lvlq) DecodeFrom(buffer []byte) (decodedByteCount int, isComplete bool)
- func (this *Lvlq) DecodeReversedFrom(buffer []byte) (decodedByteCount int, ok bool)
- func (this Lvlq) EncodeReversedTo(buffer []byte) (encodedByteCount int, ok bool)
- func (this Lvlq) EncodeTo(buffer []byte) (encodedByteCount int, ok bool)
- func (this Lvlq) EncodedSize() int
- type Rvlq
- func (this *Rvlq) DecodeFrom(buffer []byte) (decodedByteCount int, isComplete bool)
- func (this *Rvlq) DecodeReversedFrom(buffer []byte) (decodedByteCount int, ok bool)
- func (this Rvlq) EncodeReversedTo(buffer []byte) (encodedByteCount int, ok bool)
- func (this Rvlq) EncodeTo(buffer []byte) (encodedByteCount int, ok bool)
- func (this Rvlq) EncodedSize() int
Constants ¶
const MaxEncodeLength = 10
Maximum byte length that this library will encode (for a 64-bit value)
Variables ¶
This section is empty.
Functions ¶
func IsExtended ¶
Returns true if the encoded VLQ is extended (prepended with 0x80)
func MaxValueInBytes ¶
Get the maximum value that can be stored in a RVLQ of the selected byte count
Types ¶
type Lvlq ¶
type Lvlq uint64
func DecodeLvlqFrom ¶
func DecodeLvlqReversedFrom ¶
Decode a RVLQ value in reverse order from the end of a buffer. Unlike DecodeFrom(), the reversed version must have all encoded bytes present in the buffer to decode.
func (*Lvlq) DecodeFrom ¶
Decode this LVLQ from a buffer. Returns true for isComplete once the VLQ is fully decoded (i.e. it has encountered a byte with the high bit cleared). This allows for progressive decoding of the VLQ value across multiple buffers.
func (*Lvlq) DecodeReversedFrom ¶
Decode this RVLQ in reverse order from the end of a buffer. Unlike DecodeFrom(), the reversed version must have all encoded bytes present in the buffer to decode.
func (Lvlq) EncodeReversedTo ¶
Encode this LVLQ in reverse order to the end of a buffer. Returns false and the number of bytes it attempted to write if the buffer isn't big enough.
func (Lvlq) EncodeTo ¶
Encode this LVLQ to a buffer. Returns false and the number of bytes it attempted to write if the buffer isn't big enough.
func (Lvlq) EncodedSize ¶
Get the number of bytes required to encode this RVLQ
type Rvlq ¶
type Rvlq uint64
func DecodeRvlqFrom ¶
func DecodeRvlqReversedFrom ¶
Decode a RVLQ value in reverse order from the end of a buffer. Unlike DecodeFrom(), the reversed version must have all encoded bytes present in the buffer to decode.
func (*Rvlq) DecodeFrom ¶
Decode this RVLQ from a buffer. Returns true for isComplete once the VLQ is fully decoded (i.e. it has encountered a byte with the high bit cleared). This allows for progressive decoding of the VLQ value across multiple buffers.
func (*Rvlq) DecodeReversedFrom ¶
Decode this RVLQ in reverse order from the end of a buffer. Unlike DecodeFrom(), the reversed version must have all encoded bytes present in the buffer to decode.
func (Rvlq) EncodeReversedTo ¶
Encode this RVLQ in reverse order to the end of a buffer. Returns false and the number of bytes it attempted to write if the buffer isn't big enough.
func (Rvlq) EncodeTo ¶
Encode this RVLQ to a buffer. Returns false and the number of bytes it attempted to write if the buffer isn't big enough.
func (Rvlq) EncodedSize ¶
Get the number of bytes required to encode this RVLQ