Title: Play tones with specific frequencies in C#
This example shows how you can play tones with a given frequency and duration. When the user clicks the Play button, the following code plays a tone.
private void btnPlay_Click(object sender, EventArgs e)
int freq = int.Parse(txtFrequency.Text);
int duration = int.Parse(txtDuration.Text);
The code parses the tone's frequency (Hz) and duration (ms) from text boxes. It then calls System.Console.Beep to play the tone for the indicated duration.
Note that System.Console.Beep is synchronous so it waits the specified duration before returning. That means you can't use this method to play a tone while the program does other things and you can't use this method to play multiple tones at the same time.
Download the example to experiment with it and to see additional details.