1

Is it possible to play basic BIOS sounds with Javascript or Java?
I need sounds that can be played on PC computers without Sound Card.
Every PC has built-in PC speaker that can be useful in this case.

4
  • @JamesScholes Sound Card is required for this sound. I need something like Sticky Keys sound (press 5 times Shift to listen it)
    – Ilya
    Apr 24, 2013 at 21:39
  • For what it's worth, in Linux, you can do try (OutputStream out = Files.newOutputStream(Paths.get("/dev/console"))) { out.write(7); } (but even that might require the "pcspkr" kernel module to be loaded).
    – VGR
    Apr 24, 2013 at 23:19
  • I would believe that it would be impossible to control the system speaker in Javascript, however you could in Java. Apr 25, 2013 at 5:30

2 Answers 2

0

I would use Java and exec an external program:

Runtime.getRuntime().exec("beep.exe"); //not sure Beep.exe is a real thing

Which program to exec? Not sure, but look here for inspiration:

https://superuser.com/questions/227939/how-to-make-the-pc-speaker-beep-from-the-windows-7-command-prompt

or write your own:

http://www.frank-buss.de/beep/

Note that using exec is inherently platform-specific and thus frowned upon in Java. However, what you are trying to do is platform specific, so this is your best option.

Other things worth trying/thinking about:

java.awt.Toolkit.getDefaultToolkit().beep();

But I think that beeps on the soundcard.

And

System.out.print( (char)7 );

but I'm not sure that will always work.

0

pyx4j-native library was helpful for me.

  <dependency>
     <groupId>com.pyx4j</groupId>
     <artifactId>pyx4j-native</artifactId>
     <version>1.0.1</version>
  </dependency>

It have class Beep method beep(int,int).

Play any sound is so easy with this library!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.