MIDI (Musical Instrument Digital Interface) is a standard protocol for inter-connecting computers with musical instruments, stage lighting, and other time-oriented media.

Strictly speaking, MIDI is unrelated to audio. But since MIDI is commonly used with music, this article is placed in the audio section.


The physical transport layer specified in original MIDI 1.0 is a current loop with 5-pin DIN connector.

Since MIDI 1.0, additional transports have been defined, including MIDI over USB and MIDI over Bluetooth Low Energy (BLE).

MIDI for Android

Android 3.1 and later support USB On-The-Go, which permits an Android device to act as USB host to drive USB peripherals. The USB host mode APIs introduced in Android 3.1 permit developers to implement MIDI over USB at the application level, but until recently there have been no built-in platform APIs for MIDI.

Beginning with the Android 6.0 (Marshmallow) release, device makers can enable optional MIDI support in the platform. Android directly supports USB, BLE, and virtual (inter-app) transports. Android indirectly supports MIDI 1.0 via an external adapter.

For details on application programming with the new MIDI APIs, see the android.media.midi package.

The remainder of this article discusses how an Android device maker can enable MIDI support in the platform.

Enabling transports

The implementation depends on ALSA for USB host mode and USB peripheral mode transports. ALSA is not used for the BLE and virtual transports.

USB host mode

To enable MIDI for USB host mode, first support USB host mode in general, and then enable CONFIG_SND_RAWMIDI and CONFIG_SND_USB_MIDI in your kernel configuration. See Android Kernel Configuration.

The MIDI over USB transport is formally defined by the Universal Serial Bus Device Class Definition for MIDI Devices Release 1.0 Nov 1, 1999 standard published by the USB Implementers Forum, Inc.

USB peripheral mode

To enable MIDI for USB peripheral mode, you may need to apply patches to your Linux kernel to integrate the drivers/usb/gadget/f_midi.c into the USB gadget driver. As of this writing, these patches are available for Linux kernel version 3.10. These patches have not yet been updated for ConfigFs (a new architecture for USB gadget drivers), nor are they merged at upstream kernel.org.

The patches are shown in commit order for the kernel tree at project kernel/common branch android-3.10:

  1. https://android-review.googlesource.com/#/c/127450/
  2. https://android-review.googlesource.com/#/c/127452/
  3. https://android-review.googlesource.com/#/c/143714/

In addition, the end user must also check the box for MIDI in the Settings / Developer options / Networking / Select USB Configuration dialog, or by pulling down from the top of screen while attached to the USB host, selecting entry "USB for ...", and then choosing MIDI.


MIDI over BLE is always enabled, provided the device supports BLE.

Virtual (inter-app)

The virtual (inter-app) transport is always enabled.

Claiming the feature

Applications can screen for the presence of MIDI support using the android.software.midi feature.

To claim MIDI support, add this line to your device.mk:


See the Android Compatibility Definition Document (CDD) for information on requirements to claim the feature.

Debugging while in host mode

While in USB host mode, Android Debug Bridge (adb) debugging over USB is unavailable. See section Wireless usage of Android Debug Bridge for an alternative.