Glenn Kasten | 806a68c | 2015-05-21 13:03:49 -0700 | [diff] [blame] | 1 | page.title=MIDI |
| 2 | @jd:body |
| 3 | |
| 4 | <!-- |
| 5 | Copyright 2015 The Android Open Source Project |
| 6 | |
| 7 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | you may not use this file except in compliance with the License. |
| 9 | You may obtain a copy of the License at |
| 10 | |
| 11 | http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | |
| 13 | Unless required by applicable law or agreed to in writing, software |
| 14 | distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | See the License for the specific language governing permissions and |
| 17 | limitations under the License. |
| 18 | --> |
| 19 | |
| 20 | <div id="qv-wrapper"> |
| 21 | <div id="qv"> |
| 22 | <h2>In this document</h2> |
| 23 | <ol id="auto-toc"> |
| 24 | </ol> |
| 25 | </div> |
| 26 | </div> |
| 27 | |
| 28 | <p> |
| 29 | <a href="http://en.wikipedia.org/wiki/MIDI">MIDI</a> (Musical Instrument Digital Interface) |
| 30 | is a standard protocol for inter-connecting computers with musical instruments, stage lighting, |
| 31 | and other time-oriented media. |
| 32 | </p> |
| 33 | |
| 34 | <p> |
| 35 | The physical <a href="http://en.wikipedia.org/wiki/Transport_layer">transport layer</a> |
| 36 | specified in original MIDI 1.0 is a current loop with |
| 37 | <a href="http://en.wikipedia.org/wiki/DIN_connector">5-pin DIN</a> connector. |
| 38 | </p> |
| 39 | |
| 40 | <p> |
| 41 | Since MIDI 1.0, additional transports have been defined, including MIDI over USB |
| 42 | and a proposed draft for MIDI over |
| 43 | <a href="http://en.wikipedia.org/wiki/Bluetooth_low_energy">Bluetooth Low Energy</a> (BLE.) |
| 44 | </p> |
| 45 | |
| 46 | <p> |
| 47 | Strictly speaking, MIDI is unrelated to audio. But since MIDI is commonly used with |
| 48 | music, this article is placed in the audio section. |
| 49 | </p> |
| 50 | |
| 51 | <h2>MIDI for Android</h2> |
| 52 | |
| 53 | <p> |
| 54 | Android 3.1 and later support |
| 55 | <a href="http://en.wikipedia.org/wiki/USB_On-The-Go">USB On-The-Go</a>, |
| 56 | which permits an Android device to act as USB host to drive USB |
| 57 | peripherals. The USB host mode APIs introduced in Android 3.1 permit |
| 58 | developers to implement MIDI over USB at the application level, but until |
| 59 | recently there have been no built-in platform APIs for MIDI. |
| 60 | </p> |
| 61 | |
| 62 | <p> |
| 63 | Beginning with the Android M release, device makers can enable optional MIDI support in the platform. |
| 64 | Supported transports include USB, draft BLE, and virtual (inter-app). |
| 65 | </p> |
| 66 | |
| 67 | <p> |
| 68 | For details on application programming with the new MIDI APIs, see the |
| 69 | <a href="https://android-preview.googleplex.com/reference/android/media/midi/package-summary.html">android.media.midi</a> |
| 70 | package. |
| 71 | </p> |
| 72 | |
| 73 | <p> |
| 74 | The remainder of this article discusses how an Android device maker can |
| 75 | enable MIDI support in the platform. |
| 76 | </p> |
| 77 | |
| 78 | <h2>Enabling transports</h2> |
| 79 | |
| 80 | <h3>USB host mode</h3> |
| 81 | |
| 82 | <p> |
| 83 | To enable MIDI for USB host mode, first support USB host mode in general, and |
| 84 | then enable <code>CONFIG_SND_RAWMIDI</code> in your kernel configuration. |
| 85 | </p> |
| 86 | |
| 87 | <h3>USB peripheral mode</h3> |
| 88 | |
| 89 | <p> |
| 90 | To enable MIDI for USB peripheral mode, you may need to apply patches |
| 91 | to your Linux kernel to integrate the |
| 92 | <code>drivers/usb/gadget/f_midi.c</code> into the USB gadget |
| 93 | driver. As of this writing, these patches are available for Linux kernel version |
| 94 | 3.10. These patches have not yet been updated for |
| 95 | <a href="http://en.wikipedia.org/wiki/Configfs">ConfigFs</a> |
| 96 | (a new architecture |
| 97 | for USB gadget drivers), nor are they merged at upstream |
| 98 | <a href="http://kernel.org"</a>kernel.org</a>. |
| 99 | </p> |
| 100 | |
| 101 | <p> |
| 102 | The patches are shown in commit order for the <code>tegra</code> tree: |
| 103 | </p> |
| 104 | <ol> |
| 105 | <li><a href="https://android.googlesource.com/kernel/tegra/+/261230ce54cfc119efe643fc1d128e431d1678d3"</a>261230ce54cfc119efe643fc1d128e431d1678d3</a></li> |
| 106 | <li><a href="https://android.googlesource.com/kernel/tegra/+/3f048135f3028e503d9d6e32b602e362bd9f374f"</a>3f048135f3028e503d9d6e32b602e362bd9f374f</a></li> |
| 107 | <li><a href="https://android.googlesource.com/kernel/tegra/+/ae2019d83ecf14454315240c16dc3136212f0da2"</a>ae2019d83ecf14454315240c16dc3136212f0da2</a></li> |
| 108 | </ol> |
| 109 | |
| 110 | <p> |
| 111 | In addition, the end user must also check the box for MIDI |
| 112 | in the <em>Settings</em> dialog for <em>Select USB configuration</em>, |
| 113 | or by pulling down from the top of screen while attached |
| 114 | to the USB host, and choosing <strong>MIDI</strong> for "Use USB for ...". |
| 115 | </p> |
| 116 | |
| 117 | <h3>BLE</h3> |
| 118 | |
| 119 | <p> |
| 120 | MIDI over BLE is always enabled. |
| 121 | As this transport is in draft status, it is subject to change. |
| 122 | </p> |
| 123 | |
| 124 | <h3>Virtual (inter-app)</h3> |
| 125 | |
| 126 | <p> |
| 127 | The virtual (inter-app) transport is always enabled. |
| 128 | </p> |
| 129 | |
| 130 | <h2>Claiming the feature</h2> |
| 131 | |
| 132 | <p> |
| 133 | Applications can screen for the presence of MIDI support using the |
| 134 | <code>android.software.midi</code> feature. |
| 135 | </p> |
| 136 | |
| 137 | <p> |
| 138 | To claim MIDI support, add this line to your <code>device.mk</code>: |
| 139 | </p> |
| 140 | <pre> |
| 141 | PRODUCT_COPY_FILES += \ |
| 142 | frameworks/native/data/etc/android.software.midi.xml:system/etc/permissions/android.software.midi.xml |
| 143 | </pre> |
| 144 | |
| 145 | <p> |
| 146 | See the |
| 147 | <a href="{@docRoot}compatibility/android-cdd.pdf">Android Compatibility Definition Document (CDD)</a> |
| 148 | for information |
| 149 | on requirements to claim the feature. |
| 150 | </p> |
| 151 | |
| 152 | <h2 id="hostDebugging">Debugging while in host mode</h2> |
| 153 | |
| 154 | <p> |
| 155 | While in USB host mode, Android Debug Bridge (adb) debugging over USB is unavailable. |
| 156 | See section <a href="http://developer.android.com/tools/help/adb.html#wireless">Wireless usage</a> |
| 157 | of |
| 158 | <a href="http://developer.android.com/tools/help/adb.html">Android Debug Bridge</a> |
| 159 | for an alternative. |
| 160 | </p> |