[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] Timing...
> The only problems are that I want to avoid calling *anything* every frame,
> and there can't be any delay between sounds even at 60fps - unfortunately
> the ear is really good at picking that stuff up, especially is speech.
> (I'll give it a try anyway!)
Why don't you simply use threading for this?
Some more risky brain code (building on pete's code):
import thread
class SoundSequence:
"plays a sequence of sounds in order"
def __init__(self, *sounds):
"pass a sequence of Sound objects"
self.channel = pygame.mixer.play(sounds[0])
self.sounds = sounds[1:]
thread.start_new_thread(self.update,())
def update(self):
"call once per frame"
if self.channel and self.channel.get_busy():
if self.sounds:
channel.play(self.sounds[0])
self.sounds = self.sounds[1:]
else:
self.channel = None
return self.get_busy()
def get_busy(self):
"query if sounds are still playing"
return self.channel is not None
Then you would only make one instance of this class and that's it.. no
more framebased calling.. just my $.02
> (hey, is it enough for a code repository entry?)
heh.. now it is :P
j/k
HTH
--
Raiser, Frank aka CrashChaos
IRC: 141.30.225.9:6667 #United-Programmers
MS Office XP - the more money I give to Microsoft,
the more vulnerable my Windows computers are
-- Georgi Guninski
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org