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

Play and stop MIDI events in real time. More...

Functions

void MidiPlayerTK.MidiStreamPlayer.MPTK_StartMidiStream ()
 Forces initialization of MidiStreamPlayer. Useful when another component needs to send MIDI commands as soon as the application starts.
void MidiPlayerTK.MidiStreamPlayer.MPTK_PlayEvent (MPTKEvent mptkEvent)
 Plays one MIDI event from an instance of MPTKEvent. Runs in a thread so the call returns immediately. See also the method MPTK_StopEvent to stop a note from an instance of MPTKEvent.
void MidiPlayerTK.MidiStreamPlayer.MPTK_StopEvent (MPTKEvent mptkEvent)
 Stops a currently playing note. All samples associated with the note are stopped by sending a note-off. The parameter must be an MPTKEvent instance previously used with MPTK_PlayEvent.

Detailed Description

Play and stop MIDI events in real time.

This chapter covers event-by-event live playback.

Main entry points
Related concept

Function Documentation

◆ MPTK_StartMidiStream()

void MidiPlayerTK.MidiStreamPlayer.MPTK_StartMidiStream ( )

Forces initialization of MidiStreamPlayer. Useful when another component needs to send MIDI commands as soon as the application starts.

// Find a MidiStreamPlayer Prefab from the scene
MidiStreamPlayer MidiStream = FindFirstObjectByType<MidiStreamPlayer>();
MidiStream.MPTK_StartMidiStream();
Builds and plays real-time music in response to user actions or algorithmic logic....
Definition MidiStreamPlayer.cs:44
void MPTK_StartMidiStream()
Forces initialization of MidiStreamPlayer. Useful when another component needs to send MIDI commands ...
Definition MidiStreamPlayer.cs:90

◆ MPTK_PlayEvent()

void MidiPlayerTK.MidiStreamPlayer.MPTK_PlayEvent ( MPTKEvent mptkEvent)

Plays one MIDI event from an instance of MPTKEvent. Runs in a thread so the call returns immediately. See also the method MPTK_StopEvent to stop a note from an instance of MPTKEvent.

midiStreamPlayer.MPTK_PlayEvent
(
new MPTKEvent()
{
Channel = 9,
Duration = 999999,
Value = 48,
Velocity = 100
}
);
Parameters
mptkEventInstance of MPTKEvent to play.

◆ MPTK_StopEvent()

void MidiPlayerTK.MidiStreamPlayer.MPTK_StopEvent ( MPTKEvent mptkEvent)

Stops a currently playing note. All samples associated with the note are stopped by sending a note-off. The parameter must be an MPTKEvent instance previously used with MPTK_PlayEvent.

void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
// Assign our "Hello, World!"-equivalent note (using MPTKEvent's defaults plus Value = 60 for C5.
// HelperNoteLabel class could be your friend)
mptkEvent = new MPTKEvent() { Value = 60 };
// Start playing our "Hello, World!"-equivalent note
midiStreamPlayer.MPTK_PlayEvent(mptkEvent);
}
else if (Input.GetKeyUp(KeyCode.Space))
{
// Stop playing our "Hello, World!"-equivalent note
midiStreamPlayer.MPTK_StopEvent(mptkEvent);
}
}
Represents a MIDI event used throughout MPTK. This class is central to script-based MIDI workflows in...
Definition MPTKEvent.cs:59
Parameters
mptkEventMPTKEvent instance used to start the note with MPTK_PlayEvent.