These advertisements helps me to keep writing articles on this website

Native DirectX Audio for Windows Store Apps

You can use DirectX to play audio in Store Apps


To play wave files in Mahjong Solitaire for Windows 8 I used SharpDX. When I noticed pops and clicks during animations, I tried a few things like delaying a bit so animations could finish but the audio still did not perform as well as I wanted. Together with Inge Schepers who also experienced some problems with playing waves in her Takuzu game I did something I have not done in 20 years…I wrote C++ code! Luckily we found some WP8 samples we could convert to WinRT.

I wrapped everything together in a demo project you can find on Git.

I you want to use native DirectX audio, you need to do the folowing:

size_t XAudio2SoundPlayer::LoadSounds() {
char16* SOUND_FILE_LIST [] = {
private void Button_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) {

In this version you have to add the wavs in the C++ project manually to the SOUND_FILE_LIST. If you can help me improve this code in a way that you can pass the wavs from your main project, we can make it more generic. Let me know if you do!

Happy wave making!

Written by Loek van den Ouweland on May 16, 2013. Questions regarding this artice? You can send them to the address below.
By using this site, you acknowledge that you have read and understand our Cookie and Privacy Policy.