Added in API level 23

MidiDevice

class MidiDevice : Closeable
kotlin.Any
   ↳ android.media.midi.MidiDevice

This class is used for sending and receiving data to and from a MIDI device Instances of this class are created by MidiManager#openDevice.

Summary

Nested classes

This class represents a connection between the output port of one device and the input port of another.

Public methods
Unit

MidiDevice.MidiConnection!
connectPorts(inputPort: MidiInputPort!, outputPortNumber: Int)

Connects the supplied MidiInputPort to the output port of this device with the specified port number.

MidiDeviceInfo!

Returns a MidiDeviceInfo object, which describes this device.

MidiInputPort!
openInputPort(portNumber: Int)

Called to open a MidiInputPort for the specified port number.

MidiOutputPort!
openOutputPort(portNumber: Int)

Called to open a MidiOutputPort for the specified port number.

String

Protected methods
Unit

Public methods

close

Added in API level 23
fun close(): Unit
Exceptions
java.lang.Exception if this resource cannot be closed
java.io.IOException if an I/O error occurs

connectPorts

Added in API level 23
fun connectPorts(
    inputPort: MidiInputPort!,
    outputPortNumber: Int
): MidiDevice.MidiConnection!

Connects the supplied MidiInputPort to the output port of this device with the specified port number. Once the connection is made, the MidiInput port instance can no longer receive data via its MidiReceiver#onSend method. This method returns a MidiDevice.MidiConnection object, which can be used to close the connection.

Parameters
inputPort MidiInputPort!: the inputPort to connect
outputPortNumber Int: the port number of the output port to connect inputPort to.
Return
MidiDevice.MidiConnection! MidiDevice.MidiConnection object if the connection is successful, or null in case of failure.

getInfo

Added in API level 23
fun getInfo(): MidiDeviceInfo!

Returns a MidiDeviceInfo object, which describes this device.

Return
MidiDeviceInfo! the MidiDeviceInfo object

openInputPort

Added in API level 23
fun openInputPort(portNumber: Int): MidiInputPort!

Called to open a MidiInputPort for the specified port number. An input port can only be used by one sender at a time. Opening an input port will fail if another application has already opened it for use. A MidiDeviceStatus can be used to determine if an input port is already open.

Parameters
portNumber Int: the number of the input port to open
Return
MidiInputPort! the MidiInputPort if the open is successful, or null in case of failure.

openOutputPort

Added in API level 23
fun openOutputPort(portNumber: Int): MidiOutputPort!

Called to open a MidiOutputPort for the specified port number. An output port may be opened by multiple applications.

Parameters
portNumber Int: the number of the output port to open
Return
MidiOutputPort! the MidiOutputPort if the open is successful, or null in case of failure.

toString

Added in API level 23
fun toString(): String
Return
String a string representation of the object.

Protected methods

finalize

Added in API level 23
protected fun finalize(): Unit
Exceptions
java.lang.Throwable the Exception raised by this method