lmms
Cross-platform music production software
Loading...
Searching...
No Matches
lmms::MidiFile::Section Class Reference

Base class for sections of MIDI file. More...

Inheritance diagram for lmms::MidiFile::Section:
lmms::MidiFile::Header lmms::MidiFile::Track

Public Attributes

std::vector< std::uint8_t > m_buffer
 Constant-capacity buffer vector to be written to stream.

Protected Member Functions

 Section ()
 Reserve constant space for BufferSize capacity vector.
void writeBytes (std::span< const std::uint8_t > bytes)
 Write bytes to buffer.
void writeBytes (std::initializer_list< std::uint8_t > bytes)
 Write bytes to buffer.
void writeVarLength (std::uint32_t val)
 Write a MIDI-compatible variable length stream.
void writeBigEndian4 (std::uint32_t val)
 Buffer gets four 8-bit values from left to right.
void writeBigEndian2 (std::uint16_t val)
 Buffer gets two 8-bit values from left to right.
virtual void writeToBuffer ()
 Write section info to buffer.

Detailed Description

Base class for sections of MIDI file.

Constructor & Destructor Documentation

◆ Section()

lmms::MidiFile::Section::Section ( )
protected

Reserve constant space for BufferSize capacity vector.

Member Function Documentation

◆ writeBigEndian2()

void lmms::MidiFile::Section::writeBigEndian2 ( std::uint16_t val)
protected

Buffer gets two 8-bit values from left to right.

◆ writeBigEndian4()

void lmms::MidiFile::Section::writeBigEndian4 ( std::uint32_t val)
protected

Buffer gets four 8-bit values from left to right.

◆ writeBytes() [1/2]

void lmms::MidiFile::Section::writeBytes ( std::initializer_list< std::uint8_t > bytes)
protected

Write bytes to buffer.

Parameters
bytesList of bytes to be written TODO C++26: Remove once std::span supports construction from std::initializer_list

◆ writeBytes() [2/2]

void lmms::MidiFile::Section::writeBytes ( std::span< const std::uint8_t > bytes)
protected

Write bytes to buffer.

Parameters
bytesList of bytes to be written

◆ writeToBuffer()

virtual void lmms::MidiFile::Section::writeToBuffer ( )
inlineprotectedvirtual

Write section info to buffer.

Reimplemented in lmms::MidiFile::Header, and lmms::MidiFile::Track.

◆ writeVarLength()

void lmms::MidiFile::Section::writeVarLength ( std::uint32_t val)
protected

Write a MIDI-compatible variable length stream.

Parameters
valA four-byte value

The MIDI format is a little strange, and makes use of so-called variable length quantities. These quantities are a stream of bytes. If the most significant bit is 1, then more bytes follow. If it is zero, then the byte in question is the last in the stream.

Member Data Documentation

◆ m_buffer

std::vector<std::uint8_t> lmms::MidiFile::Section::m_buffer

Constant-capacity buffer vector to be written to stream.


The documentation for this class was generated from the following files: