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

2018-06-07 Thread Alec Bennett
On Thu, Jun 7, 2018 at 7:59 AM, Christopher Night 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("musi

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

2018-06-07 Thread Alec Bennett
> > > > A second solution is to load the sounds in the background of the game, > especially if you're going to launch on a menu where the sounds won't be > needed. You can pre-populate a dictionary with dummy sounds and use a > thread to go through and load each sound into the dictionary while the

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

2018-06-07 Thread Alec Bennett
On Thu, Jun 7, 2018 at 4:21 AM, Greg Ewing wrote: > Alec Bennett wrote: > >> 16 bit wav files. 1411 kbps. About 5 megs each but one is very long (a 13 >> minute medley of all of them, 133 megs). >> > > Okay, I didn't realise they were that big -- I was thinking > short horn sounds, not substantia

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

2018-06-07 Thread Christopher Night
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 fil

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

2018-06-07 Thread Daniel Foerster
It looks like you may have missed the alternative solution in my email. On Thu, Jun 7, 2018, 01:04 Alec Bennett wrote: > > I think the answer that sticks out to me is that if these are musical > horn sounds, you might consider using pygame.mixer.music, which will stream > the sounds as needed. >

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

2018-06-07 Thread Greg Ewing
Alec Bennett wrote: 16 bit wav files. 1411 kbps. About 5 megs each but one is very long (a 13 minute medley of all of them, 133 megs). Okay, I didn't realise they were that big -- I was thinking short horn sounds, not substantial pieces of music! You bring up a good point, I can certainly mak

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

2018-06-07 Thread Alec Bennett
16 bit wav files. 1411 kbps. About 5 megs each but one is very long (a 13 minute medley of all of them, 133 megs). You bring up a good point, I can certainly make them mono. But surely there must be some way to save a preloaded state? On Wed, Jun 6, 2018 at 11:32 PM, Greg Ewing wrote: > Alec

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

2018-06-07 Thread Greg Ewing
Alec Bennett wrote: since it needs to load each of the 20 sounds on startup it takes about 30 seconds to load. I'm running it on a Raspberry Pi, which doesn't help of course. How big are the sound files? Unless they're really enormous, that sounds excessive, even for an R. Pi. What format are