MidiManager
class MidiManager
kotlin.Any | |
↳ | android.media.midi.MidiManager |
This class is the public application interface to the MIDI service.
Requires the PackageManager#FEATURE_MIDI
feature which can be detected using PackageManager.hasSystemFeature(String)
.
Summary
Nested classes | |
---|---|
Callback class used for clients to receive MIDI device added and removed notifications |
|
abstract |
Listener class used for receiving the results of |
Constants | |
---|---|
static Int |
Constant representing MIDI devices. |
static Int |
Constant representing Universal MIDI devices. |
Public methods | |
---|---|
Array<MidiDeviceInfo!>! |
Gets a list of connected MIDI devices. |
MutableSet<MidiDeviceInfo!> |
getDevicesForTransport(transport: Int) Gets a list of connected MIDI devices by transport. |
Unit |
openBluetoothDevice(bluetoothDevice: BluetoothDevice!, listener: MidiManager.OnDeviceOpenedListener!, handler: Handler!) Opens a Bluetooth MIDI device for reading and writing. |
Unit |
openDevice(deviceInfo: MidiDeviceInfo!, listener: MidiManager.OnDeviceOpenedListener!, handler: Handler!) Opens a MIDI device for reading and writing. |
Unit |
registerDeviceCallback(callback: MidiManager.DeviceCallback!, handler: Handler!) Registers a callback to receive notifications when MIDI 1. |
Unit |
registerDeviceCallback(transport: Int, executor: Executor, callback: MidiManager.DeviceCallback) Registers a callback to receive notifications when MIDI devices are added and removed for a specific transport type. |
Unit |
unregisterDeviceCallback(callback: MidiManager.DeviceCallback!) Unregisters a |
Constants
TRANSPORT_MIDI_BYTE_STREAM
static val TRANSPORT_MIDI_BYTE_STREAM: Int
Constant representing MIDI devices. These devices do NOT support Universal MIDI Packets by default. These support the original MIDI 1.0 byte stream. When communicating to a USB device, a raw byte stream will be padded for USB. Likewise, for a Bluetooth device, the raw bytes will be converted for Bluetooth. For virtual devices, the byte stream will be passed directly. If Universal MIDI Packets are needed, please use MIDI-CI.
Value: 1
TRANSPORT_UNIVERSAL_MIDI_PACKETS
static val TRANSPORT_UNIVERSAL_MIDI_PACKETS: Int
Constant representing Universal MIDI devices. These devices do support Universal MIDI Packets (UMP) by default. When sending data to these devices, please send UMP. Packets should always be a multiple of 4 bytes. UMP is defined in the USB MIDI 2.0 spec. Please read the standard for more info.
Value: 2
Public methods
getDevices
fungetDevices(): Array<MidiDeviceInfo!>!
Deprecated: Use getDevicesForTransport
instead.
Gets a list of connected MIDI devices. This returns all devices that do not default to Universal MIDI Packets. To get those instead, please call getDevicesForTransport
instead.
Return | |
---|---|
Array<MidiDeviceInfo!>! |
an array of MIDI devices |
getDevicesForTransport
fun getDevicesForTransport(transport: Int): MutableSet<MidiDeviceInfo!>
Gets a list of connected MIDI devices by transport. TRANSPORT_MIDI_BYTE_STREAM is used for MIDI 1.0 and is the most common. For devices with built in Universal MIDI Packet support, use TRANSPORT_UNIVERSAL_MIDI_PACKETS instead.
Parameters | |
---|---|
transport |
Int: The transport to be used. This is either TRANSPORT_MIDI_BYTE_STREAM or TRANSPORT_UNIVERSAL_MIDI_PACKETS. Value is android.media.midi.MidiManager#TRANSPORT_MIDI_BYTE_STREAM , or android.media.midi.MidiManager#TRANSPORT_UNIVERSAL_MIDI_PACKETS |
Return | |
---|---|
MutableSet<MidiDeviceInfo!> |
a collection of MIDI devices This value cannot be null . |
openBluetoothDevice
fun openBluetoothDevice(
bluetoothDevice: BluetoothDevice!,
listener: MidiManager.OnDeviceOpenedListener!,
handler: Handler!
): Unit
Opens a Bluetooth MIDI device for reading and writing. Bluetooth MIDI devices are only available after openBluetoothDevice() is called. Once that happens anywhere in the system, then the BLE-MIDI device will appear as just another MidiDevice to other apps. If the device opened using openBluetoothDevice() is closed, then it will no longer be available. To other apps, it will appear as if the BLE MidiDevice had been unplugged. If a MidiDevice is garbage collected then it will be closed automatically. If you want the BLE-MIDI device to remain available you should keep the object alive. You may close the device with MidiDevice.close().
Parameters | |
---|---|
bluetoothDevice |
BluetoothDevice!: a android.bluetooth.BluetoothDevice to open as a MIDI device |
listener |
MidiManager.OnDeviceOpenedListener!: a MidiManager.OnDeviceOpenedListener to be called to receive the result |
handler |
Handler!: the Handler that will be used for delivering the result. If handler is null, then the thread used for the listener is unspecified. |
openDevice
fun openDevice(
deviceInfo: MidiDeviceInfo!,
listener: MidiManager.OnDeviceOpenedListener!,
handler: Handler!
): Unit
Opens a MIDI device for reading and writing.
Parameters | |
---|---|
deviceInfo |
MidiDeviceInfo!: a android.media.midi.MidiDeviceInfo to open |
listener |
MidiManager.OnDeviceOpenedListener!: a MidiManager.OnDeviceOpenedListener to be called to receive the result |
handler |
Handler!: the Handler that will be used for delivering the result. If handler is null, then the thread used for the listener is unspecified. |
registerDeviceCallback
funregisterDeviceCallback(
callback: MidiManager.DeviceCallback!,
handler: Handler!
): Unit
Deprecated: Use registerDeviceCallback(int,java.util.concurrent.Executor,android.media.midi.MidiManager.DeviceCallback)
instead.
Registers a callback to receive notifications when MIDI 1.0 devices are added and removed. These are devices that do not default to Universal MIDI Packets. To register for a callback for those, call #registerDeviceCallback instead. The DeviceCallback.onDeviceStatusChanged
method will be called immediately for any devices that have open ports. This allows applications to know which input ports are already in use and, therefore, unavailable. Applications should call getDevices
before registering the callback to get a list of devices already added.
Parameters | |
---|---|
callback |
MidiManager.DeviceCallback!: a DeviceCallback for MIDI device notifications |
handler |
Handler!: The Handler that will be used for delivering the device notifications. If handler is null, then the thread used for the callback is unspecified. |
registerDeviceCallback
fun registerDeviceCallback(
transport: Int,
executor: Executor,
callback: MidiManager.DeviceCallback
): Unit
Registers a callback to receive notifications when MIDI devices are added and removed for a specific transport type. The DeviceCallback.onDeviceStatusChanged
method will be called immediately for any devices that have open ports. This allows applications to know which input ports are already in use and, therefore, unavailable. Applications should call getDevicesForTransport
before registering the callback to get a list of devices already added.
Parameters | |
---|---|
transport |
Int: The transport to be used. This is either TRANSPORT_MIDI_BYTE_STREAM or TRANSPORT_UNIVERSAL_MIDI_PACKETS. Value is android.media.midi.MidiManager#TRANSPORT_MIDI_BYTE_STREAM , or android.media.midi.MidiManager#TRANSPORT_UNIVERSAL_MIDI_PACKETS |
executor |
Executor: The Executor that will be used for delivering the device notifications. This value cannot be null . |
callback |
MidiManager.DeviceCallback: a DeviceCallback for MIDI device notifications This value cannot be null . |
unregisterDeviceCallback
fun unregisterDeviceCallback(callback: MidiManager.DeviceCallback!): Unit
Unregisters a DeviceCallback
.
Parameters | |
---|---|
callback |
MidiManager.DeviceCallback!: a DeviceCallback to unregister |