Gabriele Cirulli Gabriele Cirulli - 6 months ago 22
Python Question

Pygame, sounds don't play

I'm trying to play sound files (.wav) with pygame but when I start it I never hear anything.

This is the code:

import pygame

pygame.init()
pygame.mixer.init()
sounda= pygame.mixer.Sound("desert_rustle.wav")

sounda.play()


I also tried using channels but the result is the same

Answer

Your code plays desert_rustle.wav quite fine on my machine (Mac OSX 10.5, Python 2.6.4, pygame 1.9.1). What OS and Python and pygame releases are you using? Can you hear the .wav OK by other means (e.g. open on a Mac's terminal or start on a Windows console followed by the filename/path to the .wav file) to guarante the file is not damaged? It's hard to debug your specific problem (which is not with the code you give) without being able to reproduce it and without having all of these crucial details.