Software solutions for a mobile world

For one of our apps for Marketplace, I decided I needed to play a sound notification under certain circumstances. I added a reference to Microsoft.Xna.Framework and then

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;

Then the code

private void play_notification()
var stream = TitleContainer.OpenStream("Sounds\\Notify.wav");
var effect = SoundEffect.FromStream(stream);

When I ran the application, on the line var effect = I got the error:-

Ensure that the specified stream contains valid PCM mono or stereo wave data

I tried changing the format 'randomly, but with the same results. I tried a file dragged from my Windows Mobile phone, and that worked fine. After looking at the format, it would appear that you need the following format:

Codec: Microsoft PCM Format
Sample Rate: 11025
Channels: 1(Mono) or 2(Stereo)

Bear in mind if you use Stereo, your file will be twice the size.

Originally posted 29/Sep/2010


M: +44 (0)7860 907493




Twitter Feed