自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
MIDI 測試程序
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
這些測試可用於驗證 Android 裝置上的 MIDI 功能。成功執行這些測試是聲明 MIDI 功能的必要條件。
準備
硬體
進行測試時需要下列硬體。
- 內含 USB 連接器的 MIDI 鍵盤
- 支援藍牙低功耗 (BLE) 的 MIDI 鍵盤
- USB 傳輸線
- USB On-The-Go (OTG) 轉接器,可將 USB-A 母端轉換為 micro-USB 或 USB-C 公端
- 搭載 Android 6.0 (Marshmallow) 以上版本的 Android 裝置
- 選用:桌上型電腦
多個 MIDI 鍵盤都支援 USB 和 BLE-MIDI,因此您只需使用一個鍵盤即可進行測試。例如 Akai LPK25 Wireless 和 Korg Microkey Air。
應用程式
這個測試程序會使用多個應用程式。您可以在 GitHub 專案 android-midisuite 的來源碼中取得這些應用程式,也可以透過 Google Play™ 的下列連結下載。
如果您選擇使用原始碼進行作業,而非透過 Google Play™ 安裝,請先使用提供的 Android.mk 建構應用程式。接著,使用 Android Debug Bridge (ADB) 安裝應用程式。舉例來說,如要安裝 MidiScope 應用程式,請按照下列步驟操作:
- 使用已安裝 ADB 的工作站。
- 將工作站的 USB 傳輸線連接至 Android 裝置。
- 您可能需要允許 Android 裝置上的 USB 連線;請參閱「USB 周邊裝置模式」
- 在工作站上輸入:
cd THIS_FOLDER
adb install -r MidiScope.apk
虛擬合成器測試
請注意,MIDI 輸入埠只能有一個連線。因此,如果其他應用程式已使用輸入埠,該埠就無法使用。如果無法連線至輸入埠,請嘗試關閉其他應用程式。
所需硬體:測試中的 Android 裝置
簡單連線
所需應用程式:MidiKeyboard、MidiSynthExample
這項測試會測試裝置列舉、虛擬裝置、通訊埠連線和訊息傳送。
- 將 Android 裝置的音量調到約一半。
- 將手機轉為橫向模式。
- 啟動 MidiKeyboard 應用程式。
- 從旋轉圖示選單中選取「SynthExample」。
- 播放按鍵。您應該會在 SynthExample 應用程式中聽到音符播放的聲音。
- 按下「返回」按鈕退出應用程式,這樣才能關閉連接埠。
USB 測試:主機模式
所需硬體:USB MIDI 鍵盤、USB 傳輸線、OTG 轉接器
重複進行這些測試幾次。我們發現,如果裝置插拔幾次,USB 堆疊就會在某些原型裝置上當機。
鍵盤已插入
所需應用程式:MidiSynthExample 或 MidiScope
這項測試會在主機模式下測試 USB MIDI。
- 將 Android 裝置的音量調到約一半。
- 使用 OTG 轉接器接上 USB 鍵盤。
- 啟動 SynthExample 或 MidiScope 應用程式。
- 從選單中選取 USB 鍵盤。系統會顯示品牌。
- 在鍵盤上播放音符。如果您執行 SynthExample,應該會聽到手機播放的音符。如果您執行 MidiScope,畫面上應該會顯示 NoteOn 和 NoteOff 訊息。
- 拔除鍵盤。「Sender for Synth」選單應顯示「- - - - -」。
- 按下「返回」按鈕即可退出應用程式。
熱插 USB 鍵盤
所需應用程式:MidiSynthExample 或 MidiScope
這項測試會在主機模式下測試 USB MIDI。
- 將 Android 裝置的音量調到約一半。
- 確認沒有插入 USB MIDI 鍵盤。
- 啟動 SynthExample 應用程式。
- 在畫面中間的「Sender for Synth」旁,查看選單。你應該不會看到 USB 鍵盤。
- 使用 OTG 轉接器接上 USB 鍵盤。
- 在「Sender for Synth」旁,選取 USB 鍵盤。並顯示品牌。
- 在鍵盤上播放音符。你應該會聽到手機播放的音符。
- 在「Synth 傳送端」旁,選取「- - - - -」。
- 在鍵盤上播放音符。你應該不會聽到任何聲音。
- 在「Sender for Synth」旁,選取 USB 鍵盤。並顯示品牌。
- 在鍵盤上播放音符。你應該會聽到手機播放的音符。
- 拔除合成器的電源線。「Sender for Synth」選單應顯示「- - - - -」。
- 按下「返回」按鈕即可退出應用程式。
USB 測試:周邊模式
所需硬體:USB 傳輸線、OTG 轉接器
Android 到 Android
所需應用程式:測試中的 Android 裝置上有 MidiKeyboard,另一部 Android 裝置上有 MidiScope。
將 Android 裝置做為其他 Android 裝置的周邊控制器。如要測試這個模式,請使用另一部以主機模式運作的 Android 裝置。請注意,您可以修改測試,讓測試與執行數位音訊工作站 (DAW) 軟體 (例如 GarageBand) 的電腦搭配使用。
- 將 USB 傳輸線連接至測試中的 Android 裝置 (Android 裝置 A)。
- 使用 OTG 轉接器,將傳輸線的另一端連接至以主機模式運作的第二部 Android 裝置 B。
- 在 Android 裝置 A 上:
- 從螢幕頂端向下滑動手指。
- 選取「USB 充電」圖示。
- 選取「MIDI」。
- 啟動 MidiKeyboard 應用程式。
- 在頂端的「Receiver for Keys」選單中,選取「Android USB Peripheral Port」。
- 在 Android 裝置 B 上:
- 啟動 MidiScope 應用程式。
- 選取其他 Android 裝置做為來源。
- 在 Android 裝置 A 上:
- 在鍵盤上播放音符,然後在 Android 裝置 B 上尋找 NoteOn 和 NoteOff。
BLE 測試
所需硬體:支援 BLE 的 MIDI 鍵盤
基本配對和播放
所需應用程式:MidiBtlePairing、MidiSynthExample
測試透過 BLE 連接至 Android 的鍵盤。
- 重新啟動 Android 裝置。
- 開啟 BLE 鍵盤。
(如要開啟 Miselu C.24 鍵盤,請按下背面附近的按鈕,讓鍵盤彈開。在配對模式下,C.24 的電源按鈕會閃爍藍光)。
- 啟動 MidiBtlePairing 應用程式。該應用程式有 MIDI+BTLE 圖示。
- 按下「藍牙掃描」按鈕。
- 選取所需的 BLE 周邊裝置。
- 應用程式應會返回主頁面,您應該會看到周邊裝置的清單。如果你使用的是 C.24,你會發現 C.24 上的燈號會變成綠色,表示已進入配對模式。
- 請按下「主畫面」按鈕,而不是「返回」按鈕,才能退出應用程式。
- 啟動 SynthExample 應用程式。
- 從選單中選取 BLE 鍵盤做為傳送端。
- 您應該可以按下 BLE 鍵盤上的按鍵,並在 Android 上聽到音符。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-03-26 (世界標準時間)。
[null,null,["上次更新時間:2025-03-26 (世界標準時間)。"],[],[],null,["# MIDI test procedure\n\nThese tests may be used to validate the MIDI feature on Android devices.\nSuccessful execution of these tests is a prerequisite to\n[claim the MIDI feature](/docs/core/audio/midi#claim-feature).\n\nPreparation\n-----------\n\n### Hardware\n\n\nThe following hardware is needed for the tests.\n\n- MIDI keyboard with USB connector\n- MIDI keyboard with Bluetooth Low Energy (BLE) support\n- USB cables\n- USB On-The-Go (OTG) adapter to convert a female USB-A to male micro-USB or USB-C\n- Android device running Android 6.0 Marshmallow or later release\n- Optional: desktop computer\n\n\nSeveral MIDI keyboards support both USB and BLE-MIDI, so you can do your testing with\njust one keyboard. Examples are the\n[Akai LPK25 Wireless](http://www.akaipro.com/product/lpk25)\nand the\n[Korg Microkey Air](https://www.korg.com/us/products/computergear/microkey2_air/).\n\n### Apps\n\n\nSeveral apps are used by this test procedure.\nThe apps are available in source code on GitHub project\n[android-midisuite](https://github.com/philburk/android-midisuite),\nand via *Google Play*™ at links in the following table.\n\n| Source code | Google Play™ | Description |\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|\n| [MidiScope](https://github.com/philburk/android-midisuite/tree/master/MidiScope) or [MidiScope](https://github.com/googlesamples/android-MidiScope) | [MIDI Scope](https://play.google.com/store/apps/details?id=com.mobileer.example.midiscope) | displays MIDI messages on-screen |\n| [MidiKeyboard](https://github.com/philburk/android-midisuite/tree/master/MidiKeyboard) | [MIDI Keyboard](https://play.google.com/store/apps/details?id=com.mobileer.midikeyboard) | sends MIDI messages by pressing an on-screen music keyboard |\n| [MidiSynthExample](https://github.com/philburk/android-midisuite/tree/master/MidiSynthExample) or [MidiSynth](https://github.com/googlesamples/android-MidiSynth) | [MIDI Synth Ex](https://play.google.com/store/apps/details?id=com.mobileer.midisynthexample) | simple MIDI synthesizer that uses sawtooth oscillators |\n| [MidiBtlePairing](https://github.com/philburk/android-midisuite/tree/master/MidiBtlePairing) | [MIDI BLE Connect](https://play.google.com/store/apps/details?id=com.mobileer.example.midibtlepairing) | pairs an Android device with a BLE peripheral |\n| [MidiTools](https://github.com/philburk/android-midisuite/tree/master/MidiTools) | | library dependency of the above apps |\n\n\nIf you choose to work from source code rather than install via *Google Play* ™,\nfirst build the app using the supplied *Android.mk* .\nThen install the app using\n[Android Debug Bridge](http://developer.android.com/tools/help/adb.html) (ADB).\nFor example, to install the *MidiScope* app:\n\n1. Use a workstation with ADB installed.\n2. Connect a USB cable from the workstation to the Android device.\n3. You may need to allow the USB connection on the Android device; see [USB peripheral mode](/docs/core/audio/midi#usb-peripheral)\n4. On the workstation, enter:\n\n cd \u003cvar translate=\"no\"\u003eTHIS_FOLDER\u003c/var\u003e\n adb install -r MidiScope.apk\n\nVirtual synth tests\n-------------------\n\nNote that a MIDI input port can have only one connection. So if another app is\nalready using an input port, that port will not be available. If you cannot connect to\nan input port then try closing other apps.\n\nHardware needed: Android device under test\n\n### Simple connection\n\nApps needed: *MidiKeyboard* , *MidiSynthExample*\n\nThis tests device enumeration, virtual devices, port connections, and message\nsending.\n\n1. Adjust volume on Android device to about halfway.\n2. Orient phone in landscape mode.\n3. Launch *MidiKeyboard* app.\n4. Select **SynthExample** from the spinner menu.\n5. Play keys. You should hear notes being played in the *SynthExample* app.\n6. Exit the application by pressing the **Back** button so that the port will be closed.\n\nUSB test: host mode\n-------------------\n\nHardware needed: USB MIDI keyboard, USB cable, OTG adapter\n\nRepeat these tests several times. We have seen the USB stack crash hard on some\nprototype devices if devices were plugged in and unplugged a few times.\n\n### Keyboard already plugged in\n\nApps needed: *MidiSynthExample* or *MidiScope*\n\nThis tests USB MIDI in host mode.\n\n1. Adjust volume on Android device to about halfway.\n2. Plug in USB keyboard using the OTG adapter.\n3. Launch *SynthExample* app or the *MidiScope* app.\n4. From the menu select the USB keyboard. It will display the brand.\n5. Play notes on the keyboard. If you ran *SynthExample* then you should hear notes being played on the phone. If you ran *MidiScope* then you should see *NoteOn* and *NoteOff* messages on-screen.\n6. Unplug the keyboard. The *Sender for Synth* menu should display *- - - - -*.\n7. Exit the application by pressing the **Back** button.\n\n### Hot-plug USB keyboard\n\nApps needed: *MidiSynthExample* or *MidiScope*\n\nThis tests USB MIDI in host mode.\n\n1. Adjust volume on Android device to about halfway.\n2. Make sure there is not a USB MIDI keyboard plugged in.\n3. Launch *SynthExample* app.\n4. At middle, next to *Sender for Synth*, look in menu. You should not see the USB keyboard listed.\n5. Plug in USB keyboard using the OTG adapter.\n6. At middle, next to *Sender for Synth*, select the USB keyboard. It will display the brand.\n7. Play notes on the keyboard. You should hear notes being played on the phone.\n8. At middle, next to *Sender for Synth* , select **- - - - -**.\n9. Play notes on the keyboard. You should hear nothing.\n10. At middle, next to *Sender for Synth*, select the USB keyboard. It will display the brand.\n11. Play notes on the keyboard. You should hear notes being played on the phone.\n12. Unplug the synthesizer. The *Sender for Synth* menu should display *- - - - -*.\n13. Exit the application by pressing the **Back** button.\n\nUSB test: peripheral mode\n-------------------------\n\nHardware needed: USB cable, OTG adapter\n\n### Android-to-Android\n\nApps needed: *MidiKeyboard* on Android device under test, *MidiScope* on another\nAndroid device.\n\nUse Android devices as a peripheral controller for another Android device. To help test\nthis mode, use another Android device running in host mode. Note that\nyou could modify the test to work with a desktop computer running Digital Audio Workstation (DAW)\nsoftware such as\nGarageBand.\n\n1. Connect the USB cable to the Android device under test (Android device **A**).\n2. Use an OTG adapter to connect the other end of the cable to a second Android device **B** that operates in host mode.\n3. On Android device A:\n 1. Drag finger down from top of screen.\n 2. Select **USB for Charging** icon.\n 3. Select **MIDI**.\n 4. Launch *MidiKeyboard* app.\n 5. Select **Android USB Peripheral Port** from *Receiver for Keys* menu at top.\n4. On Android device B:\n 1. Launch *MidiScope* app.\n 2. Select the other Android device as the source.\n5. On Android device A:\n 1. Play notes on the keyboard and look for *NoteOn* and *NoteOff* on Android device B.\n\nBLE test\n--------\n\nHardware needed: MIDI keyboard supporting BLE\n\n### Basic pairing and playing\n\nApps needed: *MidiBtlePairing* , *MidiSynthExample*\n\nTest a keyboard connected to Android over BLE.\n\n1. Reboot the Android device.\n2. Power on the BLE keyboard. \n (The Miselu C.24 keyboard is powered on by pushing the button near the back so that it pops open. The power button on the C.24 pulses blue when in pairing mode.)\n3. Launch the *MidiBtlePairing* app. It has a *MIDI+BTLE* icon.\n4. Press the **Bluetooth Scan** button.\n5. Select desired BLE peripheral.\n6. The app should return to the main page, and you should see the peripheral listed. If you are using a C.24, then you will notice that the light should turn green on the C.24 to indicate paired mode.\n7. Exit the app by pressing the **Home** button, not the **Back** button.\n8. Launch the SynthExample app.\n9. Select the BLE keyboard as the sender from the menu.\n10. You should be able to press keys on the BLE keyboard and hear notes on Android."]]