About Android MIDI
In 2015 Android introduced MIDI support. Android has billions of users which means there's a whole lot of people with MIDI compatible devices in their pocket!
In this article I'll explore the most popular types of MIDI applications on Android and how to choose the right MIDI API when developing your own app.
Common types of MIDI app
The two most popular types of MIDI app are:
1) Apps controlled by MIDI. These are apps which primarily receive MIDI data, such as synthesizers, drum machines and DJing apps.
2) MIDI controller apps. These apps are used to control other apps, external hardware or external software (such as a desktop audio workstation).
Apps controlled by MIDI
The virtual analog synthesizer app, DRC can be played using an external MIDI keyboard
MIDI controller apps
These types of apps are designed to control other apps by sending MIDI to them. Examples include:
- Using the phone's touch screen as an X-Y pad which sends MIDI Control Change messages
- Using the phone's accelerometer to send MIDI pitch bend information
- Step sequencing and piano roll apps
Super MIDI Box is a MIDI drum machine and step sequencer
Android as a USB-MIDI device
A little-known feature of Android is that when connected to a USB host (like a computer) it can become a class compliant USB-MIDI device. This is done in the USB settings.
Once the USB mode is changed to MIDI, it will appear on the host as a MIDI device with one input channel and one output channel. A MIDI controller app can then be used to control software, such as a Digital Audio Workstation (DAW), on the host.
Inside the app the MIDI device will show up as "Android USB Peripheral" with a single input port and a single output port.
DRC app connected to the Android USB Peripheral MIDI device
Android's MIDI APIs
In order to develop a MIDI application on Android you'll need to use one or both of the available MIDI APIs. Here's a summary of the available APIs and their features:
In Android Marshmallow (API 23) the JVM Midi API was released. It can be accessed using Kotlin or the Java Programming Language. It enables you to enumerate, connect and communicate with MIDI devices over USB, Bluetooth LE and other apps advertising as virtual MIDI services.
- Available on over 60% of all Android devices (correct as of July 10th 2019)
- Sending MIDI messages to C/C++ code requires use of JNI which can introduce complexity due to multi-threading
- MIDI data only available through callback mechanism
You must use this API for enumerating and connecting to MIDI devices, however, for reading and writing you can choose between this API and the Native Midi API described below.
In Android Q the Native MIDI API was released. It's specifically designed for communicating with MIDI devices inside an audio callback which makes it easy to control audio rendering objects, for example a software synthesizer.
This API only handles sending and receiving MIDI data, not MIDI device enumeration or connection. That still needs to be done using the JVM API.
- Easy to integrate with existing C and C++ code
- Best possible latency
- MIDI data can be received and sent inside an audio callback without blocking
- Still need to enumerate and connect to MIDI devices in Kotlin or the Java Programming Language using the JVM MIDI API
- Only available on Android Q and above
You can start developing a MIDI app using Android Studio. You'll want to check out the following resources:
You should also take a look at the existing MIDI apps on the Google Play Store.
If you are using audio in your app you might want to check out the Oboe library for developing high performance audio apps.
If you have questions about developing MIDI apps on Android feel free to ask them on the android-midi group. Good luck and have fun!