jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Head First Java - BeatBox Code 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 - BeatBox Code" Watch "Head First Java - BeatBox Code" New topic

Head First Java - BeatBox Code

Tom Shanks

Joined: Mar 16, 2005
Posts: 8

I am currently having some difficulty with the following code. The code is from Bert and Kathy's Head First Book. The Beatbox compiles fine, however, when I run the program the beatbox only plays one loop instead of a continuous loop as suggested in the book. Any help would be greatly appreciated.



//JAM -- added code tags.
[ May 09, 2005: Message edited by: Joel McNary ]
Mike McMahon
Ranch Hand

Joined: May 07, 2005
Posts: 30

Did you ever get this figured out? I'm having the identical problem...


Tom Shanks

Joined: Mar 16, 2005
Posts: 8
Hi Mike,

I've never figured it out. Could be that the code does not loop. It would be nice to find a way to loop the code. Kathy or Bert please help!


Bob Beerbower
Ranch Hand

Joined: Jun 06, 2001
Posts: 32
Have you checked the erata

HFJ Erata

There is something in there about a thread in the beat box, not sure if its what your lookin for.

Regards Bob Beerbower
Bert Bates

Joined: Oct 14, 2002
Posts: 8898
Hi Guys,

I'm guessing that you've got the old version of HF Java, and you're using Tiger... For some strange reason, javax.sound.midi changed a bit with Tiger, and the old code doesn't loop anymore

The easiest thing to do is to go to wickedlysmart.com and get the new code kitchen source code. If you want to try to wade thru the API, and crack this on your own, you'll have to make changes in the buildTrackAndStart method ( add a call to sequencer.LOOP_CONTNUOUSLY), after the setSequencer call. You'll also want to use a tempo factor rather than BPM thru-out the code... arghh!

I'd recommend getting the code



Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Tom Shanks

Joined: Mar 16, 2005
Posts: 8
Hi Bert and Bob,

Thanks for your replies, this Java Greenhorn will follow your advice once I get a bit of time from my hectic work schedule. Keep up the good work guys!


Tom Shanks :
d preb

Joined: Jun 12, 2005
Posts: 1
I have downloaded the code from wickedlysmart and chapter 13 still does not run right. I compiles fine but I get the HourGlass and no events are generated when mouse click is performed. I'm using java (build 1.5.0_03-b07) on win xp.
Alan Jump

Joined: May 25, 2005
Posts: 26
Strange, I entered the code as presented in HFJ and had no problems getting it to run.

Maybe I did something unconsciously that corrected the problem...?

*goes to review code*

Okay, on review, I see I have the 2nd edition, and the line

does exist. This tells me I'm in a potential pitfall when it comes to reviewing someone else's code: don't presume everyone is working from the same version, be it of a text or of a JDK.

Just my two cents' worth...save up the change for a milk shake or something.
[ June 13, 2005: Message edited by: Alan Jump ]
I agree. Here's the link: http://aspose.com/file-tools
subject: Head First Java - BeatBox Code
It's not a secret anymore!