This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes Other JSE/JEE APIs and the fly likes MidiSystem.getSequencer (locks up) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "MidiSystem.getSequencer (locks up)" Watch "MidiSystem.getSequencer (locks up)" New topic

MidiSystem.getSequencer (locks up)

Mace Challinor

Joined: Dec 04, 2003
Posts: 2
Can anyone explain to me why my java freezes when I use the MidiSystem.getSequencer in the javax.sound.midi API? (until I press Ctl+C)
The Midi sound works fine, the program works fine, but the Public class MiniMiniMusicApp will not complete.
>Yes , I'm working through the Head First book.
test code:

import javax.sound.midi.*;
public class MiniMiniMusicApp {

public static void main(String[] args){
MiniMiniMusicApp mini = new MiniMiniMusicApp();;
System.out.println("Competed Main");
public void play() {

try {
Sequencer player = MidiSystem.getSequencer();;

Sequence seq = new Sequence(Sequence.PPQ, 4);

Track track = seq.createTrack();
ShortMessage a = new ShortMessage();
MidiEvent noteOn = new MidiEvent(a,1);
ShortMessage b = new ShortMessage();
MidiEvent noteOff = new MidiEvent(b,16);
} catch (Exception ex) {
System.out.println("Competed Play");
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
I'm going to move this to Other Java APIs. Please post any follow-ups there.
Mace Challinor

Joined: Dec 04, 2003
Posts: 2
No problems now,, I have been using the Midi API in conjunction with a JFrame and the command "setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)" will gracefully close the program without the Midi hanging..
This topic can now be closed. Thanks.
I agree. Here's the link:
subject: MidiSystem.getSequencer (locks up)