Can Android play MIDI?

What is MIDI?

MIDI stands for Musical Instrument Digital Interface. As explained on TechTarget, “MIDI is a technical standard that describes a protocol, digital interface, and connectors that allow a wide variety of electronic musical instruments, computers, and other equipment to connect and communicate with each other.”

MIDI allows connecting and controlling synthesizers, sequencers, music workstations, drum machines, and more. As the Wikipedia article on MIDI notes, members of the USB-IF in 1999 developed a standard for MIDI over USB, known as the “Universal Serial Bus Device Class Definition for MIDI Devices.” This expanded the connectivity options for MIDI devices.

In summary, MIDI is an essential communication standard and protocol that enables various digital music devices and software to connect, communicate, and synchronize with each other.

Brief History of MIDI

MIDI (Musical Instrument Digital Interface) was developed in the early 1980s to standardize communication between electronic music devices from different manufacturers. While various proprietary electronic interfaces existed previously, MIDI provided a common standard that allowed different devices to connect and communicate with one another. This enabled synchronization and remote control between devices from different companies.

The first MIDI synthesizers were released in 1983 by Sequential Circuits and Oberheim (The History Of MIDI). These early synths adopted the new MIDI 1.0 Specification which defined the MIDI message structure and protocols. MIDI adoption grew quickly through the 1980s as more manufacturers incorporated MIDI inputs and outputs into their instruments and devices. By the late 1980s, MIDI had become an essential industry standard interface for electronic music and remains ubiquitous today.

How MIDI Files Work

MIDI files contain commands that electronic instruments and software can interpret as musical notation to play back. Unlike audio files like MP3s or WAVs, MIDI files do not contain actual audio data, only messages like note on/off, pitch, velocity, and other performance instructions. The small size of MIDI files allows them to be easily stored, edited, and transmitted.1

When a MIDI file is loaded into a digital audio workstation (DAW) or other music software, it triggers sounds from an instrument plugin or external MIDI device based on the MIDI messages. For example, a MIDI note-on command with a pitch of middle C will make a MIDI keyboard or software synthesizer play a middle C tone. The MIDI file itself does not contain that actual middle C sound, just the instructions for the instrument to play it.

This makes MIDI files very compact and portable, while retaining all the musical information of a composition. MIDI files can be easily edited to change tempo, key, instruments, and notes. The small file size also allows MIDI files to be downloaded, shared online, and used in mobile apps more efficiently than audio files.

Playing MIDI Files on Android

The open nature of Android allows easily installing MIDI apps from the Google Play store (https://www.larkplayer.com/resource/audio-format/midi-player.html). Many MIDI player apps are available such as MIDI Player, FluidSynth MIDI Player, midomi Player, etc.

High quality MIDI playback requires downloading synthesizer ‘soundfont’ files. The best MIDI sounds are GM (General MIDI) soundfonts created by sound designers specifically for MIDI playback. Popular GM soundfonts include FluidR3_GM.sf2, Roland SC-88.sf2, and Yamaha XG.sf2 which recreate the original sounds of those synthesizers (https://www.larkplayer.com/resource/audio-format/midi-player-for-android.html). After downloading to local storage, MIDI apps can access the soundfonts to render high fidelity audio from MIDI files.

Built-in Android MIDI Support

Android has included built-in support for MIDI since version 3.0 (Honeycomb) which was released in 2011 [1]. The Android MIDI API allows apps to generate and respond to MIDI messages, communicating with MIDI devices connected via USB or Bluetooth. This API is part of the Android media framework and allows apps to enumerate connected MIDI devices, send and receive MIDI messages, and register for callbacks when MIDI events occur.

For lower level access, Android’s Native Development Kit (NDK) includes a native MIDI library that developers can use to integrate MIDI functionality directly into their apps [2]. The native MIDI API provides improved performance and latency compared to using the Java MIDI API. Apps that require precise timing like musical instruments, sequencers, and DJ software benefit from using the native MIDI interface.

Using MIDI Controllers and Keyboards

Connecting a hardware MIDI controller or keyboard to Android requires a USB host mode adapter. Many keyboards or MIDI controllers connect via USB, but Android does not support USB host mode by default. An OTG (On-The-Go) adapter allows connecting USB devices to Android. The adapter has a USB-A port to connect the keyboard, and a micro-USB connector to plug into the Android device.

Some Android devices have built-in USB host mode support to connect MIDI devices. For example, the Samsung Galaxy S7 and newer models can connect MIDI controllers directly via the USB port and adapters are not required. Check your device specifications to see if it supports USB host mode.

For high quality MIDI playback, an external USB audio interface and synthesizer provides lower latency than the built-in Android audio. There are USB audio interfaces made specifically for connecting to Android devices via OTG cable, which then allows connecting studio headphones and MIDI instruments.

Sources:
https://musicianshq.com/connect-a-midi-keyboard-to-an-android-device/
https://help.flowkey.com/en/articles/412902-connect-your-instrument-to-your-android-device

Latency Considerations

Latency is the delay between playing a note and hearing the sound. This is especially important for musical instruments like keyboards that rely on real-time feedback. Android’s latency is generally higher than dedicated audio platforms like iOS or Windows/Mac.

Typical latency on Android devices ranges from 200-300 milliseconds, but can vary significantly between different devices and Android versions. As this Reddit discussion notes, MIDI input latency is very low at around 1ms. However, the overall latency from playing a note to hearing audio output is much higher.

Higher latency makes it challenging to play instruments in real-time on Android. However, there are some techniques to optimize latency by using professional audio apps, USB/MIDI keyboards, and reducing background processes. Choosing devices with the newest Android versions and powerful processors can also help minimize latency.

Using MIDI with Music Apps

Many Android music making apps support importing/exporting MIDI files. Popular options include Caustic 3 (https://www.iconnectivity.com/blog/2020/8/13/android-music-making-apps-our-pick-of-the-best), FL Studio Mobile, Audio Evolution Mobile Studio, etc. MIDI data enables powerful editing features in these digital audio workstations. Users can create intricate melodies, chord progressions, and drum patterns with MIDI controllers or the touchscreen piano roll editor.

Conclusion

MIDI file playback has been possible on Android since early versions of the operating system. The inclusion of the OpenSL ES API in Android provided low-level access to audio and MIDI, enabling apps to play back MIDI files. Dedicated MIDI player apps like MIDI Player utilize this API to provide a seamless MIDI playback experience.

Furthermore, Android’s native support for the MIDI protocol means connecting external keyboards via MIDI over USB is plug-and-play. Using a digital piano or MIDI controller with an Android device is straightforward with the right apps and adapters.

However, for professional music production, external MIDI hardware and optimizations for lower latency are recommended. The native Android system incurs some latency when processing MIDI data, so pro musicians may want to use a third-party audio engine or rooted device optimizations for best results.

Overall, MIDI file playback and MIDI hardware connectivity have been core parts of the Android ecosystem since the beginning. Between built-in OS support, third-party apps, and accessories, Android provides a capable platform for casual and professional MIDI use alike.

References

The information in this article was compiled using the following key sources:

Leave a Reply

Your email address will not be published. Required fields are marked *