Search code examples
androidunity-game-enginemidi

Read Midi File using Unity3D on Android


I am developing a Unity3D app to be deployed on Android. I need to read midi files (preferrably as .midi, but other endings would be fine too) and play them (get the parsed note events at the correct timing). Actual sound is not a priority.

It is also very important for me to be able to change the tempo.

Can you recommend a framework/ plugin/ code for this?

All the stuff i found does not work on Android, regarding C#SynthProject i could not figure out how to change the tempo.


Solution

  • Getting the sound is somewhat problematic (as you have noticed) as you need to emulate hardware chip that used to do the GeneralMIDI synthesis in some form or another, that is no longer commonly mounted anywhere (even windows emulates this internally), but midi file format (also known as StandardMidiFile aka SMF) files themselves are fairly well documented standard and are not terribly complex (although two non-compatible variants are a pain sometimes)

    While writing own .MID file parser is probably a lot of fun, I can recommend using this piece of code dated 2013, written by our Unity god - Keijiro Takahashi

    https://github.com/keijiro/smflite