Sorry, I left out the line where I try to save the file: > pickle.dump( sound_obj, open( "sound.pickled", "wb" ) )
On Wed, Jun 6, 2018 at 10:29 PM, Alec Bennett <wrybr...@gmail.com> wrote: > I'm building a musical horn for my car with PyGame, and it works > perfectly, but 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. > > I thought I'd simply save the Sound objects as pickle objects, but that > produces an error: > > > sound_obj = pygame.mixer.Sound("whatever.wav") > > > can't pickle Sound objects > > I also tried the dill module (https://github.com/uqfoundation/dill) but > with similar results: > > > sound_obj = pygame.mixer.Sound("whatever.wav") > > > Can't pickle <type 'Sound'>: it's not found as __builtin__.Sound > > I don't imagine can think of some clever way to save the preloaded Sounds, > or otherwise speed up the load times? > > > > >