[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [pygame] Timing...
Unless I'm missing something, I don't know why threading would help.
In this case, things will be even worse than calling per frame, because
100% of whatever the CPU can muster for this thread, virtually grinding the
game to a halt.
Adding a time.sleep(ms_wait) would be an option to give the game some
ticks - but in any case you
still need to wait for get_busy to return false, at which time it's too late
for a sample to appear again in time. (Even a done event would suffer the
but at least take no CPU during the play.)
All the buffers need to be added before the
channel ever stops playing - then there's no reason for a spin-wait
I suppose I'm too picky comming from a speech background - if you're
just doing sound f/x or you're willing to have the thing sound like most
systems, these schemes should be okay if you have enough CPU to spare.
From: email@example.com [mailto:firstname.lastname@example.org]On
Behalf Of Frank Raiser
Sent: Friday, July 27, 2001 1:16 PM
Subject: 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):
"plays a sequence of sounds in order"
def __init__(self, *sounds):
"pass a sequence of Sound objects"
self.channel = pygame.mixer.play(sounds)
self.sounds = sounds[1:]
"call once per frame"
if self.channel and self.channel.get_busy():
self.sounds = self.sounds[1:]
self.channel = None
"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
Raiser, Frank aka CrashChaos
IRC: 188.8.131.52: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
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
pygame mailing list