[Question]
  [
**Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers.
 
 
Closed 7 years ago.
**Locked**. This question and its answers are [locked](/help/locked-posts) because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
 
 
Your program has to make the computer produce a sound, any sound.
Shortest code wins, not sooner than 10 days after the first valid answer. If there is a tie, the one submitted sooner, wins.
* The program should run on a reasonable, not too uncommon personal computer.
* Opening a pop-up, message box, etc. (for example, on a web page) does not count, as they might or might not produce a sound, depending on a lot of settings.
* Just entering a wrong command or invalid character on a console and receiving a warning beep does not count, just as the compiler/interpreter/OS beeping on an error or crash does not count either. Your code must be a valid program.
  
[Answer]
# bash (13)
```
sudo rm -rf /
```
The faster the hard drive the better the sound. Don't work with SSDs.  
**(Don't try this at home, `sudo rm -rf /` erases everything on your hard drive)**
[Answer]
# \*sh (5)
```
eject
```
(does not work if you have no CD/DVD or similar drive..)
[Answer]
## Befunge, 0
If I read the spec correctly, this is an endless loop.  
Endless loop = you'll hear your CPU cooler spin up.
[Answer]
## sh 7
```
w|aplay
```
Plays a short noise.
Also 7:
```
aplay *
```
## Assembly
Another non-bell solution. Resulting binary is just 15 bytes.
```
mov al, 182
out 43h, al
out 42h, al
mov al, 16
out 42h, al
mov al, 3
out 61h, al
ret
```
Assemble with `nasm sound.asm -o sound.com`. Can be tried with `dosbox sound.com`.
[Answer]
## brainfuck: 8
```
+++++++.
```
Prints the bell character.
[Answer]
### bash (Mac OS X) 5
```
say a
```
although stylistically I prefer the somewhat longer:
```
say 'Hello, Code Golf !'
```
[Answer]
# dc, 2 chars
this one prints the bell character, too:
```
7P
```
Run with `$ dc <<< 7P` or save `7P` to file and run `$ dc file`.
Also:
# Befunge, 2 chars
Similar but infinitly looping and beeping:
```
7,
```
[Answer]
Haha, good ol' QBASIC code.
```
BEEP
```
[Answer]
# Python 3.3.3, one character
```
<bell character>
```
The error message will contain a bell character, causing the sound.
# Python 3.3.3, 10 characters
If errors are not allowed, this solution won't output the error message, only the sound.
```
print('<bell character>')
```
[Answer]
### Golfscript 3
```
'.'
```
*(where the `.` is in fact a BELL character)*
The HEX representation of the above code is:
```
27 07 27
```
[Answer]
# Java - 222
Enough of this bell character or predefined beep function stuff, this makes a real sound :)
```
import javax.sound.sampled.*;class S{static{try{SourceDataLine
l=AudioSystem.getSourceDataLine(new
AudioFormat(4000,8,1,0<1,0>1));l.open();l.start();for(byte
i=9;i!=0;i+=9)l.write(new byte[]{i},0,1);}catch(Exception e){}}}
```
[Answer]
## DOS Prompt / DOS Script
```
a:
```
Requires 3.5" floppy drive :)
[Answer]
## J (2)
```
a.
```
This prints all the characters from 0 to 255, that includes the bell.
If I have to do it without printing anything else, it's 4 characters:
```
7{a.
```
[Answer]
# Pascal: 30 characters
```
uses Crt;begin
Sound(999)
end.
```
This takes advantage of the lack of any rule regarding the sound's duration. So just turns on the speaker on 999 Hz and lets it so. (At least until another program calls `Nosound` or the computer is turned off.)
[Answer]
# Mathematica 6
This will evoke the system beep. On my computer, it is currently a chirp.
```
Beep[]
```
[Answer]
## Bash, 22
Back in the 90's, my brother taught me this one -- to be used in a computer lab where one has remote access and knows a person to be alone in said lab. Kids these days won't know what a computer lab is... but oh well.
```
cd /dev;cat sda1>audio
```
[Answer]
# cat/type/PHP 1
This is actually polyglot. It runs in `cat` (or Microsoft Cat called `type`) and PHP.
```
$ xxd file
0000000: 07                                       .
```
Execution:
```
$ xxd -r > file
0000000: 07                                       .
^D
$ cat file # cat could be replaced with type (on Windows) or with php
```
[Answer]
### brainfuck, 5 bytes
```
+[.+]
```
prints all chars including bell
[Answer]
## R 9
The bell character
```
cat("\a")
```
[Answer]
# Ruby, 7
```
$><<?\a
```
Tested on Windows with Ruby 1.9.3.
[Answer]
## DOS, 5
Indirect, requires user cooperation.
```
pause
```
[Answer]
## PowerShell, 24 17
Since nobody has posted this version yet:
```
[console]::beep()
```
**UPDATE:** Removed frequencies so it uses the default frequency and duration ([MSDN says the default is 800 hertz and 200 milliseconds](http://msdn.microsoft.com/en-us/library/8hftfeyw%28v=vs.110%29.aspx))
[Answer]
**Python** 9 chars
---
produces beep sound when executed.
```
print'\a'
```
[Answer]
# Applescript (4 Characters)
```
beep
```
This will play the default beep sound of OS X.
[Answer]
# Mathematica 7
Using Mathematica's built in text to speech capability.
```
Speak@x
```
Will make it say "x"
[Answer]
# top & aplay - 9
`top` has rhythm!
```
top|aplay
```
The periodic display sometimes does not feed the sound sink fast enough but `aplay` continues after grouching a bit... :-)
...this will run on many Linuxes...
### Bonus:
While running this, type "s 1 ENTER" to get more beats per second. :-)
Party on!!! \o/
[Answer]
## [><>](http://esolangs.org/wiki/Fish) 3
As in all answers, prints the bell (0x07) to stdout.
```
7o;
```
[Answer]
## Tcl, 1 char
```
-
```
replace `-` with the bell char.  
It will print the bell char as part of the error message. Twice.
And if you think this is not a valid program, add this before the bell char:
```
proc \007 {} {};
```
It is a valid program, I just did not define the command, because I like the error message.
[Answer]
# **C: 19**
```
main(){puts("\a");}
```
**edit:** header file is not needed for "puts"
[Answer]
### Ruby 8
```
 puts"\a"
```
Tested on Windows with Ruby 1.9.3.
]