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 web build has been tested with Unity 6 and Unity 2022.3.
Working mode
When WebGL build is selected in the editor, some changes are applied to MPTK version 2.16 (coming soon):
- 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. With core mode, 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 web build … and finally this mode will be retained with next MPTK version!
Limitations
- Coroutine for MIDI sequencer is not perfect for accurate tempo.
- Unity sound effects real-time modification by the MPTK API when playing is not unavailable (but there is a solution, perhaps for a future version). Happily SoundFont effects are working!
- The sound quality is inferior to other platforms such as macOS, iOS Windows, and Android. Look above Working Mode chapter to understand why.
- Select “Decompress On Load” when importing a SoundFont. MPTK Pro is needed for this action.
- Audio Spatializer plugins like Steam Audio seems not implemented.
- Prefab MidiSpatializer will not work.
- Real-time loading soundfont from the web is not working (not yet compliant with non-core mode) but switching on local soundfont do the job.
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.
Quick how-to from a newer project
- Create a fresh project with Unity version >= 2022.3.
- Import Maestro MPTK Pro.
- Switch to Desktop build (Build settings) if not already done.
- From the menu Maestro / SoundFont setup,
- import a SoundFont,
- extract samples with “Decompress On Load”
- Switch platform to WebGL in Unity “Building setting”.
- Select the project you want to build (try with MPTK demo 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.

*** to be continued ***