Tabula Sonora 0.1.0
A native C++20 implementation of the Roland Sound Canvas VA synth voice
Loading...
Searching...
No Matches
ts::MidiEvent Struct Reference

One scheduled MIDI message. More...

#include <tabulasonora/smf_reader.hpp>

Public Member Functions

int channel () const noexcept
 The channel a channel message addresses.
int message_type () const noexcept
 The message type nibble.

Public Attributes

std::int64_t position = 0
 Position in samples, quantised to the render-block grid.
MidiEventKind kind = MidiEventKind::channel
 Which kind of message.
int status = 0
 Status byte, for a channel message.
int data1 = 0
 First data byte.
int data2 = 0
 Second data byte, or zero for two-byte messages.
std::vector< std::uint8_t > sysex
 Raw bytes, for a system-exclusive message.
int port = 0
 Which MIDI port the event's track was tagged for.

Detailed Description

One scheduled MIDI message.

Member Function Documentation

◆ channel()

int ts::MidiEvent::channel ( ) const
inlinenodiscardnoexcept

The channel a channel message addresses.

◆ message_type()

int ts::MidiEvent::message_type ( ) const
inlinenodiscardnoexcept

The message type nibble.

Member Data Documentation

◆ position

std::int64_t ts::MidiEvent::position = 0

Position in samples, quantised to the render-block grid.

◆ kind

MidiEventKind ts::MidiEvent::kind = MidiEventKind::channel

Which kind of message.

◆ status

int ts::MidiEvent::status = 0

Status byte, for a channel message.

◆ data1

int ts::MidiEvent::data1 = 0

First data byte.

◆ data2

int ts::MidiEvent::data2 = 0

Second data byte, or zero for two-byte messages.

◆ sysex

std::vector<std::uint8_t> ts::MidiEvent::sysex

Raw bytes, for a system-exclusive message.

◆ port

int ts::MidiEvent::port = 0

Which MIDI port the event's track was tagged for.

A file addresses more than sixteen channels by splitting them across ports, and it says which port a track belongs to with a meta event: FF 21 (MIDI Port) carries the number outright, while FF 09 (Device Name) — or FF 04 (Instrument Name) in files that predate it — names an output instead. One scheme applies per file, preferred in that order: any FF 21 anywhere means the numbers rule and the names are ignored, else FF 09 names, else FF 04 names. Names are assigned numbers in order of first appearance, deduplicated by the string exactly as stored — but a name scheme only applies at all when some MIDI channel is claimed under more than one distinct name, and only tracks that play exactly one channel get a vote: a named track spanning several channels is a mix-down riding along, not a device voice. That collision is the one thing sixteen channels cannot express alone; without it the names are instrument labels, and the file is the single-port file it looks like. Untagged files are all port 0, which is what they have always been. The engine masks this to the ports it was created with, so a file asking for port 3 on a two-port engine folds onto port 1 rather than being dropped.


The documentation for this struct was generated from the following file: