The state of MIDI support on Android

The current state of Midi support on Android is depressing. They ripped out javax.sound.midi, so all libraries that depend on this are not working. (Things like JFugue for example).

Fortunately the MediaPlayer does support the playback of midi files. So if you want to have dynamic audio, you need to create your own midi file writing library, or find an existing one. Midi is quite an old beast, so it takes some effort to learn this. Fortunately there are lot of examples and info for the MIDI file format.

Android seems to use Sonivox for MIDI handling in the MediaPlayer. From what I understand it’s a embedded synthesizer that is integrated in Android. One of the things it support is the Jet file format. It’s some kind of wrapper around midi that you can use to “dynamically” playback music. It’s however totally depended on manually generated midi input that you need to edit on your PC to turn into the Jet format. So no pushing midi events to a stream or something like that. The only thing you can do is repeat sections and turn tracks on and off. Bummer.

So, currently on Android there is no way to dynamically generate realtime MIDI. We can’t simple send midi-commands to a synthesizer that then realtime plays it back.

However…. According to  the Sonivox EAS (Embedded Audio Synthesis) API Reference (found in the git tree of android), Sonivox does support Midi Streaming! That means that the low-level software stack of android does have the support for it. But it’s not exposed to us poor developers. I also don’t know if it’s possible to use the NDK to just use these C(++) API’s. I don’t have the C knowledge for that, and the NDK docs don’t mention them as supported/stable.

So, there may be a change that you can indeed use the C API’s, but that means you need to learn C/C++. Could be usefull, but well, why can’t we get it in Java in the SDK?

To resolve this I have opened a feature request on the google issue tracker to request for exposing these API’s in Java. If you are in any way interested in this feature, please leave a comment, star it, rate it, whatever it takes to let Google know that we need better MIDI support!

Now back to hacking.

Update
Personally I solved the dynamic midi generation issue as follows: programmatically generate a midi file, write it to the device storage, initiate a mediaplayer with the file and let it play. This is fast enough if you just need to play a dynamic midi sound. I doubt it’s useful for creating user controlled midi stuff like sequencers, but for other cases it’s great.

18 thoughts on “The state of MIDI support on Android”

  1. Yes, I have faced the same issue. I want to create an app involving midi control. In the previous version of Android SDK, it can have J2ME standard midi interface. So we can send the midi messages to Android’s embedded synthesizer at anytime. But the recent releases of SDK have removed this interface. Instead, they create the Jetplayer APIs to java programmer. Jetplayer is not really suitable to be used to build the musical game. Now I will try to build on NDK layer.

  2. You do realize that the NDK support for this is non-existing? I mean, it’s not stable.
    For me it’s too hard now, but I would really love to know if you indeed succeeded to implement it!

  3. Would you be willing to share the code you created for dynamically creating the midi file?

    Thx

  4. Hi Paul,

    I am not willing to share the final code, but I did try to find the online example for generating midi files that I used to create my own. Unfortunately I can’t find it anymore. Just search the internet for java and midi, it will probably give some usefull results and examples.

    Peter

  5. Vasos Panagiotopoulos

    I tried running my midi files on Android’s sound player and it thinks they are karaoke and fails. I am trying to find a midi player that is downloadable as an apk file off the web because I don’t have the ability to log in my android tablet just yet.

  6. All the android apps look and sound great but are just toys. all apps lack midi clock – to be useful to a musician in a live situation, you must be able to share master midi clock! pleaseeee sort it

  7. Pingback: Control MIDI with an Android device | CisforComputers

  8. I just got my first android tablet and I haven’t heard the synthesizer. What about its quality?

  9. Hi Peter,

    You wrote:

    > I solved the dynamic midi generation issue as follows:
    > programmatically generate a midi file, write it to the device
    > storage, initiate a mediaplayer with the file and let it play.

    I am hoping to do something very similar, but without success. I cannot get the MediaPlayer to recognize the MIDI file that I have created. I’ve posted a question about it here:

    http://stackoverflow.com/questions/26610223/get-android-mediaplayer-to-open-a-midi-file-saved-to-local-storage

    Perhaps you would be happy to let me how you did it differently so that you got it to work.

    Thanks in advance,

    James

  10. Can you please state which is the latest version of Android SDK that supports javax.sound.midi?
    Thanks

  11. Всем доброе время суток, что вы знаете о мастер-класса для женщин, просто заинтересовал этот вопрос. Так как недавно нашла информацию
    здесь
    Поэтому хочу понять, стоит ли брать?

Comments are closed.

Scroll to Top