Musical Instrument Digital Interface (MIDI) is a standard protocol for interconnecting computers with musical instruments, stage lighting, and other time-oriented media.
Starting in Android 13, MIDI 2.0 support is added to the USB transport. MIDI 2.0 is a newer MIDI standard defined in 2020. This protocol adds features such as two-way communication, higher resolution and property exchange. MIDI 2.0 through USB host mode is always enabled when MIDI support is enabled on the platform.
Strictly speaking, MIDI is unrelated to audio. But because MIDI is commonly used with music, this article is placed in the audio section.
MIDI for NDK
Android 10 makes it easier to port professional audio apps using MIDI to the Android platform.
Android MIDI apps usually use the
midi API to communicate with the Android MIDI service. MIDI
apps primarily depend on the
MidiManager class to discover, open, and close one or more
objects, and pass data to and from each device through the device's MIDI input and output ports.
Since MIDI 1.0, additional transports have been defined, including MIDI over USB and MIDI over Bluetooth Low Energy (BLE).
MIDI for Android
Android supports USB On-The-Go, which permits an Android device to act as a USB host to drive USB peripherals. The USB host mode APIs 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 (interapp) transports. Android supports MIDI 1.0 through an external adapter.
For details on application programming with the MIDI APIs, see the
The remainder of this article discusses how an Android device maker can enable MIDI support in the platform.
Enabling MIDI 1.0 transports
MIDI 1.0 implementation depends on ALSA for USB host mode and USB peripheral mode transports. ALSA isn't 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
drivers/usb/gadget/f_midi.c into the USB gadget
driver. 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
You also need to do either of the following:
- Go to Settings > Developer options > Networking and check the box for MIDI in the Select USB Configuration dialog.
- While attached to the USB host, pull down from the top of screen, select the entry USB for, and then select MIDI.
MIDI over BLE is always enabled, provided the device supports BLE.
The virtual (interapp) transport is always enabled.
Claiming the feature
Apps 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.
Debugging while in host mode
While in USB host mode, Android Debug Bridge (adb) debugging over USB is unavailable. See the Wireless usage section of Android Debug Bridge for an alternative.