Prefab MidiExternalPlayer

MidiExternalPlayer is a Prefab, available with the Pro version, able to play Midi music from Midi outside MPTK: from a folder on your desktop or from a web site.

  • This Prefab is available with MPTK Pro.
  • No line of script is necessary to use this Prefab.
  • But an API exists for a more complex integration in your application. See an example with source code at the end of this page.

Inspector parameters

When running:

  • Midi URL or file path type a file path or an URL, select from a folder, clear the content. Example of path:
    • Windows: file://C:/Users/Thierry/Desktop/Midi/WishYouWereHere.mid
    • Mac: file:///Users/thierry/Desktop/Nirvana.mid
    • Web:
    • Or use the browser icon (on left) to select a file from your desktop.
  • Volume set the default volume of the playing.
  • Pause with distance if checked, automatically pause the play if distance between the gameobject MidiFilePlayer and the AudioListener is greater than MaxDistance.
  • MaxDistance distance for the pause with distance function.
  • Transpose transpose the music by half tone.
  • Play At Startup if checked, start playing when your application starts.
  • Send To Synth if not checked, Midi file is read but no Midi events are send to the synthesizer. Nevertheless, The Unity event
    OnEventNotesMidi is fired.
  • Loop if checked, restart playing automatically when the end of the Midi file is reached.
  • Time / Position current time position of the playing Midi and total length. The value can change if a tempo change is received from the Midi sequencer. The slider can be used to change this position when playing.
  • Ticks / Position current ticks position of the playing Midi and total length. The value is independant of the tempo change. The slider can be used to change this position when playing.
  • Play / Pause / Stop / Restart, change the current playing status.
  • Previous / Next load previous or next Midi in the MPTK Midi list.

Others Foldout

Integration of MidiExternalPlayer in your script

See TestMidiExternalPlayer.cs and events associated in the canvas gameobjects of TestExternalMidiPlay scene for the whole example.

using MidiPlayerTK;
// MPTK component able to play a Midi file from an external source.
// This PreFab must be present in your scene.
public MidiExternalPlayer midiExternalPlayer;...
// This method is fired from button (with predefined URI) 
// or input field in the screen.
public void Play(string uri)
    Debug.Log("Play from script:" + uri);
    midiExternalPlayer.MPTK_MidiName = uri;
// Play a predefined Midi from the web
public void PlayStatic()
    midiExternalPlayer.MPTK_MidiName = "";