File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Head First Java

 
Jones Iraland
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,i have tried the Head First Java 2nd edition's programm called MiniMiniMusic and i do not hear anything.my computer's sound is ok and i have run the MusicTest1 without raising the exception "MidiUnavailableException",so what i am doing wrong?
Thanks in advance
 
Nickolas Case
Ranch Hand
Posts: 98
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried the code myself. I got it to play...something. It wasn't a piano key like the book advertised but it was there and it was very subtle. Almost like static. Also, the program never exits. What is MusciTest1? I can't find it in the book.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nickolas Case:
...the program never exits...

This can be fixed by adding the following 3 lines immediately after calling sequencer.start()...

This will cause a 2-second pause (which should be long enough for the sequencer to play the note), after which it will close the Sequencer and exit the program. There might be a better way, but this should work.

As for the sound, does your system have some sort of MIDI control panel? You might want to play around with those settings.
 
Nickolas Case
Ranch Hand
Posts: 98
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was just making the point that I copied the code verbatim from the book and was able to get a sound. The program not exiting was an observation I found odd seeing how this is a code example from a teaching book. It should include these things.

Jones, were you able to figure out your issue??
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've found that the Head First books often use code examples to make specific points, and that the code examples aren't necessarily complete.

Some of my favorite code examples have been the ones where they say off-handedly "and oh, by the way, this has a bug in it"... I love finding (and fixing) that bug! If they had made it fault-free I wouldn't learn as much, I think.

Another favorite is when they give an exercise, I solve whatever it is and make exactly the mistake that they were setting me up to make. And then in the next section, they explain why I have to pay attention to ABC or why XYZ didn't happen even though I expected it too.

I'm tempted to say that if it is an incomplete example, then there is probably a good reason for it to be that way. And if not, then it is probably listed in the errata

Did you get it straightened out, Jones?
 
Jones Iraland
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couldnt find the valid reason ,so i skiped it went forward.
Thanks guys for all the replies sent.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic