Sound problems

Hi again,

We’re adding sounds to our game, and have some problems. On various user input we perform an action on the game state and play a sound matching the action. The problem is, that these sounds are not played from time to time. We play each sound like so:

self.openCurtain = loader.loadSfx("../sounds/openCurtain.wav")

It seems completely random and doesn’t seem to have anything to do with the state of the game whatsoever. We are aware that, since the references are thrown away if the above code is excuted in rapid succession, sounds will some times stop playing right after they’ve started. That’s not the problem; they’re simply not played, and this seems to happen a couple of times in a row and then stop, only to happen again later. Are there anything we should be aware of with regards to sounds and the task manager, or any priorities that should be set to ensure the playback of the sounds?


Have you tried increasing your audio-cache-limit?

audio-cache-limit 128

The default is pretty low, 15 or something like that. This is the number of sound objects that are kept simultaneously ready to play; if you exceed this number with active sound objects, some of them may not be able to play.

You can also set the priority of an individual sound object with audioSound.setPriority(). This helps Panda decide which sounds to play when you have exceeded the hardware limit of your sound card. Note that setting them all to the same high priority won’t help you; you have to set some of them lower that you don’t mind not hearing.


That did the trick :smiley:

Strange though, we had nowhere near 16 sounds playing at once, and made sure that sound references were thrown away to garbage collection - but that apparently isn’t done often enough. And earlier we tried keeping each sound effect in storage so we wouldn’t have to load them, but that didn’t work either. Being a Python newbie is tough. Thanks for the help!