In this document
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.
Since MIDI 1.0, additional transports have been defined, including MIDI over USB and a proposed draft for 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, draft 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
The remainder of this article discusses how an Android device maker can enable MIDI support in the platform.
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
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
(a new architecture
for USB gadget drivers), nor are they merged at upstream
The patches are shown in commit order for the kernel tree at project
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. As this transport is in draft status, it is subject to change.
The virtual (inter-app) transport is always enabled.
Claiming the feature
Applications can screen for the presence of MIDI support using the
To claim MIDI support, add this line to your
PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.software.midi.xml:system/etc/permissions/android.software.midi.xml
See the Android Compatibility Definition Document (CDD) for information on requirements to claim the feature.