Added in API level 23

MidiInputPort


class MidiInputPort : MidiReceiver, Closeable

This class is used for sending data to a port on a MIDI device

Summary

Public methods
Unit

Int

Returns the port number of this port

Unit

Unit
onSend(msg: ByteArray!, offset: Int, count: Int, timestamp: Long)

Protected methods
Unit

Inherited functions
Unit flush()

Instructs the receiver to discard all pending MIDI data.

Int getMaxMessageSize()

Returns the maximum size of a message this receiver can receive.

Unit send(msg: ByteArray!, offset: Int, count: Int)

Called to send MIDI data to the receiver without a timestamp. Data will be processed by receiver in the order sent. Data will get split into multiple calls to onSend if count exceeds getMaxMessageSize. Blocks until all the data is sent or an exception occurs. In the latter case, the amount of data sent prior to the exception is not provided to caller. The communication should be considered corrupt. The sender should reestablish communication, reset all controllers and send all notes off.

Unit send(msg: ByteArray!, offset: Int, count: Int, timestamp: Long)

Called to send MIDI data to the receiver with a specified timestamp. Data will be processed by receiver in order first by timestamp, then in the order sent. Data will get split into multiple calls to onSend if count exceeds getMaxMessageSize. Blocks until all the data is sent or an exception occurs. In the latter case, the amount of data sent prior to the exception is not provided to caller. The communication should be considered corrupt. The sender should reestablish communication, reset all controllers and send all notes off.

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

getPortNumber

Added in API level 23
fun getPortNumber(): Int

Returns the port number of this port

Return
Int the port's port number

onFlush

Added in API level 23
fun onFlush(): Unit
Exceptions
java.io.IOException

onSend

Added in API level 23
fun onSend(
    msg: ByteArray!,
    offset: Int,
    count: Int,
    timestamp: Long
): Unit
Parameters
msg ByteArray!: a byte array containing the MIDI data
offset Int: the offset of the first byte of the data in the array to be processed
count Int: the number of bytes of MIDI data in the array to be processed
timestamp Long: the timestamp of the message (based on java.lang.System#nanoTime
Exceptions
java.io.IOException

Protected methods

finalize

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