[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] reserving an audio channel?



Hi gang,

Most of the sounds I've used in my games so far are short, fire'n'forget thingies.  I manually grab a channel (so I can do stereo effects) with pygame.mixer.find_channel(True) so that if there are no available channels, it will grab the longest-running busy one.

Now I've got a sound effect that I want to continue looping under certain conditions.  Unfortunately, since this quickly ends up being the longest-running busy channel, it always ends up getting appropriated by another sound.

What I'd like to do is essentially "lock" this one channel where I'm playing the long-running sample.  I see pygame.mixer.set_reserved(), but that just takes a number of channels to reserve;  How do I specify that I want to lock just *this* channel?  Do I need to first grab my channel and then call set_reserved(1) before any other sound stuff?  That seems sort of convoluted...  Also, the documentation says that "calling Sound.play() will not use the reserved channels."  Does that apply to find_channel() as well?

TIA,

--
// jack
// http://www.nuthole.com