tags:

views:

4419

answers:

7

How do I make the computer's internal speaker beep in C# without external speakers?

+9  A: 

Console.Beep

Barry Kelly
+1  A: 

Console.WriteLine("\a")

Chris Ballance
+23  A: 

In .Net 2.0, you can use Console.Beep().

// Default beep
Console.Beep();

You can also specify the frequency and length of the beep in milliseconds.

// Beep at 5000 Hz for 1 second
Console.Beep(5000, 1000);
a_hardin
Enjoy your new badge. ;)
Robert S.
Note that Beep() is not supported on Windows 64 bit systems (i.e. you'll hear no sound).
Lck
I just tested in Win 7 x64 RC, and although the internal speaker didn't beep, there was a beep through speakers when I had them plugged in and on. I guess it's just the internal (mobo) speaker that won't beep. Thanks for the info @Lck.
a_hardin
+1 for the x64 tip, doesn't work on Vista x64 either!
Andy Dent
And here is why: http://blogs.msdn.com/larryosterman/archive/2010/01/04/what-s-up-with-the-beep-driver-in-windows-7.aspx
Michael Stum
It should work on x64, but the sound will come out trough the normal speakers (which can be muted).http://blogs.msdn.com/larryosterman/archive/2010/01/04/what-s-up-with-the-beep-driver-in-windows-7.aspx
Kalmi
+13  A: 

You can also use the relatively unused:

    System.Media.SystemSounds.Beep.Play();
    System.Media.SystemSounds.Asterisk.Play();
    System.Media.SystemSounds.Exclamation.Play();
    System.Media.SystemSounds.Question.Play();
    System.Media.SystemSounds.Hand.Play();
RandomNoob
Unfortunately these system sounds require external speakers, which can't always be counted on. It's definitely good to know these, though!
a_hardin
Now knowing that x64 versions of Windows requires speakers to hear the Console.Beep(), these options will work just as well.
a_hardin
My Vista x64 on laptop with inbuilt speakers doesn't play Console.Beep() but these are fine.
Andy Dent
A: 

Does anyone know a site or have any info on where I can find some Xmas tunes in 'beep' format?

You just made me flash back to my QuickBASIC class in high school. Complete with a ASCII Christmas tree with flashing lights and snow falling. Unfortunately, I don't have it. It'd be easy to rewrite Jingle Bells in C#, now.
a_hardin
A: 

windows xp 64bit version beeps fine, without speakers. Thanks for the short line, I like it simple and good...

Ruth
A: 

Hi !

I am running Windows Server 2008 R2 [only exists as a x64 version] and all beep related functions do NOT work [have no XP/x64 to compare]. So some people may be happy about this, as a server administrator I am completely unhappy:All my long running scripts [WSH/PS/CMD even C#] use usually this type of feedback.

If someone could possibly look on a XP/x64 version for the speaker driver and tell me, if this is really present, I could possibly organize one and try to install it on a w2k8 server ;-)

I filed this as a recommendation to MS-Connect [should have been marked as bug] and this is mentioned in stackoverflow already [http://stackoverflow.com/questions/1488531/net-winform-system-beep-on-a-64-bit-os].

Thanks !

mabra

mabra