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

Re: [pygame] How to play a sound from a "file" of infinite size?



On Tue, 2006-02-07 at 06:09 +0100, Tomasz Primke wrote:
> I'd like to write a player, that would be able to play files in some rare
> format. I have a library (written in C), that can be used to play such a
> files, but I'm not sure about the way that I should use PyGame to code my
> player.

You may want to plug into the SDL_mixer library at the C level.
SDL_mixer has a single "streaming" channel. You register a C callback
and a background thread will occasionally call your function with a
request like "put up to 10000 samples of new sound data at this
pointer".

The good news is when you do it through the SDL layer it will run on
just about any platform. It will also allow you to work with all the
different sound drivers on linux.

You could also consider filling Numeric arrays of sound data and
queueing them one at a time directly in Python. If your file format does
not require a lot of processing to get the samples this could be a good
solution.