I tested the cases Clare mentioned, and was able to get the same behavior as her (specifically that doing a pygame.init first, sound would never be heard until after a display was sucessfully created, while doing a pygame.mixer.init first, the sound worked in all cases). Also, if I replace pygame.init with pygame.display.init, same results (display before mixer + no window = no sound)
Ethan seems to have got things pegged with his DirectX comments too... On 10/11/07, Ethan Glasser-Camp <[EMAIL PROTECTED]> wrote: > To force a non-DirectX audio driver, you could try doing something like: > > import pygame, os > os.environ['SDL_AUDIODRIVER'] = waveout' > > before doing any pygame*.init(). As you may have gathered, I have no > idea if this will actually work. > When adding the code Ethan suggested above before pygame.init(), the sound worked for me even if the display wasn't created. So it seems clear to me that Ethan hit the nail on the head - the directX audio backend sets things up in a way that audio can't be played until after a window is created. The docs for pygame.mixer.init allude to this: http://www.pygame.org/docs/ref/mixer.html#pygame.mixer.init It seems though, that as Clare discovered, the directX backend only has that problem if pygame.display.init() is called before pygame.mixer.init(). pygame.init must call SDL in a way that does the display before the mixer. ...Ultimately, it seems to me that if you are making a game, with a window, none of this will matter at all. if you are making something that plays sounds with no window, then either force waveout for windows like Ethan suggested, or call pygame.mixer.init and forget about pygame.init and others.