MidiPlayerGlobal

It’s a singleton class to manage all global features of MPTK.

Inspector [PRO only]

Select your midi in the Inspector and run your application, the Midi is playing . It’s as simple as that ! See below the specific parameters that can be applied.

  • Current SoundFont select a SoundFont from the MPTK DB SoundFont available.
  • To be continued

Integration of MidiFilePlayer in your script

See TestMidiFilePlayerScripting.cs for the whole example.

using MidiPlayerTK;
...
MidiFilePlayer mfp = FindObjectOfType<MidiFilePlayer>();

// Set event by script
mfp.OnEventEndPlayMidi.AddListener(EndPlay);
mfp.OnEventNotesMidi.AddListener(MidiReadEvents);

// Event fired when a midi is ended
public void EndPlay(string midiname, EventEndMidiEnum reason)
{
   Debug.LogFormat("End playing {0} reason:{1}", midiname, reason);
}

// Event fired by MidiFilePlayer when midi notes are available
public void MidiReadEvents(List<MPTKEvent> events)
{
   foreach (MPTKEvent midievent in events)
      ...
}

void OnGUI()
{
   ...
   mfp.MPTK_Play();
   midiFilePlayer.MPTK_Position = position;
   ...
}