• Post Reply Bookmark Topic Watch Topic
  • New Topic

Beep Sound continuously for 1 min??  RSS feed

 
Bikash Paul
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can any one plz tell me How Can I create Beep sound for 1min continuously.Now I can create Beep sound only once by below code.Eagerly waiting for someone reply.
Toolkit.getDefaultToolkit().beep();
Regards
Bikash
 
Dingcheng lee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can write a loop, in the loop you can invoke the
for(int i = 0 ; i < 600; i++){
Toolkit.getDefaultToolkit().beep();
try{
Thread.sleep(100);
}catch(Exception e){
}
}
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"smartHawk" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

Thanks! and welcome to the JavaRanch!

Bikash,

I would use a separate Thread instead of a loop to sound the bell...

 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a another key question when doing this. Is there any way to get Java to turn the audio on in windows and turn up the volume? In my application, we want to make sure the user hears us when we trash talk him for doing something stupid. (Otherwise the user may simply hace the sound off, and not hear it.)
--Marek
 
Bikash Paul
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for all of ur's help.
Thanks & Regards
Bikash
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark, we're talking about the system speaker here... that's what the beep() method sounds. I don't think that you can turn off the system speaker through the control panel. If you want to use real sounds (.WAV sound files or other types), you'll have to use JMF (Java Media Framework), which also gives you a lot more control of playback, and supports most video and sound formats. There isn't a built-in way of turning up the system sound (as far as I know), you'd have to do some kind of JNI to get Windows to control the system sound. But this really seems like overkill... if the user turns sounds off at the system level, that probably means they want sounds off... I'd be pretty mad if I turned sound off and then some stupid program that thought it knew better than me turns sound back on to sound an error message. For example, you could be breaking into a high security facility and using your PDA to hack into the security systems to disable it. You have sounds turned off because you are perched inside an air duct above the guard station. Whoops! You accidently mis-typed a command! The program re-enables system sound to beep at you. You're dead...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!