I am using pygame + Twisted. I created a Sound wrapper class whose corresponding parts are here:
class Sound(object): def __init__(self, sound): self.sound = sound self._status_task = task.LoopingCall(self._check_status) self._status_task.start(0.05) def _check_status(self): chans = self.sound.get_num_channels() if chans > 0: logger.debug("'%s' playing on %d channels", self.filename, chans) def play(self): self.sound.play()
What happens, however, is good after playing the sound .get_num_channels() returns a positive number, for example:
2013-07-08 15:13:30,502-DEBUG-engine.sound - 'sounds/foo.wav' playing on 2 channels 2013-07-08 15:13:30,503-DEBUG-engine.sound - 'sounds/bar.wav' playing on 1 channels 2013-07-08 15:13:30,546-DEBUG-engine.sound - 'sounds/foo.wav' playing on 2 channels 2013-07-08 15:13:30,558-DEBUG-engine.sound - 'sounds/bar.wav' playing on 1 channels 2013-07-08 15:13:30,602-DEBUG-engine.sound - 'sounds/foo.wav' playing on 2 channels
Why is this so?
I ask because sometimes the sound does not play at all when I talk about it, and I'm trying to figure it out. I understand that this can help with this error.
source share