Maestro - Midi Player Tool Kit for Unity Version 2.18.2
Loading...
Searching...
No Matches
MidiFilePlayer

High-level MIDI-file playback with transport, timing, loading, and callback APIs. More...

Topics

 MIDI Selection
 Select which MIDI file will be played.
 Playback Controls
 Start, stop, pause, resume, replay, and sequence MIDI playback.
 Position, Duration, and Timing
 Query and control playback position, timing, duration, and speed.
 MIDI Loading and Event Reading
 Load MIDI content and inspect its event data before or during playback.
 Playback Events and Callbacks
 React to playback start, end, and groups of MIDI events.
 MIDI Channels
 Access the 16 MIDI channels managed by the player.
 Maestro Pro Extensions
 Extended loading, looping, and transition features available in Maestro Pro.

Classes

class  MidiPlayerTK.MidiFilePlayer
 Plays a MIDI file from the MidiDB. This class must be used with the prefab MidiFilePlayer.
See "Midi File Setup" in the Unity menu MPTK for adding MIDI in MidiDB.
. More...

Play and Stop MIDI

bool MidiPlayerTK.MidiFilePlayer.MPTK_PauseOnFocusLoss
 Should the MIDI playing must be paused when the application lost the focus?
void MidiPlayerTK.MidiFilePlayer.MPTK_Stop ()
 Stops MIDI playback and cancels all sounds. This operation is performed in background, so MIDI may really stop after this method returns.

Detailed Description

High-level MIDI-file playback with transport, timing, loading, and callback APIs.

MidiFilePlayer is the most user-facing playback component in Maestro MPTK. It is designed to play complete MIDI files through the MidiFilePlayer prefab and exposes a practical API for both inspector-driven workflows and script-based control.

With MidiFilePlayer, you can:

  • select a MIDI by name or index from the MidiDB,
  • preload a MIDI and inspect its events before playback,
  • play, stop, pause, resume, restart, or loop playback,
  • jump to a position by time or by tick,
  • inspect timing information such as duration, pulse, play time, and real time,
  • react to playback lifecycle events and groups of MIDI events,
  • in Maestro Pro, load external MIDI files, play from byte arrays or generated MIDI writers, and use inner loop / delayed transition features.

MidiFilePlayer builds on MidiSynth. The class focuses on MIDI-file playback features, while synthesis, channel control, and sound rendering options remain available through the inherited MidiSynth API.

Recommended reading order:

  1. MidiFilePlayer Overview
  2. Loading and Inspecting MIDI Content
  3. Playback Control Workflow
  4. Position and Timing
  5. Playback Events and Unity Callbacks
  6. MPTKInnerLoop Workflow (Pro)
  7. MidiFilePlayer Pro Extensions
  8. MPTKWriter Authoring Workflow (Pro)
Note
  • Many advanced scenarios rely on MPTK_MidiLoaded, which exposes detailed information about the currently loaded MIDI. Always check that MPTK_MidiLoaded is not null before using its properties.
  • For setup guidance on adding MIDI files, see https://paxstellar.fr/setup-mptk-add-midi-files-v2/
See also
MidiFilePlayer Overview
Loading and Inspecting MIDI Content
Playback Control Workflow
Position and Timing
Playback Events and Unity Callbacks
MPTKInnerLoop Workflow (Pro)
MidiFilePlayer Pro Extensions
MPTKWriter Authoring Workflow (Pro)