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

Represents a MIDI track. More...

#include <MidiFile.h>

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

Public Member Functions

void setChannel (std::uint8_t channel)
void addNote (std::uint8_t pitch, std::uint8_t volume, double realTime, double duration)
 Add both NOTE_ON and NOTE_OFF effects.
void addTempo (std::uint32_t tempo, tick_t time)
 Add a tempo mark.
void addPatch (MidiPatch patch, tick_t time)
 Add bank select and program change events.
void addName (std::string name, tick_t time)
 Add a track name event.
void writeToBuffer ()
 Write MIDI track to buffer.

Private Member Functions

void addEvent (Event &&event, tick_t time)
 Append a single event to vector.
void writeMIDIToBuffer ()
 Write the meta data and note data to buffer.
void writeEventsToBuffer ()
 Write the sorted events in m_events to buffer.
void writeSingleEventToBuffer (Event &event)
 Write a single event to buffer.

Private Attributes

std::vector< Event > m_events
 Variable-length vector of events.
std::uint8_t m_channel = 0
 Track channel number.

Additional Inherited Members

Public Attributes inherited from lmms::MidiFile::Section
std::vector< std::uint8_t > m_buffer
 Constant-capacity buffer vector to be written to stream.
Protected Member Functions inherited from lmms::MidiFile::Section
 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.

Detailed Description

Represents a MIDI track.

Member Function Documentation

◆ addEvent()

void lmms::MidiFile::Track::addEvent ( Event && event,
tick_t time )
private

Append a single event to vector.

◆ addName()

void lmms::MidiFile::Track::addName ( std::string name,
tick_t time )

Add a track name event.

◆ addNote()

void lmms::MidiFile::Track::addNote ( std::uint8_t pitch,
std::uint8_t volume,
double realTime,
double duration )

Add both NOTE_ON and NOTE_OFF effects.

Parameters
pitchNote pitch
volumeNote volume
realTimeTime of note start
durationHow long the note lasts

◆ addPatch()

void lmms::MidiFile::Track::addPatch ( MidiPatch patch,
tick_t time )

Add bank select and program change events.

◆ addTempo()

void lmms::MidiFile::Track::addTempo ( std::uint32_t tempo,
tick_t time )

Add a tempo mark.

◆ setChannel()

void lmms::MidiFile::Track::setChannel ( std::uint8_t channel)
inline

◆ writeEventsToBuffer()

void lmms::MidiFile::Track::writeEventsToBuffer ( )
private

Write the sorted events in m_events to buffer.

◆ writeMIDIToBuffer()

void lmms::MidiFile::Track::writeMIDIToBuffer ( )
private

Write the meta data and note data to buffer.

◆ writeSingleEventToBuffer()

void lmms::MidiFile::Track::writeSingleEventToBuffer ( Event & event)
private

Write a single event to buffer.

◆ writeToBuffer()

void lmms::MidiFile::Track::writeToBuffer ( )
virtual

Write MIDI track to buffer.

Reimplemented from lmms::MidiFile::Section.

Member Data Documentation

◆ m_channel

std::uint8_t lmms::MidiFile::Track::m_channel = 0
private

Track channel number.

◆ m_events

std::vector<Event> lmms::MidiFile::Track::m_events
private

Variable-length vector of events.


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