public final class MidiDispatcher extends MidiReceiver
MidiReceiver
s.
This class subclasses MidiReceiver
and dispatches any data it receives
to its receiver list. Any receivers that throw an exception upon receiving data will
be automatically removed from the receiver list, but no IOException will be returned
from the dispatcher's MidiReceiver.onSend(byte[], int, int, long)
in that case.Constructor and Description |
---|
MidiDispatcher() |
Modifier and Type | Method and Description |
---|---|
int |
getReceiverCount()
Returns the number of
MidiReceiver s this dispatcher contains. |
MidiSender |
getSender()
Returns a
MidiSender which is used to add and remove
MidiReceiver s
to the dispatcher's receiver list. |
void |
onFlush()
Called when the receiver is instructed to discard all pending MIDI data.
|
void |
onSend(byte[] msg,
int offset,
int count,
long timestamp)
Called whenever the receiver is passed new MIDI data.
|
flush, getMaxMessageSize, send, send
public int getReceiverCount()
MidiReceiver
s this dispatcher contains.public MidiSender getSender()
MidiSender
which is used to add and remove
MidiReceiver
s
to the dispatcher's receiver list.public void onSend(byte[] msg, int offset, int count, long timestamp) throws IOException
MidiReceiver
MidiReceiver.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.onSend
in class MidiReceiver
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 onFlush() throws IOException
MidiReceiver
onFlush
in class MidiReceiver
IOException