g | x | w | all
Bytes Lang Time Link
019C MSVC + Win32250731T122736Zjdt
059C gcc250731T060145Zceilingc
084SmileBASIC170207T145905Z12Me21
004Jolf160124T185330ZConor O&
020Vitsy + X11160124T175018Za spaghe
095Bash + Linux utils151116T231607ZDigital
074VB.net151116T011451ZEric Joh
038Hassium151119T142826ZJacob Mi
036MATLAB151115T220949ZBlackhol
082C with WinAPI151117T094751Zuser4677
086Shadertoy GLSL Sound Shader151117T015651ZKroltan
114JavaScript151116T034021ZTaylor G
027Perl151116T221203ZChicagoR
032PowerShell151116T010002ZNacht
020Bash + X11151115T230553Za spaghe
012FakeASM151115T220541Zlynn
nanQBasic151115T215554Zlynn
095Turbo/Borland/Free/GNU Pascal151116T111801ZSztupY
106Processing151116T044233Zgeokavel
080C#151115T220606ZSean Lat
042Mathematica151115T215043ZMartin E
040Python2151115T215706Zorlp

C (MSVC) + Win32, 19 bytes

f(f){Beep(f,5000);}

C (gcc), 59 bytes

i,j;f(x){for(i=4e4;i--;)putchar(j=128+128*sin(i*x/1274.));}

Try it online!

Outputs samples to standard output suitable for an 8 bit 8 kHz DAC such as ./aplay available on many Linux distributions.

SmileBASIC, 84 bytes

INPUT F
N=LOG(F/440,POW(2,1/12))+57BGMPLAY FORMAT$("@D%D@255T12N%D",(N-(N<<0))*63,N)

Converts from Hz to half steps, and plays the a certain note with the a detune value to produce the frequency.

Jolf, 4 bytes, noncompeting

This language addition came after the challenge.

Αc5j
Αc     create a beep
  5     five seconds long
   j    with the input as a frequency

The default wave is a sine wave.

Vitsy + X11, 20 bytes

"5 "WX" 9 b tesx",7O

A translation of my bash answer. Does not work in the online interpreter (obviously).

Takes input as any non-numeric character followed by the frequency (so for an input of 440 Hz you could do "a440").

Explanation

"5 "WX" 9 b tesx",7O
"5 "                   Push " 5"
    WX                 Reads input and removes the first character (which is used to force string context)
      " 9 b tesx"      Push "xset b 9 "
                 ,     Pop everything and execute as a shell command.
                  7O   Output bell char.

Bash + Linux utils, 95

bc -l<<<"obase=16;for(;t<5;t+=1/8000){a=s($1*t*6.3);scale=0;a*30/1+99;scale=9}"|xxd -p -r|aplay

This is a true sine wave. No beeps. Input frequency entered via the command-line:

./hz.sh 440

VB.net, 90 bytes, 74 bytes

Module m
Sub Main(a() as String)
Console.Beep(a(0),5000)
End Sub
End Module

Thanks to Sehnsucht

Module m
Sub Main()
Console.Beep(My.Application.CommandLineArgs.First,5000)
End Sub
End Module

This is my first post so if I did any thing wrong please let me know

Hassium, 38 Bytes

func main()Console.beep(input(), 5000)

MATLAB, 36 bytes

sound(sin(pi*input('')*(0:8^-4:10)))

Thanks to flawr for saving two bytes.

C with WinAPI, 82 bytes

#include<windows.h>
#include<stdio.h>
main(){int x;scanf("%i",&x);Beep(x,5000);}

Uses the WinAPI Beep() function.

Shadertoy GLSL Sound Shader, 86

#define F 440.0
vec2 mainSound(float t){return vec2(sin(6.3*F*t)*(t<5.0?1.0:0.0));}

"Input" is given via #define. Outputs a sinewave with approximate frequency of FHz. Rounded 2*Pi to 6.3, instead of "default" 6.2831, but sounds pretty much the same.

Sadly there isn't much to golf here.

JavaScript, 114 bytes

p=prompt();c=new AudioContext;with(c.createOscillator()){frequency.value=p;connect(c.destination);start();stop(5)}

Requires a somewhat cutting-edge browser, enter the frequency in the prompt. JSFiddle

Perl, 27 bytes

Basically a Perl version of the Python answer (also only works on Windows), if we're allowing modules.

use Audio::Beep;beep<>,5000

PowerShell, 32 bytes

[console]::beep((read-host),5kb)

Bash + X11, 27 20 bytes

xset b 9 $1 5;echo 

This contains an unprintable, so here's a hexdump:

0000000: 7873 6574 2062 2039 2024 3120 353b 6563  xset b 9 $1 5;ec
0000010: 686f 2007                                ho .

This takes the frequency as a command-line argument and plays the appropriate beep at a volume of 9% (since no volume was specified).

(Note: I was unable to test this due to some issues with my computer, but I'm 99% sure it works.)

FakeASM, 12 bytes

RDA
BEEP 5e3

Works with the Windows reference implementation (download). It calls Windows' Beep function, which is a sine wave on modern platforms.

QBasic, 18 bytes (disqualified)

Like @pabouk mentioned, this uses the PC speaker, so it plays a square wave, not a sine wave like the problem asks. (This requirement was added to the problem after this answer was posted, hence the votes.) I'll leave it here for posterity anyway.


INPUT F
SOUND F,91

Play a sound at the inputted frequency for 91 ticks, which is equal to 5 seconds.

Turbo/Borland/Free/GNU Pascal, 95 bytes

Due to issues with the delay function on modern computers (well, anything faster than 200Mhz) trying to run Turbo / Borland pascal, this might not wait 5 seconds, even with a patched CRT library

Program a;Uses crt;Var i,k:Integer;BEGIN Val(ParamStr(1),i,k);Sound(i);Delay(5000);NoSound;END.

The String to Integer conversion can be done shorter (77 bytes) on FreePascal, and modern derivates, as they have the StrToInt function:

Program a;Uses crt;BEGIN Sound(StrToInt(ParamStr(1)));Delay(5000);NoSound;END.

Processing, 148 114 106 bytes

import processing.sound.*;
Engine.start().sinePlay(int(loadStrings("s")[0]),1,0,0,0);delay(5000);exit();

(For some reason Processing requires both using the import statement and the new line, otherwise it does not recognize the library.)

I still haven't figured out how to pass arguments into Processing, though I know it's possible, so this code requires having a file called "s" in the sketch folder which has the frequency value. If I can figure out how to pass in arguments I could replace file loading with args[0].

C#, 80 bytes

class P{static void Main(string[]a){System.Console.Beep(int.Parse(a[0]),5000);}}

Mathematica, 42 bytes

Well if we can use built-ins...

Input[]
EmitSound@Play[Sin[2t%Pi],{t,0,5}]

Thanks to the requirement for a full program, this was the first time I got to use my recently discovered golfing tip of using % (result of last evaluation) to save two bytes.

Mathematica also has a built-in Sound which takes a pitch and a duration as arguments, but unfortunately the pitch has to be given as a musical note. Specifying your own sound wave via Play seems to be the only way to work with a frequency.

Python2, 40 bytes

from winsound import*
Beep(input(),5000)

Only works on Windows.