I am trying to read a midi file and output when the note is played, the note, and velocity. This would work great but it doesn't output the data live when the note is played. The code that plays the midi:
package midistep;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.Sequencer;
public class MidiReadAndPlay {
public static void main(String[] args) throws Exception {
Sequencer sequencer;
sequencer = MidiSystem.getSequencer();
sequencer.open();
InputStream is = new BufferedInputStream(new FileInputStream(new File("midifile.mid")));
sequencer.setSequence(is);
sequencer.start();
}
}
The code from the question I mention earlier doesn't output the data live. It just outputs it all at once. I would like it to output the sequencer data when the note is played so then it could be used later.