Game Development Reference
In-Depth Information
The first variable will hold our DirectSound object. The second one is the primary
sound buffer, and the third variable is a secondary sound buffer that will store the
sound we want to play.
Now,wewilladdanewmethodcalled InitDirectSound() tothe TileGameWin-
dow class. The following is the code for it:
public void InitDirectSound()
{
// Create our DirectSound object.
m_DirectSound = new DirectSound();
// Set the cooperative level.
m_DirectSound.SetCooperativeLevel(m_Form.Handle,
SlimDX.DirectSound.CooperativeLevel.Priority);
// Create the primary sound buffer.
SoundBufferDescription desc = new
SoundBufferDescription();
desc.Flags =
SlimDX.DirectSound.BufferFlags.PrimaryBuffer;
m_DSoundPrimaryBuffer = new
PrimarySoundBuffer(m_DirectSound, desc);
// Create our secondary sound buffer.
using (WaveStream wavFile = new
WaveStream(Application.StartupPath + "\\" +
"lost_village_128.wav"))
{
SoundBufferDescription DSoundBufferDesc;
DSoundBufferDesc = new
SoundBufferDescription();
DSoundBufferDesc.SizeInBytes = (int)
wavFile.Length;
DSoundBufferDesc.Flags =
SlimDX.DirectSound.BufferFlags.ControlVolume;
DSoundBufferDesc.Format =
Search WWH ::




Custom Search