Click to See Complete Forum and Search --> : Send tone to sound card...


Jim_Auricman
February 12th, 2009, 04:01 PM
The following function causes the small computer speaker to emit a tone for the requested duration:

Console.Beep(freq, duration_ms);

Is there a generic function to call to send the tone to the sound card, or would the call have to be hardware specific dependent on the particular sound card in the computer?
Thanks,
Jim

dglienna
February 12th, 2009, 08:25 PM
It's a WinAPI, and you can P/Invoke it:



using System;
using System.Runtime.InteropServices;

public class _Main
{
#region Win32

[DllImport("Kernel32.dll")]
static extern bool Beep(
uint dwFreq, uint dwDuration
);

#endregion

public static void Main()
{
Beep(150, 150);
}
}

Jim_Auricman
February 12th, 2009, 09:48 PM
Thanks, dglienna.
I tried your test program and sound does indeed come out of the headphones.
This enables me to do what I have planned to do.
Jim