• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

javax.sound.midi compatibility with JMF

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
John Calson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This solution assumes:
- Windows XP SP3
- JDK 1.6+
- JRE 1.6+

The problem is the file sound.jar
Find it in 3 places and delete it.

C:\Program Files\JMF2.1.1e\lib\sound.jar
C:\Program Files\Java\jdk1.6.0_07\jre\lib\ext\sound.jar
C:\Program Files\Java\jre1.6.0_07\lib\ext\sound.jar

Also, remove sound.jar reference from PATH and CLASSPATH

This is an old sound.jar that messes up the new sound API in the new versions of Java.
 
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic