Basically, I want to get and display the data of a midi note (the track, the note, and the octave) as a sequencer plays it, in real time.
I’d like to be able to add this to the following code:
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.setSequence(MidiSystem.getSequence(song));
sequencer.open();
sequencer.start();
while(true) {
if(sequencer.isRunning()) {
try {
Thread.sleep(1000); // Check every second
} catch(InterruptedException ignore) {
break;
}
} else {
break;
}
}
But I have no idea how to do it.
Add a ControllerEventListener to the Sequencer. It will save you the active wait and will provide all the information you need to display.
Have a look at this page as well.