[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?



First: the file format, that the C library decodes, requires a lot of 
processing - therefore the idea to make samples in pure C and then to wrap 
it all with Python (e.g. with Pyrex) sounds... reasonable. But it will be 
the last resort. My philosophy of programming is to use Python as long, as 
it's fast enough; then use Pyrex as long, as it's fast enough; and as the 
last resort, use C.

This single "streaming" channel looks realy interesting. And use of the 
SDL_mixer library would be very portable solution (I like it!). But 
wouldn't that collide with the PyGame? I need PyGame to make this player 
look nice.

Dnia wtorek 07 luty 2006 17:29, Peter Shinners napisał:
> 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.