These types of apps are especially useful on Android because of how easy it is to use Android as a USB-MIDI device. ​

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.

Android's MIDI setting is shown when it's connected to a USB host

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.

A Pixel XL in USB-MIDI mode connected to MacOS shows as a 1-in/1-out MIDI device

Inside the app the MIDI device will show up as "Android USB Peripheral" with a single input port and a single output port.

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:

JVM Midi

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.

Pros

Available on over 60% of all Android devices (correct as of July 10th 2019)

Cons

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.

Native Midi

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.

Pros

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

Cons

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

Getting Started

You can start developing a MIDI app using Android Studio. You'll want to check out the following resources: