MusIT

MidiPlayerGlobal

MidiPlayerGlobal is a singleton and static class for managing all global features of MPTK.

For non C# specialist:

  • singleton: only one instance can exist at the same time.
  • static: the class doesn’t need to be instantiated (done automatically by MPTK) in an object to be used. All properties are shared and are available for all others objects. That is very useful!

The script MidiPlayerGlobal.cs exists in each MPTK Prefab. But when running, only one is kept in the scene hierarchy.

Inspector [PRO only]

With the inspector, you can:

  • Current SoundFont: select a SoundFont from the MPTK SoundFont available.
  • Load SoundFont at startup: the selected SoundFont is loaded when application is started. It’s the default behaviors. It’s possible de disable this automatic loading.
  • Load Samples at startup (no core mode): the “no core mode” will be removed with the next major version.
  • SoundFont URL or file path: with the version Pro it’s possible to dynamically load a SoundFont when running from a local file on your desktop or from a web site. But, SoundFont loading could take some times.

Integration in your script

All methods and properties of MidiPlayerGlobal are static. So you can use directly by the class name to access it. Look at this page for more information how scripting with MPTK and to download the full documentation.

Look at the MidiPlayerGlobal API for a full information.

Example of methods:

Debug.Log(string.Format("Load Time:{0} s Samples:{1} s Count Presets:{2} Samples:{3}", MidiPlayerGlobal.MPTK_TimeToLoadSoundFont.TotalSeconds, MidiPlayerGlobal.MPTK_TimeToLoadWave.TotalSeconds, MidiPlayerGlobal.MPTK_CountPresetLoaded, MidiPlayerGlobal.MPTK_CountWaveLoaded));
Code language: C# (cs)
// Dynamically loading a SoundFont when running: (Pro version) void Start() { MidiPlayerGlobal.OnEventPresetLoaded.AddListener(EndLoadingSF); MidiPlayerGlobal.MPTK_LoadLiveSF(URLSoundFontAtStart); } public void EndLoadingSF() { Debug.Log("End loading SF, Maestro ready to play"); } public void LoadSF() { string urlSF= "https://mptkapi.paxstellar.com/GSv1471.sf2"; if (URLSoundFont != null && string.IsNullOrEmpty(URLSoundFont.text)) urlSF = URLSoundFont.text; MidiPlayerGlobal.MPTK_LoadLiveSF(urlSF); }
Code language: C# (cs)

Get MPTK from the Unity store

If you like Midi Player Tool Kit, please leave a review on the Asset Store. It’s very appreciated!!!

Contact

If you have any questions, please don’t hesitate to contact us via the dedicated Unity forum or our Discord  channel.

We are always happy to discuss your projects!

Add MIDI Music With 3 Clicks for Free

Sound Spatialisation, MPTK is ready for Virtual Reality [Pro]

Sound Spatialisation, MPTK is ready for Virtual Reality [free]

Midi Synth : Real Time Voice Effect Change

Euclidean Rhythm demo

New on Asset Store

Asset Store Partners