PyWeek - Tips about pygame.mixer

Here are a couple of things I've learned about using pygame.mixer in the last couple of days. I'm posting them here in case they're of benefit to anyone.

gcewing on 2007/09/10 00:35 of 555-BOOM!


Comments: (log in to comment)

Further investigation reveals that the buffer doesn't have to be small, it just has to be a submultiple of the frame time.

E.g. for a frame time of 50ms and a sample rate of 22050, a buffer size of 1102 bytes works well, but 1024 doesn't.

I'm guessing that pygame.mixer can only start playing a sound on a buffer boundary, so if the time to play a buffer's worth of sound isn't coordinated with the frame time, they drift in and out of phase and you get unpredictable sound start times.