wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Head First Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Head First Java" Watch "Head First Java" New topic

Head First Java

Jones Iraland
Ranch Hand

Joined: Sep 15, 2007
Posts: 36
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

Joined: Apr 26, 2008
Posts: 98
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

Joined: Aug 31, 2004
Posts: 11343

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.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Nickolas Case
Ranch Hand

Joined: Apr 26, 2008
Posts: 98
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

Joined: Nov 03, 2006
Posts: 1357
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

Joined: Sep 15, 2007
Posts: 36
I couldnt find the valid reason ,so i skiped it went forward.
Thanks guys for all the replies sent.
I agree. Here's the link: http://aspose.com/file-tools
subject: Head First Java
Similar Threads
How to prepare for SCWCD exam
Head First Start Series are Real Real Good
Books that should be made into movies
My dog is smarter than I in regards to polymorphism
Java 5 - books (not necessarily certification ones)