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

Re: [pygame] write sound to file for fast loading?



I think it would be easier to simply use a loading screen before a part of the game (f.e. entering an area) and there load any sounds that might come in use into that part. It surely would be nicer to see than lag during the gameplay. Of course this could not be the best solution, but if there are not better options, this would be the better to use.
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