Hi I am trying to write an application that will play morse code. I just wanted to know if there was a default system sound in java like some beep, or do I have to download some sound file from the internet?
You can:
Print the ASCII bell character to the console (will emit a beep sound):
public class DoBeep {
public static main(String args[]) {
System.out.print("\007"); // bell ASCII char
System.out.flush();
}
}
Use the beep()
method that will use the buzzer on the motherboard:
import java.awt.*;
public class DoBeep {
public static void main(String args[]) {
Toolkit.getDefaultToolkit().beep();
}
}
Have a look at the Java Sound API, which can play MIDI tones.
You may want to look at jMorse for some tips. This isn't to discourage you from your effort, but rather to provide a reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With