1

I'm working on a game for wp7 and I'm having issues with the sound.

Most of the time, when I play a sound (tap a button or something like that) it plays perfectly. But there are times when, for a period of time the Sound volume decreases dramatically (only the sound volume, I have a background music playing and it sounds fine) and then suddenly it plays with the correct volume.

This problem is absolutely random; there are times when everything goes right so I don't know how to reproduce the bug...

Here's my code for playing the Sounds:

public static void PlaySound(string sound)
{
    SoundEffect s = EngineGame.Sounds[sound];
    currentSound = s.CreateInstance();
    currentSound.Play();
    System.Diagnostics.Debug.WriteLine("Volume: " + currentSound.Volume);
}

by the way that "writeline" always shows 1.0 so the problem is not exactly with the volume itself...

PS: I'm testing the game in a Nokia 710 (if that's relevant)

nemesv
  • 138,284
  • 16
  • 416
  • 359
petrix18
  • 51
  • 5

1 Answers1

1

This is just hit and trail solution : do not create instances of soundeffect every time you want to play that sound. You can directly play the sound by writing the below code

SoundEffect drum; drum = Content.Load("location");

Inside the method just write this code

drum.Play();

Hope it works.