How to add Midi musics in your application in a few steps.
if you are starting a new project go to 1.1 bullet bellow.
if you are updating Midi Player ToolKit, some older classes will remain in the folders because Unity import won’t removed these files and you will get tricky issues. Consequently, please follow this steps:
- backup your project,
- remove the entire current version in the Unity Editor project panel (remove folder MidiPlayer).
- and go to 1.1 bullet below.
1.2 – Import Unity package in your Unity application, you will get something like this in your project:
Tips : Free version comes with a default SoundFont (GeneralUser_GS_SoftSynth_v144) and some examples of Midi files. However, you can delete all the Midi files and add your favorites (see Midi Player Tool Kit Setup below) even with the free version 😉
Recommendations: to ease installation of futures updates of MPTK (a lot of great functions are forecasted!), please follow these rules:
- Create your assets apart of the MidiPlayer assets folder.
- Don’t change anything in MPTK scripts or hierarchy.
- Don’t change anything in Prefab.
- Use only documented API.
SoundFont(R) is a registered trademark of E-mu Systems, Inc.
2 – Hierarchy
If you already have added Midi files and SoundFont in MPTK, you can continue with the actions below.
2.1 – Add to your Unity hierarchy, one or more “MidiFilePlayer” Prefab from “MidiPlayer/Prefab”. Each one can plays a different Midi file.
2.2 – Check that you have an AudioListener component somewhere in your hierarchy. This component is typically associated with the “Main Camera”.
3 – From the MidiFilePlayer Inspector
3.1 – Firstly, select one MidiFilePlayer in the hierarchy, then look at the Inspector.
3.2.1 – Secondly, select the Midi File to play. But, if no Midi is available, see How to add Midi file.
3.2.2 – Most importantly, check that “Play At Startup” and “Send To Synth” are selected (default value).
3.2.3 – It’s over! Now you can run your Unity application, the Midi begins to play!
After that, you can play with the parameters available in the inspector. You can also going here to have a description of all parameters.