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

Provides access to the native MidiKeyboard plugin to send and receive MIDI messages from desktop MIDI devices. More...

Public Types

enum  PluginError
 Native plugin error return values (WinMM/MMSystem style).

Public Member Functions

static int MPTK_ClearReadQueue ()
 Clears the native MIDI input read queue.
static int MPTK_SizeReadQueue ()
 Gets the number of MIDI messages waiting in the native read queue.
static int MPTK_CountInp ()
 Gets the number of MIDI input devices currently detected by Windows (WinMM).
static int MPTK_CountOut ()
 Gets the number of MIDI output devices currently detected by Windows (WinMM).
static int MPTK_CountOpenInp ()
 Gets the number of MIDI input devices currently opened and tracked by the plugin. This differs from MPTK_CountInp, which returns the number of devices detected by Windows.
static void MPTK_OpenOut (int index)
 Opens a MIDI output device.
static void MPTK_CloseOut (int index)
 Closes a MIDI output device.
static void MPTK_OpenAllInp ()
 Opens all available MIDI input devices and refreshes the opened list on subsequent calls.
static void MPTK_CloseAllInp ()
 Closes all MIDI input devices currently opened by the plugin.
static void MPTK_RebuildAllInp ()
 Forces a full rebuild of all opened MIDI input devices.

Static Public Member Functions

static MPTKEvent MPTK_Read ()
 Reads one MIDI message from the shared native input queue.
static string MPTK_GetInpName (int index)
 Gets the display name of a MIDI input device from its WinMM index.
static string MPTK_GetOutName (int index)
 Gets the display name of a MIDI output device from its WinMM index.
static void MPTK_PlayEvent (MPTKEvent evnt, int device)
 Sends a MIDI event to an output device. If the event has a delay, it is sent from a worker thread.
static void MPTK_ExcludeSystemMessage (bool exclude)
 Enables or disables filtering of MIDI system messages.
static string MPTK_Version ()
 Gets the current native plugin version string.
static void MPTK_SetRealTimeRead ()
 Enables real-time MIDI input notifications through a native callback. The OnActionInputMidi event is raised when a MIDI event is available.
static int MPTK_DispatchPendingRealtimeInput (int maxMessages=256)
 Dispatches MIDI messages received from the native callback when no Unity synchronization context is available. Call this from the main thread (for example from Update).
static void MPTK_UnsetRealTimeRead ()
 Disables real-time MIDI input notifications from the native callback. This should be called before application shutdown (especially in the Unity Editor) to reduce the risk of crashes caused by stale callbacks.
static bool MPTK_Init ()
 Initializes the native MidiKeyboard plugin. This must be called before using any other plugin function.

Properties

static PluginError MPTK_LastStatus [get]
 Gets the last native plugin status. The status is reset to OK after each call.

Events

static Action< MPTKEventOnActionInputMidi
 Event raised when an input MIDI message is available.

Detailed Description

Provides access to the native MidiKeyboard plugin to send and receive MIDI messages from desktop MIDI devices.

Version: Maestro Pro

More information: https://paxstellar.fr/class-midikeyboard/

Member Function Documentation

◆ MPTK_ClearReadQueue()

int MidiPlayerTK.MidiKeyboard.MPTK_ClearReadQueue ( )

Clears the native MIDI input read queue.

Returns
Implementation-specific status value from the native plugin.

◆ MPTK_Read()

MPTKEvent MidiPlayerTK.MidiKeyboard.MPTK_Read ( )
static

Reads one MIDI message from the shared native input queue.

Returns
A parsed MPTKEvent or null when the queue is empty.

◆ MPTK_SizeReadQueue()

int MidiPlayerTK.MidiKeyboard.MPTK_SizeReadQueue ( )

Gets the number of MIDI messages waiting in the native read queue.

Returns
Queue length.

◆ MPTK_CountInp()

int MidiPlayerTK.MidiKeyboard.MPTK_CountInp ( )

Gets the number of MIDI input devices currently detected by Windows (WinMM).

Returns
Detected input device count.

◆ MPTK_CountOut()

int MidiPlayerTK.MidiKeyboard.MPTK_CountOut ( )

