Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Head First Java Newb  RSS feed

 
Stephen Little
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I'm typing in this "My first sound player app" and I'm getting this error, it complies ok this error happens when I run it.

java.lang.IllegalStateException: Sequence not set at com.sun.media.sound.RealTimeSequencer.start(RealTimeSequencer.java:316)

here is the coe

import javax.sound.midi.*;

public class MiniMiniMusicApp {
public static void main (String[] args) {
MiniMiniMusicApp mini = new MiniMiniMusicApp();
mini.play();
}

public void play() {
try
{
Sequencer player = MidiSystem.getSequencer();
player.open();

Sequence seq = new Sequence(Sequence.PPQ, 4);
Track track = seq.createTrack();

ShortMessage a = new ShortMessage();
a.setMessage(144, 1, 44, 100);
MidiEvent noteOn = new MidiEvent(a, 1);
track.add(noteOn);

ShortMessage b = new ShortMessage();
b.setMessage(128, 1, 44, 100);
MidiEvent noteOff = new MidiEvent(b, 16);
track.add(noteOff);

player.start();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}



thanks for any help you guys can give

Stephen
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

We have a strict policy on display names, which must be a real first and last name with a space between.

Please go here and fix your display name up, pronto. Thanks, pardner!
 
Stephen Little
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I fixed my name now can you see what is wrong

Stephen
 
Davy Kelly
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stephen Little:
Ok I'm typing in this "My first sound player app" and I'm getting this error, it complies ok this error happens when I run it.

java.lang.IllegalStateException: Sequence not set at com.sun.media.sound.RealTimeSequencer.start(RealTimeSequencer.java:316)

here is the coe



thanks for any help you guys can give

Stephen


I added a line to your code, that was in my code but not yours

davy
[ November 23, 2006: Message edited by: Davy Kelly ]
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to add that the stack trace printed when the exception is caught tells you that the exception occurred in the player.start() method and this narrows it down quite a bit in helping you to figure out where the error is.

-- Kaydell
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!