Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 30481  / 3 Years ago, sun, may 30, 2021, 12:17:20

There has been much written on getting the beep sound from Ubuntu releases over the years. Example: fixing the beep



My needs are slightly different in that I do not want to ensure sound card beeps are functioning. Instead, I want PC speaker beeps, the kind produced by the original built-in speaker because I believe they will produce less CPU load. I have confirmed that my computer has the PC speaker by unplugging the external speakers and shutting down Ubuntu. At some point in the shutdown and restart process a beep is heard even though the external speakers have no power.



I have tried the following:



In /etc/modprobe.d/blacklist.conf, turn these lines into comments:



#blacklist snd_pcsp
#blacklist pcspkr


In .bashrc



/usr/bin/xset b on
/usr/bin/xset b 100


Enable in the gnome terminal: Edit > Profile Prefs > General > Terminal Bell



Ensure no "mute" selections in: System > Prefs > Sound > various tabs (uncheck them all).



Select "Enable window and button sounds" in: System > Prefs > Sound > Sound Effects



In gconf-editor desktop > gnome > sound, select the three sound check boxes.



In gconf-editor apps > metacity > general select the audible bell check box.



Still I get no PC speaker beeps when I send code 7 to the console via my Java program or use



echo -e 'a'


or equivalently



echo -e "a"


on the bash command line. (The -e option means enable escape sequence interpretation.) What else should I try?



Update Since my goal is to minimize load on the CPU, here is a comparison of elapsed times. Each test is for 100,000 iterations. Each variant was performed three times so three results are presented for each.



printwriter.format("%c", 7); 
// 1.3 seconds, 1.5 seconds, 1.5 seconds

Toolkit.getDefaultToolkit().beep();
// 0.8 seconds, 0.3 seconds, 0.5 seconds

try { Runtime.getRuntime().exec("beep"); } catch (IOException e) { }
// 10.3 seconds, 16.3 seconds, 11.4 seconds


These runs were done inside Eclipse so multiply by some value less than 1 for standalone execution. Unfortunately, Toolkit's beep is silent on my computer and so is code 7. The beep utility works but has the most cost.


More From » speakers

 Answers
0

On 14.04.3 LTS it nows seems sufficient to edit /etc/modprobe.d/blacklist.conf and enable pcspkr by commenting out the blacklist line.


#blacklist pcspkr

The # turns the line into a comment.


Make sure the Terminal (gnome-terminal) allows console bell in the preferences tab.


This was tested via backspace on an empty terminal line. This was also tested via the beep utility (assuming that you have installed it). Instead you can do programmatic beeping via the java.awt.Toolkit object: java.awt.Toolkit.getDefaultToolkit().beep().


The Toolkit object is more efficient than the beep utility.


By the way, some people dislike the PC speaker.


[#40883] Monday, May 31, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rcraftemur

Total Points: 118
Total Questions: 119
Total Answers: 144

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
;