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

Re: [pygame] Re: Some way to pickle or otherwise save a pygame.mixer.Sound object?





On Thu, Jun 7, 2018 at 7:59 AM, Christopher Night <cosmologicon@xxxxxxxxx> wrote:
I recommend saving the sound as a raw buffer. First in a separate script:

sound = pygame.mixer.Sound("music1.wav")
open("music1.buf", "wb").write(sound.get_raw())

Then in your game:
sound = pygame.mixer.Sound(buffer=open("music1.buf", "rb").read())

I found about 4x speedup of reading a large file on my desktop using this method. That may or may not be enough for you, especially if you combine with other tips in this thread.


Very interesting. Will try this when I'm working on this tonight.