Game Audio in C++ Metro App
-
Saturday, August 11, 2012 2:30 AM
I want to add audio to my D3D C++ Metro App/game. I want to play:
1) Looping background audio PCM, plus
2) Sound Effects - up to 2-3 simultaneous PCM plus
3) VoiceOver - single shot longer voice over PCM
Do I use XAudio2 ??? are there any shortcuts? I am familiar with DirectSound API. XAudio2 seems somewhat familiar.
http://www.puttnutz.com
All Replies
-
Sunday, August 12, 2012 8:26 AMYes, you should use XAudio2.
C++ DX11
- Marked As Answer by James Dailey - MSFTMicrosoft Employee, Moderator Wednesday, August 15, 2012 12:04 AM
- Unmarked As Answer by James Dailey - MSFTMicrosoft Employee, Moderator Wednesday, August 15, 2012 12:04 AM
-
Wednesday, August 15, 2012 12:05 AMModerator
Here are some samples that might help:
XAudio2 audio file playback sample
http://code.msdn.microsoft.com/windowsapps/Basic-Audio-Sample-9a5bb0b7XAudio2 audio stream effect sample
http://code.msdn.microsoft.com/windowsapps/XAudio2-Stream-Effect-3f95c8f2XInput audio controller playback sample
-James
http://code.msdn.microsoft.com/windowsapps/Audio-Controller-Sample-266f9a0e
Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
- Edited by James Dailey - MSFTMicrosoft Employee, Moderator Wednesday, August 15, 2012 12:06 AM added name
- Marked As Answer by James Dailey - MSFTMicrosoft Employee, Moderator Wednesday, August 15, 2012 12:06 AM
-
Friday, August 17, 2012 6:32 PM
Yes, XAudio2 works well, and it was not hard to hook up.
Hooking up SFX was easy. After reading the docs initially I thought I would also have to hook up streaming from file to play BG audio then I thought about the fact that Metro apps are download-only so I wasn't going to be able to have huge audio assets so I wrote this extension to XAudio2SoundPlayer that allows me to stop and delete an audio voice so I can use one of the voices for BG audio. it goes something like this, if it helps anybody ( I did not see a way to do this with the XAudio2SoundPLayer in the samples)
void XAudio2SoundPlayer::KillSound(size_t index) { StopSound(index); m_soundList.erase( m_soundList.begin() + index ); }http://www.puttnutz.com


