This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Head First Java - BeatBox Code

 
Tom Shanks
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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.

Regards,

Tom



//JAM -- added code tags.
[ May 09, 2005: Message edited by: Joel McNary ]
 
Mike McMahon
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

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

Thanks!

Mike
 
Tom Shanks
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

Regards,

Tom
 
Bob Beerbower
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bert Bates
author
Sheriff
Posts: 8900
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

HTH,

Bert
 
Tom Shanks
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

Regards,

Tom Shanks :
 
d preb
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic