add startTime

This commit is contained in:
David Rose 2002-09-05 03:17:43 +00:00
parent 649fb5d0ca
commit 699d35618d

View File

@ -18,7 +18,7 @@ class SoundInterval(Interval.Interval):
# seems to be some timing in the audio such that the stop doesn't # seems to be some timing in the audio such that the stop doesn't
# kill the looping sound until the next time around if duration # kill the looping sound until the next time around if duration
# of the interval equals duration of the sound # of the interval equals duration of the sound
def __init__(self, sound, loop = 0, duration = 0.0, name = None, volume = 1.0): def __init__(self, sound, loop = 0, duration = 0.0, name = None, volume = 1.0, startTime = 0.0):
"""__init__(sound, loop, name) """__init__(sound, loop, name)
""" """
# Generate unique name # Generate unique name
@ -28,9 +28,10 @@ class SoundInterval(Interval.Interval):
self.sound = sound self.sound = sound
self.loop = loop self.loop = loop
self.volume = volume self.volume = volume
self.startTime = startTime
# If no duration given use sound's duration as interval's duration # If no duration given use sound's duration as interval's duration
if duration == 0.0 and self.sound != None: if duration == 0.0 and self.sound != None:
duration = self.sound.length() duration = self.sound.length() - self.startTime
if (duration == 0): if (duration == 0):
self.notify.warning('zero length duration!') self.notify.warning('zero length duration!')
# MPG - hack for Miles bug # MPG - hack for Miles bug
@ -57,13 +58,14 @@ class SoundInterval(Interval.Interval):
# IVAL_INIT event, start new sound # IVAL_INIT event, start new sound
# If its within a 10th of a second of the start, # If its within a 10th of a second of the start,
# start at the beginning # start at the beginning
if (t < 0.1): t1 = t + self.startTime
t = 0.0 if (t1 < 0.1):
t1 = 0.0
if self.sound: if self.sound:
# Start sound # Start sound
self.sound.setTime(t)
self.sound.setLoop(self.loop)
self.sound.setVolume(self.volume) self.sound.setVolume(self.volume)
self.sound.setTime(t1)
self.sound.setLoop(self.loop)
self.sound.play() self.sound.play()
# Print debug information # Print debug information