Platform Compatibility

MPTK is full operational on Windows and Mac OS. Some users have tested also with IOs with good results.

But there is some limitations depending with these devices:

  • Android:
    • Playing midi works but only for simple song due to these limitations:
      • No wave looping over an arbitrary region (wavetable). See detailed information below.
      • Latency.
      • Investigations are in progress with OpenSL ES. Thank to 5Argon. Have a look to his Unity Asset.
    • Other functions as reading/writing midi events work correctly.
  • WebGL:
    • no playing midi due to limitation:
      • Lack of a good threading behaviors.
      • Investigation in progress …
    • Other functions as reading/writing midi events work correctly.

Before buying, check with the free version,
if the free is ok then the pro will be!

If the free is ok then the pro will be!

Wave Looping

See here more information about the wave looping limitation with Android and WebGL.

Take an example with a sound like a piano. When a piano key is hit (note on), the sound is played from the start of the wave:

  • first the attack+decay phase (a very short phase),
  • then the sound plays the sustain phase until the key is released (note off),
  • then the sound plays the release phase, generally a short phase,
  • then the sound is stopped.
From Wikipedia

See here more information how a synthesizer runs (in particular with envelope).

Note: information about looping is defined in the wave file with dedicated attributes defined when the wave is recorded..

Unfortunately, WebGL and Android don’t use these looping information: the sound is playing from the start to the end of the wave until the key is released: all the steps are repeated: attack / decay / sustain / release. It’s like if you hit the piano key a lot of times! It’s a very weird result.

Note: some sound don’t loop. Generally, it’s the case for the percussion sounds.

Perhaps a solution: when processing the SoundFont, prepare each waves by cutting each waves in 3 steps (A/D + S + R); then let MPTK runs each sub wave according the current phase. Wait and see …

Timing accuracy

MPTK is able to trigger action on Midi events. It’s useful to add synchronization with your Unity gameObject: the music can interact with your game or application. It’s only possible because the Midi is read from the Unity main thread.

This can be done because reading events is done in a CoRoutine from the main thread. The default timing is 15 milliseconds which is sufficient in most of the cases. Unfortunately, this tempo is sometimes delayed (because Unity is doing some others tasks).

See below the result: 1,3 % of the cycle are triggered with the double of the value of 15ms. For the most part of Midi files this cannot be heard by a “normal” human ears! Here a midi file with high tempo where the issue arise for some notes (thank robinspots!)

Another solution with a better timing accuracy, could be to read events from OnAudioFilterRead method as with CSharpSynthForUnity. But in this case the reading of the Midi events is executed in an another thread: the reading midi process cannot interact with your gameObject. Nothing is perfect!