Add Midi music to your Unity application

Play music in your Unity 3D games or applications from Midi files or from algo. Thank SoundFont for adding hundred sounds of instruments for playing Midi files.

SoundFont(R) is a registered trademark of E-mu Systems, Inc.

Want to start directly the journey? here a Quick start.

Otherwise, get a few information on this product:

  • Play music from Midi files in your Unity application without any C# or JS scripting.
  • Use powerful customs inspectors to define your musics.
  • Synchronize Midi events with your game or application.
  • Play generated music in your Unity application and reuse hundreds presets and waves extracted from SoundFont.
  • Add Midi Audio Source Prefab in your scene as much as you want.
  • Add Midi files (from the web or from your composition) as much as you want.
  • Play / Paused automatically based on distance.
  • Write Midi file by script.
  • Read Karaoke information.
  • Read Midi events from a Midi keyboard, play directly, or do anything that you want with the Midi events.
  • A full API is available to integrate MPTK in your application for more complex interactions.
  • Furthermore, all the source code is available! (except for reading Midi input).
  • Also, Prefab will help you to build your application:
    • Midi File Player: play music from a Midi file.
    • Midi Stream Player: create music from algo.
    • Midi File Loader: load a Midi file for analysis or processing purpose.
    • Pro version:
      • Midi Play List: play music from list of Midi files, overlap between Midi, play part of a midi, loop …
      • Midi External Player: playing a Midi directly from the Web or anywhere on the desktop.
      • Midi Input Reader: read Midi events from a Midi keyboard, play directly, or do anything that you want with the Midi events.

One way, prefab!

Many examples are available in the Unity package

Demonstrators has many roles: help us for regression test, demonstration, example of scripts. Have a look !

  • TestMidiFilePlayer: a very simple example with only one MidiFilePlayer prefab to play Midi music. An example of using MPTK to play Midi music without programming. There is no script !
  • TestMidiFilePlayerScripting: how to integrate MPTK by script in your application. Example of a a Karaoke like application. Use of the MPTK API with a few lines of code.
  • TestMidiLoader: a simple Midi loader able to display the Midi events.
  • TestMidiFilePlayerMulti: four MidiFilePlayer prefabs are defined on a scene with the camera moving on each to experiment the “Playing on distance” function.
  • TestMidiStreamSimple: how to generate music without any Midi files with a few lines of code.
  • CatchMusic: Midi is read from a MidiFilePlayer but playing music is delayed in time, thank to the MidiStreamPlayer. Could become a game !
  • Pro Version:
    • Play External Midi: Midi is loaded directly from your desktop or from a web site.
    • TestMidiPlayList: demonstration of the prefab MidiListPlayer able to play a list of Midi files with overlap and loop inside a Midi itself.
    • TestMidiWriter: Four methods to create and write a Midi file with MPTK. Contains also a light music sequencer.
    • TestMidiInReader: wait and play Midi events from a Midi keyboard connected to your computer. Use of the MPTK API with a few lines of code.
    • EuclideanRhythm: The Euclidean rhythm in music was discovered by Godfried Toussaint in 2004 and is described in a 2005 paper “The Euclidean Algorithm Generates Traditional Musical Rhythms”. An impressive Rhythm Box. It’s a demonstration, but a lot of potential for a more complex application!

Have a look to the main demonstration scene to an easy access on each demos. Load and run this scene: Scenes For Demo/ScenesDemonstration

Warning: To avoid interacting with your project, MPTK doesn’t add MPTK scenes in the Build Settings. Add the MPTK scenes with “File/Build Settings” if you want a full functionality of the demonstrator.

Free or Pro version ?

Play Midi Music (Midi File)XX
Play Generated Music (Midi Stream)XX
Play / Paused automatically on distance, on focus lostXX
Loop, transpose, quantization, start play at first note, change position, speedXX
Load Midi fileXX
API for a full integration in your scriptXX
Midi File Writer X
Play External Midi File X
Midi Play List and Loop inside X
Midi Input Reader from an external Midi keyboardX
Import and manage several SoundFonts and optimize samples count X
Load SoundFont on the fly from a local file or from the web X

Obviously, even if you don’t have the need of the Pro function, you can also bought it 😉 It’s a lot of work. Please, help us to maintain this application with a professional behaviors !!!

Also: Play Music Without Midi File

Generate your music from your own algorithm by using hundreds waves extracted from SoundFont. Of course, a pitch effect is added to waves to adapt notes frequency. Some examples are provided to explain how to. Have a look to : TestMidiStreamSimple.

For more information see Class MidiPlayerTK.MidiStreamPlayer. More information about integrating MPTK in your script here.


There is no extra DLL or binary (except for reading Midi input), all the source code of MPTK is available (C#). Consequently, there is some functions not available on some devices. See here.

Example of integration with MPTK

Midi File Player Advanced

Write Midi File (Pro)

Generated Midi

Catch Music (simplified design with MPTK asset)

Rhythm Box