You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
559 B
34 lines
559 B
15 years ago
|
import java.util.PriorityQueue;
|
||
|
import javax.sound.midi.*;
|
||
|
import javax.sound.midi.MidiMessage.*;
|
||
|
|
||
|
class MIDIMessageReceiver implements Receiver
|
||
|
{
|
||
|
private PriorityQueue<MidiMessage> messages;
|
||
|
|
||
|
MIDIMessageReceiver()
|
||
|
{
|
||
|
messages = new PriorityQueue<MidiMessage>();
|
||
|
}
|
||
|
|
||
|
public void send(MidiMessage message, long timeStamp)
|
||
|
{
|
||
|
messages.add(message);
|
||
|
}
|
||
|
|
||
|
public boolean hasReceived()
|
||
|
{
|
||
|
return (messages.size() != 0);
|
||
|
}
|
||
|
|
||
|
public MidiMessage receive()
|
||
|
{
|
||
|
return messages.poll();
|
||
|
}
|
||
|
|
||
|
public void close()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
}
|