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

[pygame] write sound to file for fast loading?



Howdy, folks.

I have a problem I've been studying a while and I can't figure out a solution. Pygame or SDL--not sure which--is pretty slow at loading sounds. For large sounds, like songs, this means significant pauses in your game; or very long loading times at startup if you have a few of them to load.

I tried using a thread to load a song, but as expected that only resulted in a very laggy game for the duration.

So I was thinking it might be faster to pre-process a song: load it via the mixer, write the buffer to a data file, then later load it into an array and feed the array to the mixer. I can see that part of that idea is implemented in _sndarray.py, but I didn't really want to require numpy and I couldn't see how to convert that module's code to my purpose anyhow.

I'm strikin' out. Is this even feasible, or is it a hair-brained scheme doomed to failure? Has anyone solved this problem, and would s/he be willing to share? :)

Gumm