How to generate constant beep in windows forms

Viewed 32

I am creating a morse code interpreter on C# because I am bored.

I have the whole thing working except one thing, the beep.

I am currently using Console.Beep(1000, timer1.Interval); in the timer1_tick event to beep for the same amount of time as the timer ticks, attempting to emulate a constant beep until the key is released. However this comes out very choppy with a few ms gap of silence between beeps.

Is there any way to create a constant buzz/beep sound until my isPressed bool is found false in the tick event?

1 Answers

Why you don't use playing the wav file? You can have a special file and play it, then stop playing when the key is released...

//start
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = @"file.wav";
player.Play(); //or player.PlaySync();


//stop
player.Stop();

Hope this helps!

Related