I'm using pygame and I'm trying to play wav files but it's not going great. Code is as simple as:

import pygame

but I'm still having I've only managed to play a mono wav file (less than 500KB in

I couldn't play a 44100 Hz, 16bit, stereo file, got this error:

*** glibc detected *** python: double free or corruption (!prev): 0x01b1f1fa8

I've split channels, deleted one and saved the same wav file as mono and the sound plays but I head a pop at the start and end of playback and get this message:

ALSA lib pcm.c:7339(snd_pcm_recover) underrun occurred

I've tried different variants for the pygame.mixer.init() call with various wav settings(frequency, bit depth, channels, buffer) but with no luck so far. Also, I've done an apt-get update and upgrade just in case, and no change.

Are all wav files supported ? If not what are the limitations ?

2 Answers 2


I've tested with multiple WAV formats and the important part might be having a signed WAV file (as opposed to unsigned or other options).

For example in Audacity the format would be WAV (Microsoft) signed 16 bit PCM.

The WAV I'm using which pygame plays nicely is reported by aplay as

Signed 16 bit Little Endian, Rate 44100Hz, Stereo

And slightly off topic, since I couldn't find a volume slider in the desktop interface I've set the volume to full using:

amixer cset numid=1 400
*** glibc detected *** python: double free or corruption (!prev): 0x01b1f1fa8

This should not happen with python even if you are using it improperly. If it does, it strongly implies a bug in the implementation or a module you are using.

This is because "double free or corruption" happens when you try to do something that you could not possibly do with python itself, or at least, not unless you compiled a routine to do from native C. However, as just mentioned, it is something that could happen due to a bug in the C source for the interpreter or (more likely) a module which was built partially from C (such as, I'd presume, pygame) and not pure python.

Probably not something you can do much about beyond reporting the bug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.