Hello,
I am getting a MidiUnavailableException : MIDI OUT transmitter not available
The code is the MiniMusicApp from the Head First
Java book
The program was working great until I installed JMF 2.1.1e. Since then I get the above error. I am running JDK 1.6.06 and JRE 1.6.06 on Windows XP. I can play MIDI files through Windows Media Player - no problem.
javax.sound.sampled is working fine
Code:
import javax.sound.midi.*;
public class MiniMusicApp { // this is the first one
public static void main(
String[] args) {
MiniMusicApp mini = new MiniMusicApp();
mini.play();
}
public void play() {
try {
// make (and open) a sequencer, make a sequence and track
Sequencer sequencer = MidiSystem.getSequencer(); //***** Blows up here ********
sequencer.open();
Sequence seq = new Sequence(Sequence.PPQ, 4);
Track track = seq.createTrack();
// now make two midi events (containing a midi message)
MidiEvent event = null;
// first make the message
// then stick the message into a midi event
// and add the event to the track
ShortMessage first = new ShortMessage();
first.setMessage(192, 1, 102, 0);
MidiEvent setIns = new MidiEvent(first, 0);
track.add(setIns);
ShortMessage a = new ShortMessage();
a.setMessage(144, 1, 82, 120);
MidiEvent noteOn = new MidiEvent(a, 1); // <-- means at tick one, the above event happens
track.add(noteOn);
ShortMessage b = new ShortMessage();
b.setMessage(128, 1, 82, 120);
MidiEvent noteOff = new MidiEvent(b, 64); // <-- means at tick one, the above event happens
track.add(noteOff);
// add the events to the track
// add the sequence to the sequencer, set timing, and start
sequencer.setSequence(seq);
sequencer.start();
// new
Thread.sleep(1000);
sequencer.close();
System.exit(0);
} catch (Exception ex) {ex.printStackTrace();}
} // close play
} // close class
I noticed a similar issue was filed in 2005 but that was never answered, hence my request again for info. If Sun continues to make JMF available for download then it should be supported?
Further, if this a known problem with no solution, then the book or their website should warn you not to install JMF