public
abstract
class
MidiReceiver
extends Object
java.lang.Object | |
↳ | android.media.midi.MidiReceiver |
Known Direct Subclasses |
Interface for sending and receiving data to and from a MIDI device.
Public constructors | |
---|---|
MidiReceiver()
Default MidiReceiver constructor. |
|
MidiReceiver(int maxMessageSize)
MidiReceiver constructor. |
Public methods | |
---|---|
void
|
flush()
Instructs the receiver to discard all pending MIDI data. |
final
int
|
getMaxMessageSize()
Returns the maximum size of a message this receiver can receive. |
void
|
onFlush()
Called when the receiver is instructed to discard all pending MIDI data. |
abstract
void
|
onSend(byte[] msg, int offset, int count, long timestamp)
Called whenever the receiver is passed new MIDI data. |
void
|
send(byte[] msg, int offset, int count)
Called to send MIDI data to the receiver without a timestamp. |
void
|
send(byte[] msg, int offset, int count, long timestamp)
Called to send MIDI data to the receiver with a specified timestamp. |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
MidiReceiver ()
Default MidiReceiver constructor. Maximum message size is set to
MAX_VALUE
MidiReceiver (int maxMessageSize)
MidiReceiver constructor.
Parameters | |
---|---|
maxMessageSize |
int :
the maximum size of a message this receiver can receive
|
void flush ()
Instructs the receiver to discard all pending MIDI data.
Throws | |
---|---|
IOException |
int getMaxMessageSize ()
Returns the maximum size of a message this receiver can receive.
Returns | |
---|---|
int |
maximum message size |
void onFlush ()
Called when the receiver is instructed to discard all pending MIDI data. Subclasses should override this method if they maintain a list or queue of MIDI data to be processed in the future.
Throws | |
---|---|
IOException |
void onSend (byte[] msg, int offset, int count, long timestamp)
Called whenever the receiver is passed new MIDI data.
Subclasses override this method to receive MIDI data.
May fail if count exceeds getMaxMessageSize()
.
NOTE: the msg array parameter is only valid within the context of this call.
The msg bytes should be copied by the receiver rather than retaining a reference
to this parameter.
Also, modifying the contents of the msg array parameter may result in other receivers
in the same application receiving incorrect values in their {link #onSend} method.
Parameters | |
---|---|
msg |
byte :
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 nanoTime() |
Throws | |
---|---|
IOException |
void send (byte[] msg, int offset, int count)
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(byte[], int, int, long)
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.
Parameters | |
---|---|
msg |
byte :
a byte array containing the MIDI data |
offset |
int :
the offset of the first byte of the data in the array to be sent |
count |
int :
the number of bytes of MIDI data in the array to be sent |
Throws | |
---|---|
IOException |
if the data could not be sent in entirety |
void send (byte[] msg, int offset, int count, long timestamp)
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(byte[], int, int, long)
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.
Parameters | |
---|---|
msg |
byte :
a byte array containing the MIDI data |
offset |
int :
the offset of the first byte of the data in the array to be sent |
count |
int :
the number of bytes of MIDI data in the array to be sent |
timestamp |
long :
the timestamp of the message, based on nanoTime() |
Throws | |
---|---|
IOException |
if the data could not be sent in entirety |