Audio Lag in pygame

Added by Michael Robertson 228 days ago

Hi,

I've been messing around with some simple code as a practice model for our game Panzer Blitz. This practice was set up with an orb object bouncing around the screen making a sound when it reaches/"hits" the edges of the screen. However once it was run there is a very big problem. There is about a half second delay on the bounce and the sound being played :(. I've looked at setting up the mixer using pre_init, setting parameters like the freq, channels etc. and everything pretty much on the pygame page @ http://www.pygame.org/docs/ref/mixer.html

I've attached a zip file with all the stuff you need please any help with sorting out this lag would be greatly appreciated :D

audioTesting.zip (8.3 KB)


Replies

RE: Audio Lag in pygame - Added by Michael Robertson 194 days ago

Hi guys, I've done loads of looking around on the internet and can not seem to find a solution to this problem. Is there anyone who can help?

RE: Audio Lag in pygame - Added by Derek Stobbs 194 days ago

Hi Michael,

Adding the line pygame.mixer.pre_init(22050, 8, 2, 1024) before pygame.init() seems to fix the lag problem. Note that this means you can only play two sounds at a time, but you can increase the 3rd parameter (channels) if need be.