From 8a44e44a355b1c8aa1f0c2f6abb7476820d2f369 Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Thu, 14 Dec 2006 01:52:40 +0000 Subject: [PATCH] first rev --- direct/src/showbase/PositionalSound.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 direct/src/showbase/PositionalSound.py diff --git a/direct/src/showbase/PositionalSound.py b/direct/src/showbase/PositionalSound.py new file mode 100755 index 0000000000..f46c46c7d9 --- /dev/null +++ b/direct/src/showbase/PositionalSound.py @@ -0,0 +1,20 @@ +from direct.interval.IntervalGlobal import * +from pandac.PandaModules import NodePath +import random + +class PositionalSound: + def __init__(self, soundPath, node, volume=None): + if volume is None: + volume = 1. + self._sound = base.loadSfx(soundPath) + self._ival = SoundInterval(self._sound, node=node, volume=volume) + self.start() + def destroy(self): + self._ival.pause() + del self._ival + del self._sound + def start(self): + self._ival.loop() + self._ival.setT(random.random() * self._sound.length()) + def stop(self): + self._ival.stop()