ryansimean
28-07-2008 22:58:04
Ok, I'm sure this really should be quite easy but I have been butting my head against it for a few days now. Probably I'm just approaching this the wrong way, but all I want to do is play a sound when a certain event happens; in this case, a mouse click. The thing is, it works just fine and plays the sound, but always stops after 100 plays. I assume this has something do with soundManager.maxSources being 100, but apparently using self.soundManager.destroySound(sound) doesn't do clear this out / do garbage collection the way I thought it did.
Basically here's the deal:
project/game/gamestates/main.py
project/game/audio.py
If I don't destroySound(s) the thing of course crashes after the first mouseClick, because the sound "sfx" already exists. However, even with destroying the sound it stops playing the sound (no crashing, just silence) after exactly 100 mouse clicks. I assume I'm doing something stupid here since I'm a n00b, but I can't figure out what it is! Ideas?
Basically here's the deal:
project/game/gamestates/main.py
import ogre.sound.OgreAL as OgreAL
from Game.Audio import SFX
def __init__(self):
self.soundManager = OgreAL.soundManager()
self.sfx = SFX(self.soundManager)
def mouseClick(self, evt, buttonID):
soundFile = "sound.ogg"
self.sfx.play(soundFile)
project/game/audio.py
class SFX(object):
def __init__(self, soundManager):
self.soundManager = soundManager
def play(self, soundFile):
s = self.soundManager.createSound("sfx", soundFile, False, False)
s.play()
s.soundManager.destroySound(s)
If I don't destroySound(s) the thing of course crashes after the first mouseClick, because the sound "sfx" already exists. However, even with destroying the sound it stops playing the sound (no crashing, just silence) after exactly 100 mouse clicks. I assume I'm doing something stupid here since I'm a n00b, but I can't figure out what it is! Ideas?