MidiManager
public
final
class
MidiManager
extends Object
java.lang.Object | |
↳ | 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 | |
---|---|
class |
MidiManager.DeviceCallback
Callback class used for clients to receive MIDI device added and removed notifications |
interface |
MidiManager.OnDeviceOpenedListener
Listener class used for receiving the results of |
Constants | |
---|---|
int |
TRANSPORT_MIDI_BYTE_STREAM
Constant representing MIDI devices. |
int |
TRANSPORT_UNIVERSAL_MIDI_PACKETS
Constant representing Universal MIDI devices. |
Public methods | |
---|---|
MidiDeviceInfo[]
|
getDevices()
This method was deprecated
in API level 33.
Use |
Set<MidiDeviceInfo>
|
getDevicesForTransport(int transport)
Gets a list of connected MIDI devices by transport. |
void
|
openBluetoothDevice(BluetoothDevice bluetoothDevice, MidiManager.OnDeviceOpenedListener listener, Handler handler)
Opens a Bluetooth MIDI device for reading and writing. |
void
|
openDevice(MidiDeviceInfo deviceInfo, MidiManager.OnDeviceOpenedListener listener, Handler handler)
Opens a MIDI device for reading and writing. |
void
|
registerDeviceCallback(int transport, Executor executor, MidiManager.DeviceCallback callback)
Registers a callback to receive notifications when MIDI devices are added and removed for a specific transport type. |
void
|
registerDeviceCallback(MidiManager.DeviceCallback callback, Handler handler)
This method was deprecated
in API level 33.
Use |
void
|
unregisterDeviceCallback(MidiManager.DeviceCallback callback)
Unregisters a |
Inherited methods | |
---|---|
Constants
TRANSPORT_MIDI_BYTE_STREAM
public static final int TRANSPORT_MIDI_BYTE_STREAM
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.
See also:
Constant Value: 1 (0x00000001)
TRANSPORT_UNIVERSAL_MIDI_PACKETS
public static final int TRANSPORT_UNIVERSAL_MIDI_PACKETS
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.
See also:
Constant Value: 2 (0x00000002)
Public methods
getDevices
public MidiDeviceInfo[] getDevices ()
This method was deprecated
in API level 33.
Use getDevicesForTransport(int)
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(int)
instead.
Returns | |
---|---|
MidiDeviceInfo[] |
an array of MIDI devices |
getDevicesForTransport
public Set<MidiDeviceInfo> getDevicesForTransport (int transport)
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 TRANSPORT_MIDI_BYTE_STREAM , or TRANSPORT_UNIVERSAL_MIDI_PACKETS |
Returns | |
---|---|
Set<MidiDeviceInfo> |
a collection of MIDI devices
This value cannot be null . |
openBluetoothDevice
public void openBluetoothDevice (BluetoothDevice bluetoothDevice, MidiManager.OnDeviceOpenedListener listener, Handler handler)
Opens a Bluetooth MIDI device for reading and writing.
Parameters | |
---|---|
bluetoothDevice |
BluetoothDevice : a 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
public void openDevice (MidiDeviceInfo deviceInfo, MidiManager.OnDeviceOpenedListener listener, Handler handler)
Opens a MIDI device for reading and writing.
Parameters | |
---|---|
deviceInfo |
MidiDeviceInfo : a 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
public void registerDeviceCallback (int transport, Executor executor, MidiManager.DeviceCallback callback)
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(int)
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 TRANSPORT_MIDI_BYTE_STREAM , or 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 . |
registerDeviceCallback
public void registerDeviceCallback (MidiManager.DeviceCallback callback, Handler handler)
This method was deprecated
in API level 33.
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(DeviceCallback, Handler)
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. |
unregisterDeviceCallback
public void unregisterDeviceCallback (MidiManager.DeviceCallback callback)
Unregisters a DeviceCallback
.
Parameters | |
---|---|
callback |
MidiManager.DeviceCallback : a DeviceCallback to unregister |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-11 UTC.