public abstract class MidiReceiver extends Object
Constructor and Description |
---|
MidiReceiver()
Default MidiReceiver constructor.
|
MidiReceiver(int maxMessageSize)
MidiReceiver constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
flush()
Instructs the receiver to discard all pending MIDI data.
|
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.
|
public MidiReceiver()
Integer.MAX_VALUE
public MidiReceiver(int maxMessageSize)
maxMessageSize
- the maximum size of a message this receiver can receivepublic abstract void onSend(byte[] msg, int offset, int count, long timestamp) throws IOException
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.msg
- a byte array containing the MIDI dataoffset
- the offset of the first byte of the data in the array to be processedcount
- the number of bytes of MIDI data in the array to be processedtimestamp
- the timestamp of the message (based on System.nanoTime()
IOException
public void flush() throws IOException
IOException
public void onFlush() throws IOException
IOException
public final int getMaxMessageSize()
public void send(byte[] msg, int offset, int count) throws IOException
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.msg
- a byte array containing the MIDI dataoffset
- the offset of the first byte of the data in the array to be sentcount
- the number of bytes of MIDI data in the array to be sentIOException
- if the data could not be sent in entiretypublic void send(byte[] msg, int offset, int count, long timestamp) throws IOException
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.msg
- a byte array containing the MIDI dataoffset
- the offset of the first byte of the data in the array to be sentcount
- the number of bytes of MIDI data in the array to be senttimestamp
- the timestamp of the message, based on System.nanoTime()
IOException
- if the data could not be sent in entirety