| |||||||||||
PyWeek - Tips about pygame.mixerHere 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) |
Last Challenge
September 2008 [entries, ratings] Previous March 2008 [entries, ratings] > September 2007 [entries, ratings] April 2007 [entries, ratings] September 2006 [entries, ratings] March 2006 [entries, ratings] (June 2006) August 2005 [entries, ratings] Not logged in Login | ||||||||||
By gcewing on 2007/09/12 00:45:
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.