Game Development Reference
In-Depth Information
else
InitXAudio2();
This change makes it such that the program will use XAudio2 instead of DirectSound
if the m_UseDirectSound member variable is set to false . So, go to the top of the
class file, find that variable, and change its value to false .
With that taken care of, we need to create the InitXAudio2() method so that if the
m_UseDirectSound variable is set to false , the method is called. The following is
the code for this method:
public void InitXAudio2()
{
// Create the XAudio2 object.
m_XAudio2 = new XAudio2();
// Check that we have a valid sound device
to use.
if (m_XAudio2.DeviceCount == 0)
return;
// Create our mastering voice object. This
object represents the sound output device.
m_MasteringVoice = new
MasteringVoice(m_XAudio2);
// Open the .wav file that contains our
sound.
using (WaveStream wavFile = new
WaveStream(Application.StartupPath + "\\" +
"lost_village_128.wav"))
{
// Create the audio buffer and store
the audio data from the file in it.
m_AudioBuffer = new AudioBuffer();
m_AudioBuffer.AudioData = wavFile;
m_AudioBuffer.AudioBytes = (int)
Search WWH ::




Custom Search