Toolkit not beeping on ubuntu
I am having problems with Toolkit's beep. I commented out the two speaker disabling lines in /etc/modprobe.d/blacklist.conf
. I cannot use the console code 7
to beep because I need it to work in Swing and I would like it to be audible开发者_运维百科 in Eclipse IDE (rather than to show a special symbol in the console-like pane in Eclipse). When not in the Eclipse IDE, I have tested code 7
and found it to be audible so I know it is not a loose connector problem. I do have nice sound effects via .wav files but sometimes I just want a simple beep and I don't want to use a lot of CPU cycles to achieve it. Presently I am using Runtime.getRuntime().exec("beep")
but that also seems a bit excessive. I am on ubuntu 10.10. The computer board is a Gigabyte MA 770 UD3. Below is the offending program.
import java.awt.Toolkit;
public class Beeper
{
public static void main(String[] args)
{
Toolkit.getDefaultToolkit().beep();
}
}
From blacklist.conf is the following.
# low-quality, just noise when being used for sound playback, causes
# hangs at desktop session start (Ubuntu: #246969)
#blacklist snd_pcsp
# ugly and loud noise, getting on everyone's nerves; this should be done by a
# nice pulseaudio bing (Ubuntu: #77010)
#blacklist pcspkr
I guess that your pcspks
module isn't loaded... I had the same problem and found out that on my system (14.04 LTS), it wasn't.
Check if it's loaded by doing a lsmod | grep pcspkr
in a terminal. If you get a line similar to
pcspkr 12718 0 `
it is loaded. If you do not get any output back from the command, try to load the module:
sudo modprobe pcspkr
That did the trick for me.
精彩评论