So late!
Why now? The persistent and frustrating Unity issue with looping inside a sample from a web build has finally been resolved by Unity. https://issuetracker.unity3d.com/issues/webgl-a-looping-audio-sounds-different-on-webgl-than-in-the-editor-slash-native-desktop-player
MPTK webGL build has been tested with Unity 6 and Unity 2022.3.
Working mode and Historics
When webGL build is selected in the editor, some changes are applied to MPTK version 2.16:
- Core mode is set to false: each couple note / instrument are played in a dedicated AudioSource.
- Coroutines are used for MIDI sequencer (threads are not allowed with webGL, perhaps one day …).
The MPTK non core mode was the legacy mode for playing generated samples. The initial version released in 2018 achieved significant success, despite sound quality was suboptimal. So, I have decided to build a real synth process based on the OnAudioFilterRead callback.
With core mode enabled, one AudioSource is able to play all samples (so, for each note-on) with a very low latency and an excellent stable timing. Also, there is only one AudioSource for each MIDI Synth (MidiFilePlayer, MisiStreamPlayer, …).
The legacy mode was notified as deprecated and to be removed in a future major version. Unfortunately, callback OnAudioFilterRead with AudioSource is not implemented for web. Therefore, non core mode is mandatory for webGL build … and finally this mode will be retained with next MPTK versions and named Legacy Mode!
Limitations
- Coroutine for MIDI sequencer is not perfect for very precise tempo.
- Sound effects real-time modification by the MPTK API when playing is unavailable (but there is a solution, perhaps for a future version).
- The sound quality is inferior to other platforms such as macOS, iOS Windows, and Android. Look above Working Mode chapter to understand why..
- Audio Spatializer plugins like Steam Audio seems not implemented, so prefab MidiSpatializer will not work.
- Real-time loading soundfont from the web is not working (not yet compliant with legacy mode) but switching on local soundfont do the job.
- The plugins MidiKeyboard is not available for WebGL build. Some tests in progress with this Unity package …
Good points
- The interactivity between your gameplay and the music works well. This is one of Maestro MPTK’s strengths: influencing the music by script (or the inverse!) according to the scenarios you have imagined.
- Spatialization based on distance between MPTK Prefab and Listener is working.
- Real-time loading soundfont from local soundfont is working.
- SoundFont effects by the MPTK API is working but not dynamic change.
- Low latency on user action!
- Compatible with the Free MPTK! If you publish a web app, I’d be happy if you could give credit to MPTK somewhere in your app.
Quick how-to from a newer project
- Create a fresh project with Unity version >= 2022.3.
- Import Maestro MPTK Pro or Free.
- Switch to WebGL build (Build settings) if not already done.
- From the menu Maestro / SoundFont setup,
- import a SoundFont,
- extract samples with default choices “Compressed In Memory” and “PCM”
- Select the project you want to build (try with MPTK demos like TestMidiFilePlayerScript).
- Build and run your project. When the webpage pop up, your project will be loaded and run. A first user action is requested to activate the sound in the web page.
Tip: If you want to build for another platform, switch back to ‘Windows, Mac, Linux platform’. Unfortunately, all audio files will be converted by Unity to be compliant, and that takes time — but the conversion will run only once per platform.
Want to test?
The demo scene (Demo/Builder/ScenesDemonstration) has been build for webGL and deployed on itch.io
See here: Unity MIDI Player Tool Kit on WebGL
This demo contains all the scenes available with the Pro version

Next Step
- Release 2.16.0 is mandatory for webGL build, soon available!
- Improve Legacy mode with your input.
- A full game with music as a key role. I have the ideas – therefore, now to be transformed in the real world, summer will be hot!