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

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



2010/2/2 机械唯物主义 <linjunhalida@xxxxxxxxx>:
> emmm...
>
> large music file ---> longger loading time..
> the file is not buffered?
>
> can you post a sample code ?

Well I just asumed music was being streamed from disc in pygame.music:

import pygame
pygame.init()
pygame.music.load('some_file.ogg')
pygame.music.play()

I have never used pygame.music with .ogg files larger than 5 mb, so I
cannot say whether my assumption is valid or not.

What file format are you using?

>
> On Tue, Feb 2, 2010 at 3:24 PM, Olof Bjarnason <olof.bjarnason@xxxxxxxxx> wrote:
>> 2010/2/2 B W <stabbingfinger@xxxxxxxxx>:
>>> 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.
>>
>> Tried pygame music?
>>
>> http://www.pygame.org/docs/ref/music.html
>>
>>>
>>> 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
>>>
>>
>>
>>
>> --
>> http://olofb.wordpress.com
>>
>



-- 
http://olofb.wordpress.com