Maestro - Midi Player Tool Kit for Unity Version 2.18.2
Loading...
Searching...
No Matches
MPTKEvent Concept and Data Model

Understand what MPTKEvent represents and how to use it in playback workflows.

MPTKEvent is the central runtime MIDI message object in Maestro MPTK. It represents one MIDI event (note, controller, patch change, meta event, etc.) and is used by both file-based and real-time playback systems.

In practice:

  • MidiFilePlayer reads and emits lists of MPTKEvent.
  • MidiStreamPlayer plays MPTKEvent instances created at runtime.
  • MPTKWriter and related APIs generate MIDI content through MPTKEvent-compatible data.

Core Model

The event type is defined by Command. Other fields are interpreted from that command:

  • Value: note number, controller value, patch index, tempo/signature packed data, etc.
  • Channel: MIDI channel (0 to 15).
  • Velocity: mainly for note on/off events.
  • Duration: note length in milliseconds for NoteOn events.
  • Controller: controller type for ControlChange.
  • Meta and Info: meta-event subtype and text data.

Related enums:

Typical Runtime Usage

A common real-time workflow is:

// Play C4 on channel 0 for 500 ms
MPTKEvent e = new MPTKEvent()
{
Command = MPTKCommand.NoteOn,
Value = 60,
Velocity = 100,
Channel = 0,
Duration = 500
};
midiStreamPlayer.MPTK_PlayEvent(e);

Timing and Context

MPTKEvent also stores timeline and runtime context information:

  • musical position: Tick, Measure, Beat,
  • real-time position: RealTime,
  • session/source context: IdSession, Source,
  • attached active voices: Voices, and completion state: IsOver.

These fields are useful for diagnostics, filtering, editor tools, and synchronization logic around playback.

Maestro Pro Extension

In Maestro Pro, MPTKEvent adds per-event SoundFont generator controls (real-time timbre changes):

See also
Real-Time MIDI Messages Workflow
MidiPlayerTK.MPTKEvent
MidiPlayerTK.MidiStreamPlayer.MPTK_PlayEvent
MidiPlayerTK.MidiFilePlayer.MPTK_ReadMidiEvents