Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In particular, I'd like to know how to get a set of audio samples that are compatible with the XNA's Sound API classes, such as the DynamicSoundEffectInstance class.

I've used the DynamicSoundEffectInstance class for synthesizer work in XNA before. But now instead of synthesizing my sounds, I'd like to read audio samples directly out of audio files - basically I want to do my own mixing and sequencing of samples into a single DynamicSoundEffectInstance object. I've had subtle timing problems when trying to do sequencing on XNA before using regular timers and Play() calls, so I need more control.

Clearly, XNA already knows how to load sounds, for instance, using the content pipeline and the SoundEffect class. Is the underlying format used by the SoundEffect class the same as the one used by the DynamicSoundEffectInstance class - signed 16 bit interleaved PCM?

In short, how do I reach the point where I can play an audio file using the DynamicSoundEffectInstance class?

share|improve this question
up vote 1 down vote accepted

Take a look at this tutorial. This shows you how to read and play a WAV file with DSEI (with streaming, too).

The same technique can be used for audio in other formats, but you will have to bring your own converter. Google may be able to help if you need to support other formats.

XNA's SoundEffect can use PCM that are (I think) in the same format as DSEI. But it can also accept compressed sound effects in some Microsoft proprietary format. However there does not appear to be any way to access its PCM data directly.

share|improve this answer
I wonder why I didn't notice there was an MSDN article on this already :) That's exactly what I needed, and for my purposes it's fine to support only wave files. – David Gouveia Mar 1 '12 at 8:32
I was half-way through replicating the contents of the tutorial in my answer before I stumbled upon it ;) – Andrew Russell Mar 1 '12 at 8:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.