TrackEvent

A TrackEvent is a delta time coupled with either a MIDI event, a system exclusive event or a meta event.

TrackEvent has an underlying union that uses the status byte to discriminate (which cannot be changed after construction). Use asMIDIEvent(), asSysExEvent() or asMetaEvent() to access the underlying values from the union.

See the documentation of mididi.def.isMIDIEvent() to see what each type of message means. Note: system exclusive events ARE also semantically system common messages. The confusing thing is that all other system common messages are syntactically MIDI events, but system exclusive events are not MIDI events.

Constructors

this
this(int deltaTime, MIDIEvent event)
this(int deltaTime, SysExEvent event)
this(int deltaTime, MetaEvent event)

These constructors initialize the object with a delta time and an event.

Members

Functions

asMIDIEvent
inout(MIDIEvent)* asMIDIEvent()
asMetaEvent
inout(MetaEvent)* asMetaEvent()
asSysExEvent
inout(SysExEvent)* asSysExEvent()
opEquals
bool opEquals(TrackEvent rhs)
toHash
size_t toHash()

Equality and hash methods.

Properties

statusByte
ubyte statusByte [@property getter]

Variables

deltaTime
int deltaTime;

deltaTime is the time between the previous event and this event.

Examples

Here is an example of how to use TrackEvent.

auto statusByte = cast(ubyte) ((ChannelMessageType.noteOn << 4) | 0x7);
auto event = TrackEvent(
    200,
    MIDIEvent(statusByte, [0x0F, 0x00]),
);

// get underlying value
assert(event.asSysExEvent() is null);
assert(event.asMetaEvent() is null);
const message = event.asMIDIEvent();
assert(message !is null);

// MIDI event = either a channel message or a system message
assert(message.isChannelMessage());
assert(!message.isSystemMessage());

// since it's a channel message, we can use these properties of the
// `MIDIEvent` struct:
assert(message.getChannelMessageType() == ChannelMessageType.noteOn);
assert(message.getChannelNumber() == 0x7);
assert(message.data == [0x0F, 0x00]);

Meta