Gets the number of MIDI output devices currently detected by Windows (WinMM).

Returns
Detected output device count.

◆ MPTK_GetInpName()

string MidiPlayerTK.MidiKeyboard.MPTK_GetInpName ( int index)
static

Gets the display name of a MIDI input device from its WinMM index.

Parameters
indexWinMM input device index.
Returns
Input device display name.

◆ MPTK_GetOutName()

string MidiPlayerTK.MidiKeyboard.MPTK_GetOutName ( int index)
static

Gets the display name of a MIDI output device from its WinMM index.

Parameters
indexWinMM output device index.
Returns
Output device display name.

◆ MPTK_OpenOut()

void MidiPlayerTK.MidiKeyboard.MPTK_OpenOut ( int index)

Opens a MIDI output device.

Parameters
indexWinMM output device index.

◆ MPTK_CloseOut()

void MidiPlayerTK.MidiKeyboard.MPTK_CloseOut ( int index)

Closes a MIDI output device.

Parameters
indexWinMM output device index.

◆ MPTK_PlayEvent()

void MidiPlayerTK.MidiKeyboard.MPTK_PlayEvent ( MPTKEvent evnt,
int device )
static

Sends a MIDI event to an output device. If the event has a delay, it is sent from a worker thread.

Parameters
evntMIDI event to send.
deviceWinMM output device index.

◆ MPTK_OpenAllInp()

void MidiPlayerTK.MidiKeyboard.MPTK_OpenAllInp ( )

Opens all available MIDI input devices and refreshes the opened list on subsequent calls.

Hot-plug behavior depends on the Windows MIDI driver (WinMM). Some hardware/drivers, especially older USB-MIDI drivers, may not report disconnect/reconnect reliably. If a device is not detected after reconnect, call MPTK_RebuildAllInp.

◆ MPTK_RebuildAllInp()

void MidiPlayerTK.MidiKeyboard.MPTK_RebuildAllInp ( )

Forces a full rebuild of all opened MIDI input devices.

Use this as a recovery action when hot-plug is not detected correctly by some hardware/drivers.

◆ MPTK_ExcludeSystemMessage()

void MidiPlayerTK.MidiKeyboard.MPTK_ExcludeSystemMessage ( bool exclude)
static

Enables or disables filtering of MIDI system messages.

Parameters
excludeIf true, excludes messages with status/command >= 0xF0 (default behavior).

◆ MPTK_Version()

string MidiPlayerTK.MidiKeyboard.MPTK_Version ( )
static

Gets the current native plugin version string.

Returns
Version string, or a fallback message if the plugin is not available.

◆ MPTK_SetRealTimeRead()

void MidiPlayerTK.MidiKeyboard.MPTK_SetRealTimeRead ( )
static

Enables real-time MIDI input notifications through a native callback. The OnActionInputMidi event is raised when a MIDI event is available.

if (enableRealTimeRead)
{
}
else
{
}
Provides access to the native MidiKeyboard plugin to send and receive MIDI messages from desktop MIDI...
Definition MidiKeyboard.cs:17
static Action< MPTKEvent > OnActionInputMidi
Event raised when an input MIDI message is available.
Definition MidiKeyboard.cs:64
static void MPTK_UnsetRealTimeRead()
Disables real-time MIDI input notifications from the native callback. This should be called before ap...
Definition MidiKeyboard.cs:382
static void MPTK_SetRealTimeRead()
Enables real-time MIDI input notifications through a native callback. The OnActionInputMidi event is ...
Definition MidiKeyboard.cs:300

◆ MPTK_DispatchPendingRealtimeInput()

int MidiPlayerTK.MidiKeyboard.MPTK_DispatchPendingRealtimeInput ( int maxMessages = 256)
static

Dispatches MIDI messages received from the native callback when no Unity synchronization context is available. Call this from the main thread (for example from Update).

Parameters
maxMessagesMaximum messages to dispatch in one call.
Returns
Number of dispatched messages.

Event Documentation

◆ OnActionInputMidi

Action<MPTKEvent> MidiPlayerTK.MidiKeyboard.OnActionInputMidi
static

Event raised when an input MIDI message is available.