Hi, I'm having some trouble playing MIDI files in Java. What I get is a MidiUnavailableException (MIDI OUT transmitter not available)
when I try to play it. My code is standard:
try {
midiseq = MidiSystem.getSequencer();
midiseq.open();
midiseq.setSequence(MidiSystem.getSequence(sound1));
midiseq.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
midiseq.start();
} catch (Exception e) {e.printStackTrace();}
midiseq
is a Sequencer
; sound1
is an InputStream
.
This code works on several other computers, and even works in Eclipse and when used in a JAR file, just not when I launch it from the command prompt. I've downloaded a more stable Java midi application, and it threw the same exception.
It can't be a hardware problem because Eclipse can run it without problems, neither can it be a coding problem because this runs correctly on other computers. Even this one line of code throws this exception:
javax.sound.midi.MidiSystem.getSequencer();
Thanks in advance.
edit: My operating system is Windows Vista. Before I asked this question I've downloaded the latest JRE and JDK (1.6.0_13 I think).
edit: The code:
ClassLoader.getSystemClassLoader().loadClass("com.sun.media.sound.RealTimeSequencer");
System.out.println( "Sequencer class loaded" );// Otherwise ClassNotFoundException
prints "Sequencer class loaded."
But this code:
try{
System.out.println(javax.sound.midi.MidiSystem.getSequencer());
System.exit(0);
} catch(Exception e) {
throw new RuntimeException(e);
}
System.exit(1);
throws the MidiUnavailableException.
Also, this code:
MidiDevice.Info[] devices = MidiSystem.getMidiDeviceInfo();
if (devices.length == 0) {
System.out.println("No MIDI devices found");
} else {
for (MidiDevice.Info dev : devices) {
System.out.println(dev);
}
}
gives me this:
Microsoft MIDI Mapper Microsoft GS Wavetable Synth Real Time Sequencer Java Sound Synthesizer