Category Archives: audio

Play an audio resource in C#

The System.Media.SoundPlayer class lets you easily play a WAV file stored as an audio resource. For this example, first add the WAV file as an audio resource. To do that, open the Project menu and select Properties. Then open the … Continue reading

Posted in audio, multimedia | Tagged , , , , , , , , , , , , , | 1 Comment

Play WAV files in C#

The System.Media.SoundPlayer class lets you easily play WAV files. This example uses the following PlayWav method to play WAV files. // The player making the current sound. private SoundPlayer Player = null; // Dispose of the current player and // … Continue reading

Posted in audio, files, multimedia | Tagged , , , , , , , , , , , , , | Leave a comment

Use vectors to manage bouncing balls in C#

This example is similar to the one Use sprites to animate several bouncing balls in C# except it uses vectors to store information about the balls. A vector is a direction represented by X and Y coordinates. For example, the … Continue reading

Posted in algorithms, animation, audio, geometry, graphics, multimedia | Tagged , , , , , , , , , , , , , , , , , , , | Leave a comment

Use sprites to animate several bouncing balls in C#

This example is similar to the one described in the post Animate several bouncing balls in C# except it uses sprites to control the balls. The previous example stores the ball data in a group of arrays. This approach works … Continue reading

Posted in algorithms, animation, audio, graphics, multimedia | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Animate several bouncing balls in C#

This example modifies the earlier post Make a bouncing ball animation in C# to animate several bouncing balls. Much of the basic idea is the same so see that example first. The big difference is that this version stores ball … Continue reading

Posted in animation, audio, graphics, multimedia | Tagged , , , , , , , , , , , , , | 3 Comments

Make a bouncing ball animation in C#

This example shows how to make a bounding ball animation. When the form loads, the following code executes. // Some drawing parameters. private const int BallWidth = 50; private const int BallHeight = 50; private int BallX, BallY; // Position. … Continue reading

Posted in animation, audio, multimedia | Tagged , , , , , , , , , , , , | 4 Comments

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 … Continue reading

Posted in audio, multimedia | Tagged , , , , , , , , , , , , | Leave a comment

Play system sounds: beep, asterisk, question, etc. in C#

This example shows how to do something simple yet very useful: playing the default system sounds. Sometimes you may want to make your program beep or make some other sound. It would be nice to just call a Beep method. … Continue reading

Posted in audio, system | Tagged , , , , , , , , , | Leave a comment