MidiPlayerGlobal

Global MPTK feature

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:

C#
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));
C#
// 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);
}

Get Creative Tools from the Unity store

If you enjoy these creative tools, please leave a review on the Unity Asset Store! Your feedback and support motivate me to keep improving them and creating new features.

Skills for AI assistants

Maestro MPTK now includes AI Skills to help your favorite AI assistant build projects with Maestro! Don’t miss this detailed guide.

AI Skills for Creature Kit are in development.

Note: The custom MPTK LLM has been deprecated.

Contact

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

Reach the Discord archive by topic.

We are always happy to discuss your projects!

Creature Kit – Wild Beasts Demo

Creature Kit – Beast Generator – Creating a Beast in Unity

Add MIDI Music With 3 Clicks for Free

Midi Synth : Real Time Voice Effect Change

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

Euclidean Rhythm demo

Demo on itch!