[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pygame sound delay problem



On Thu, Dec 13, 2012 at 1:23 PM, Joshua_Blake <tri_magnus@xxxxxxxxx> wrote:
I have created a basic checkers game using pygame. I have sampled some very
short sounds for use in the game, but there is a 500 to 1000ms delay from
the time I call a sounds play() method to when it actually plays. Some
information: This problem persists from my Windows 7 64-bit desktop and my
Windows XP 32-bit laptop. I am using python 2.7.3 and pygame version 1.9.1.

Some things that I have tried:
* decreasing the buffer-size passed to pygame.mixer.pre_init() from the 4096
default, incrementally down to 128 -- no change. This was the only 'fix'
that I saw repeatedly throughout the internet.
* ensuring that the frequency of the audio samples, channels, and whatnot
all matched up to my pre_init call. I'll admit that I really don't know much
about audio in general.
* created a small sample demo (to rule out my program loop causing the
delay)
* added a call to pygame.time.wait(125) after the call to .play() a sound,
and it does allow the sound to synch with the animation. However, it also
causes a noticeable delay between clicking on the checkers piece and the
actual pickup animation.
* hacked in pyglet as a sound backend. *sigh* it works GREAT, but then will
have some crazy audio artifacts that happen after some number of sounds of
been played, and not every time. I "dont" like this solution, at all. The
artifacts become unbearably noisy and overwhelming if many concurrent sounds
are played, and they never stop.

Nothing has really helped. So, does anyone have any ideas? Any help would be
greatly appreciated!
Well, I can't suggest anything other than the buffer fix.

Can I see the self-contained demo? I'll play with it some and see if I can reproduce it, even if I can't really help another way.

Ian