Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Make a sound

868 views
Skip to first unread message

#Hai

unread,
Jun 22, 2003, 1:01:13 AM6/22/03
to
I want to send out a small piece of sound (ex: a series of 5 beep) to the
speaker (by C#).
How to do that ?


Michael Mayer

unread,
Jun 22, 2003, 3:54:03 AM6/22/03
to
I did a quick google search on "C# messagebeep"

Here's a hard way to do it (involves directx 9 sdk)
http://www.codeproject.com/csharp/MessageBeep.asp

And a few other good ways are listed in a message at:
http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=8811

From the 2nd URL, I think my own favorite would be this one (but then
again, i have no particularly bad feelings towards vb).
...you could call VB Runtime Beep like this.
Add referece to Microsoft Visual Basic.NET Runtime
//And then you just use this in your code:
Microsoft.VisualBasic.Interaction.Beep();

-mike


" #Hai" <LH...@SoftHome.net> wrote in message
news:OZWoPzHO...@TK2MSFTNGP10.phx.gbl...

L3m0n

unread,
Jun 22, 2003, 6:28:44 AM6/22/03
to
The simpler way do obtain the internal speaker beep is to use the
Beep(frequency,duration) function. In order to user it u got to import
kernel32.dll.

using System;
using System.Runtime.InteropServices;

class MainClass
{
[DllImport("kernel32.dll")]
public static extern bool Beep(int freq,int duration);

public static void Main(string[] args)
{
Console.WriteLine("un beep");
Beep(1000,1000);
Console.WriteLine("un beep più alto e più corto");
Beep(2000,500);
}
}
-Alessandro-

" #Hai" <LH...@SoftHome.net> ha scritto nel messaggio
news:OZWoPzHO...@TK2MSFTNGP10.phx.gbl...

Herfried K. Wagner

unread,
Jun 22, 2003, 7:10:24 AM6/22/03
to
Hello,

" #Hai" <LH...@SoftHome.net> schrieb:


> I want to send out a small piece of sound (ex: a series of 5 beep)
> to the speaker (by C#).
> How to do that ?

Method 1:

\\\
Console.WriteLine( "\a" ); // Beep
///

Method 2:

\\\
[DllImport("kernel32.dll")]
private static extern bool Beep(int frequency, int duration);
///

Method 3:

\\\
Microsoft.VisualBasic.Interaction.Beep()
///

Method 4:

http://www.palmbytes.de/content/dotnetmisc/klassen.htm
-> class "SystemSound"

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


0 new messages