Skip to content

The state of MIDI support on Android

by peterdk on May 7th, 2010

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.

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.

From → Android, Java

  1. byron permalink

    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. peterdk permalink

    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. Paul permalink

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


  4. peterdk permalink

    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.


  5. Paul permalink

    Thanks for the response.


  6. Vasos Panagiotopoulos permalink

    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.

  7. 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

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

  9. peterdk permalink

    Try my app Mini Piano Lite to hear the standard midi sounds.

  10. This page still turns up high on google, when looking for android and midi. So I thought this might be useful:

    It’s an open source implementation of a midi player, with visualisation by keyboard and sheet music. The code for android is free for download.

  11. tsukihuu permalink
    this page can not open in my conputer. can you send me a copy of the code?

  12. James Newton permalink

    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:

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

    Thanks in advance,


  13. Ziad permalink

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

  14. peterdk permalink

    As far as I know, there is none.

  15. lgong permalink

    you can use android NDK send midi cmd
    you can find such code in github

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

  17. Stephenloala permalink

    Amazing website, how do u find all this info?I have read a few articles on your site and I love your writing style. Thanks a million, keep up the great work.

  18. United Steel Industries is a new Rolling Mill in Fujairah. USI is incorporated in 140,000 square meters of land. The plant will produce bar and wire rod products for civil construction. The rolling mill project was designed in 2005 by Germany’s concern SIEMENS – VAI ( SVAI ). Our mill capacity is 1.1 MTPA producing wire rods and Rebar’s.

    Steel abu dhabi

  19. The winner is determined in which the little ball stops. Some added bonus codes will even give you installments each and every time you score some quantity of points. This means raising small amounts or simply just calling or checking.

  20. Clydewhods permalink

    Всем привет !!!

    Скажем так, я не отличаюсь отличной внешностью и прямо Скажем красотой. Хочу поставить брекеты. Это реально?? поможет??? Хотя бы если выровнеть зубы не буду настолько урод. внешностью у меня отталкивает людей, Это правда. ФОто прилагать не буду. Просто вопрос. Насколько вы обращаете внимание на зубы человека при знакомстве? У меня зубы торчат сильно вперед и как-то не стыкуются между собой. Вас бы Это оттолкнуло???

  21. If you wish to return completely house to your husband and children, you can ask housemaid solution NYC to routinely perform an extra package of services, such as:
    Pet care;
    Acquisition of home chemicals and also products;
    Repayment of energy expenses;
    Sprinkling home blossoms;
    Putting order inside the closets – you yourself state house cleaning service NY, what, where as well as in what order you require to put it.

    Counting on us, you can be certain that our maid solution NY is an staff member with long-term residence and living in New York City, who will professionally cleanse the apartment or condo as well as satisfy all family tasks.
    We abide by the regulations, consequently we do not admit to the staff of our company persons that are not registered in the nation. house cleaning service NY who are not people of our state can not work in our firm.
    The maids nj NY residence service is CHEAP!

    All you require to do in order to invite the maid to your house is to leave a demand to our phone managers. Afterwards, cleanliness and also order will resolve in your home!

    Top notch house chemicals as well as technological tools that is required for cleansing, our inbound housemaid, and also currently you’re assistant will bring with her.
    All maids strictly observe confidentiality as well as understand the guidelines as well as standards of habits and communication in the family with the employer. They are constantly accountable and also exec.

    Order the services of a caretaker! Rid on your own of tiring research as well as require time on your own and also your enjoyed ones!

  22. Здравствуйте,
    возникла такая вопрос , полагается найти музыку для
    заставки для презентацию пиццерии, всегда качаю здесь –

    скачать музыку в хорошем качестве однако может у кого то столоваться еще варианты
    Буду весьма благодарен!

Trackbacks & Pingbacks

  1. Control MIDI with an Android device | CisforComputers

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS