Re: [pygame] #pygame on irc.freenode.net

2008-02-18 Thread Marcus von Appen
On, Tue Feb 19, 2008, Devin Jeanpierre wrote:

> Hey guys, the channel #pygame on irc.freenode.net is deregistered, and
> it'd be nice if somebody from the pygame project could take it over.
> ATM it's inhabited by trolls and so on that don't really give a good
> impression of Pygame at all ("What I'm saying is, you're an idiot.",
> "All 14 year olds have assburgers", etc.). It'd just be very nice if
> somebody could take back the channel and kick the trolls.

Just put them on your /ignore list, if you do not like a free discussion
style :-).

Regards
Marcus


pgptmvEWkWUJd.pgp
Description: PGP signature


[pygame] #pygame on irc.freenode.net

2008-02-18 Thread Devin Jeanpierre
Hey guys, the channel #pygame on irc.freenode.net is deregistered, and
it'd be nice if somebody from the pygame project could take it over.
ATM it's inhabited by trolls and so on that don't really give a good
impression of Pygame at all ("What I'm saying is, you're an idiot.",
"All 14 year olds have assburgers", etc.). It'd just be very nice if
somebody could take back the channel and kick the trolls.


Re: [pygame] Re: Check Sound status in Pygame

2008-02-18 Thread Wyatt Olson

Wonderful!  This seems to do the trick.

Thanks for the tip.

Lenard Lindstrom wrote:
It seems you need to do your own channel management. It is easiest 
show with a code sample. Note this is untested.


#  A queue of channels from oldest to newest
channel_queue = []

def play_sound(sound):
   """Play a sound

   If all channels are busy then reuse the channel that was playing 
the longest.

   """

   for i, c in enumerate(channel_queue):
   if not c.get_busy():
   channel = channel_queue.pop(i)
   break
   else:
   if len(channel_queue) < pygame.mixer.get_num_channels():
   channel = Channel(len(channel_queue))
   else:
   channel = channel_queue.pop(0)
   channel.play(sound)
   channel_queue.append(channel)


Lenard

Wyatt Olson wrote:


OK, I found the method get_num_channels which seems to do this.  
However, I now need to be able to stop playing oldest sounds if I 
wish, to clear out space for other ones.  For instance, assume that I 
have 16 channels defined.  I am trying to play 30 notes on the ride 
cymbal in a 5 second interval.  The ride cymbal sample is 10 seconds 
long.  Without stopping sounds, once I play the sample 16 times, I 
cannot play any more until one of the samples finished playing.  What 
I would like to do is check how many samples are playing, and if the 
count is greater than some threshold, stop the oldest instance of the 
playing sound.  I can't seem to find any way to stop a single 
*instance* of a sound - if you call stop() or fadeout(), all 
instances of the sound will be stopped.  I realize that this 
requirement is a bit more unique for my application, but I imagine 
that manipulating individual instances of existing sounds can be 
useful to anyone.


Please let me know if I am missing something else which should be 
obvious to me.


Cheers

Wyatt Olson wrote:

Hello all,

I am developing a drum sequencer program using Pygame, and have a 
(hopefully easy) architectural question for you.  How can you tell 
if a Sound object is currently playing? (On any channel - I don't 
care where it is playing, I just want to know if it is).  There is 
no 'is_playing()' or similar method which I could find.  I imagine 
that this is a pretty common request, so I must be just missing 
something.


Thanks!








signature.asc
Description: OpenPGP digital signature


Re: [pygame] Re: Check Sound status in Pygame

2008-02-18 Thread Lenard Lindstrom
It seems you need to do your own channel management. It is easiest show 
with a code sample. Note this is untested.


#  A queue of channels from oldest to newest
channel_queue = []

def play_sound(sound):
   """Play a sound

   If all channels are busy then reuse the channel that was playing the 
longest.

   """

   for i, c in enumerate(channel_queue):
   if not c.get_busy():
   channel = channel_queue.pop(i)
   break
   else:
   if len(channel_queue) < pygame.mixer.get_num_channels():
   channel = Channel(len(channel_queue))
   else:
   channel = channel_queue.pop(0)
   channel.play(sound)
   channel_queue.append(channel)


Lenard

Wyatt Olson wrote:


OK, I found the method get_num_channels which seems to do this.  
However, I now need to be able to stop playing oldest sounds if I 
wish, to clear out space for other ones.  For instance, assume that I 
have 16 channels defined.  I am trying to play 30 notes on the ride 
cymbal in a 5 second interval.  The ride cymbal sample is 10 seconds 
long.  Without stopping sounds, once I play the sample 16 times, I 
cannot play any more until one of the samples finished playing.  What 
I would like to do is check how many samples are playing, and if the 
count is greater than some threshold, stop the oldest instance of the 
playing sound.  I can't seem to find any way to stop a single 
*instance* of a sound - if you call stop() or fadeout(), all instances 
of the sound will be stopped.  I realize that this requirement is a 
bit more unique for my application, but I imagine that manipulating 
individual instances of existing sounds can be useful to anyone.


Please let me know if I am missing something else which should be 
obvious to me.


Cheers

Wyatt Olson wrote:

Hello all,

I am developing a drum sequencer program using Pygame, and have a 
(hopefully easy) architectural question for you.  How can you tell if 
a Sound object is currently playing? (On any channel - I don't care 
where it is playing, I just want to know if it is).  There is no 
'is_playing()' or similar method which I could find.  I imagine that 
this is a pretty common request, so I must be just missing something.


Thanks!