Is there a way to play audio snippets in C# without installing the DirectX SDK?
-
05-09-2019 - |
Question
For a school project I need to create a program and it'd be nice if it could include some sound effects. We're using C# (and Visual C# Express Edition 2008 Edition) to code our programs, and I was wondering if there's anyway to play short audio files without installing the DirectX SDK.
On our school computers, we don't have sufficient access to install any SDKs, and we have to use those computers for development. Is there any way to play audio files w/o the DirectX SDK?
Solution
You can use a System.Media.SoundPlayer, but it will only work with wavs.
OTHER TIPS
You can add sound effects with the speech engine (.net3), too!
Fun Fun Fun!
Add a reference to System.Speech dll
using System.Speech;
System.Speech.Synthesis.SpeechSynthesizer ss = new System.Speech.Synthesis.SpeechSynthesizer();
ss.Rate = 8;
ss.SpeakAsync("Booom Booom Booom Booom Booom Booom");
Try increase/decrease the Rate and pitch for more fun