Midi Player Tool Kit For Unity

Midi Player Tool Kit is a package for Unity able to play music from Midi file in your application.

  • No scripting C# or JS is mandatory.
  • API available if you need more complex integration with your application.
  • Add Midi Audio Source as much as you want.

Midi file is a well known format for playing music. It’s very easy to find a lot of varied music often for free on the web.

Try here :

  • Midi World is a huge free midi site with varied genre : classic, pop, rock, rap, dance, punk, blues, country, movie themes, tv themes, christmas carols, video game themes, disney themes, national anthems, jazz , hip-hop : http://www.midiworld.com/
  • Free Midi is also huge free midi site with varied genre : Rock, Pop, Rap, Hip-Hop, R&B, Soul, Classical, Country Folk, Jazz, Blues, Dance / Electric, Folk, Punk, Newage : https://freemidi.org/
  • Search midi video game ? Started in 1996, thousands midi file are available  : https://www.vgmusic.com/
  • Another site specialized in midi video game : http://www.midishrine.com/

Midi Player Tool Kit is based on SoundFont, a kind of library wich contains hundred sound of instruments as piano, sax, drum, …

But SoundFont are designed to be used with synthetizer or powerful computer. Midi Player Tool Kit converts SoundFont to a more simple format with not all the functionnalities of SoudFont but enough to play music to support application in Unity.

The FREE version of Midi Player Tool Kit use the SoundFont Chorium Rev A. It’s a sound font with a good balancing between size and quality.

Thousands SoundFonts are available on the web, often for free, the Full version is able to use another SoundFont and optimize the size of sound in your application.

Find SounfFonts here :

Tips : try General Midi SoundFont to get a large variety of instruments and a compatibility with Midi norm.

Quick Start

  1. Download Free MidiPlayer Tool Kit or Download Pro Midiplayer Tool Kit.
  2. Import Unity package in your Unity application, you will get something like picture below.

tips : Free version comes with a default SoundFont (ChoriumRevA) and some examples of midi files. Of course you can delete all Midi files and add your favorites (see Midi Player Tool Kit Setup below).



  1. Add to the hierarchy one or more « MidiFilePlayer » Prefab from « Asset/MidiPlayer/Prefab ». Each one can play a different Midi file.
  2. Check that you have an AudioListener component somewhere in your hierarchy, typically associated with the « Main Camera ».

Midi File Player Inspector

Select one Midi File Player in the hierarchy.

From the inspector :

  1. Select the Midi File to play. The Midi Files available are defined with the tool « Midi Player Toolkit ».  See below Setup Midi Player.
  2. Check ​ »Play On Start ».
  3. It’s over ! Run your Unity application, the Midi begins to play !

More advanced used with Midi File Player :

  • ​ »Play On Start » if checked, start playing when your application start.
  • « Pause with distance » if checked, pause playing if distance between MidiFilePlayer GameObject  and your AudioListener is greater than MaxDistance.
  • MaxDistance. If « Pause with distance » is checked, Midi playing is paused depending the distance. See below Audio Source Template
  • « Loop » if checked, restart playing automatically at end of the Midi file.
  • Quantization : define quantization to remove some imprecision in tempo. With quantization, notes are plays on beats or on fractions of beats.
  • « Enable Change » if checked, tempo change from the Midi are used (better to disable if you encounters some issues when playing).
  • « Transpose » transpose the music by half tone.
  • « Events » set events to trigger actions in your scripts at start/end playing.


Midi File Player Inspector in Mode Run

In Run Mode with the inspector you can Play / Pause / Stop / Restart the playing. It’s useful to quickly check your Midi file.


Advanced Use

Audio Source Template

Each MidiFilePlayer gameobject contains an AudioSource template. This audio source is used as a template to plays each sound in your Midi File Player.

You can customize it to adapts to your need. Picture below is the default configuration. Go to Unity documentation to understand how to use.

Tips :

  • By default Spatial Blend is set to 0, Set to a upper value to change volume accordingly with the distance to the Audio Listener and the Left/Right.
  • Define the MaxDistance to automatically pause playing midi when the distance with the AudioListener is greater than MaxDistance
  • Audio Source Template are created at run time when a new sound is need. So, change the template parameters at edit mode to be sure that change is taken in account.


Set-up Sound Font and Midi File

Go to the menu Tools and « Midi Player Tool Kit » to display the setup

There is 6 panels, 2 panels by rows, see screen capture below :

  1. Top : manage SoundFont (Pro version)
  2. Middle : manage your Midi Files (all version)
  3. Bottom : optimize SoundFont with your Midi Files (Pro version)

Panel SoundFont [Pro Version]

  • « Add SoundFont » : choose a SoundFont (filename of type .sf2) on your PC and load it in Midi Player ToolKit. You can select the banks to used :
    • Default bank for sound as Piano, Sax, Organ, Guitar. Often the first bank contains a well selected variety of instruments.
    • Drum Kit bank for drum sound. Often the last bank is dedicated to Drum Kit.
  • ​ »Select » : select the default SoundFont to use. Only one SoundFont can be selected at the same time.
  • « Remove » : delete the SoundFont and all sound associated to it

Tips: Free Version is published with the SoundFont « Chorium Rev A ». It’s a free sound font with a good balancing between size and quality.

Panel MidiFile [Free & Pro]

  • « Add Midi File » : Add a Midi File (filenam of type .mid) from your computer to Midi Player Tool Kit
  • « Analyse » : Read the Midi File and displays informations in the right panel : tempo, patch, copyright, …
  • « Remove » : delete the Midi File from the list

Tips : you can also directly imports a group of midi files in yout project : drag and drop Midi files into folders MidiPlayer\Assets\MidiPlayer\Resources\MidiDB. Next, you have to go to menu Tools and « Midi Player Tool Kit » to display the setup wich automatically add these new Midi files.

Panel Optimize [Pro Version]

  • Click on button « Analyse Midi Files » : each Midi Files in the list are analysed to detect patch and wave used. Patchs and waves not used are stripped from the SoundFont to reduce the size of your project. A more simple format of SoundFont is created.
  • « Keep all Zones » : if checked, all waves for selected patch are kept. It is useful if you want to transpose music when playing.
  • « Keep all Patchs » if checked, all patchs are kept in the SoundFont.

Integrate Midi Player in your script


Have Fun !

Laisser un commentaire