April 15th, 2013, 04:43 PM
I am having a problem playing music in pygame, the file is a wav and I've never had this problem - so here is all the code.
Everything else works, but the console returns the error
import pygame, sys, time
pygame.display.set_caption("Star Citizen - A Roguelike game")
SWidth = 1280
SHeight = 1024
Screen = pygame.display.set_mode((SWidth, SHeight), 0, 32)
mmi = ("C:\\Python_Game\\Graphics\\SC_Logo.png")
BGI = pygame.image.load(mmi).convert()
for event in pygame.event.get():
if event.type == pygame.QUIT:
I use Sony Vegas 12 to render my sounds, and was wandering if pygame only supports a specific sound 'quality', if you will. Could this be the problem?
Traceback (most recent call last):
File "C:\Python_Game\MainGame.py", line 28, in <module>
File "C:\Python_Game\MainGame.py", line 17, in Main
pygame.error: Unable to load WAV file
April 15th, 2013, 05:51 PM
On my system, if the file isn't found I get a different error.
pygame.error: Couldn't open 'blah blah blah'
[/code] are essential for python code and Makefiles!
April 15th, 2013, 05:57 PM
My computer knows where the file is, as it turns out the error you stated if I deliberately make the wrong file path. The problem with mine is it wont load it and I don't know why
Originally Posted by b49P23TIvg
April 15th, 2013, 09:37 PM
Try throwing this after the imports and see if it helps:
although that should get initialized when you call pygame.init() anyway.
Not sure if this is the problem though. It sounds more like pygame doesn't like your particular wav file. Next step would be to try opening the file and resaving it with another application.
You also might want to look into pygame.mixer.pre_init() although again I don't think this is actually the problem here.
April 16th, 2013, 01:00 AM
Kudos on you sir for making a roguelike game, I've been playing nethack for the last ten years and it's still one of my favourite games of all time.
As Mekire is saying, try experimenting with pygame.mixer.init(), you might have to put in a few arguments depending on the frequency of the sample and such.
April 16th, 2013, 01:01 PM
I finally resolved the problem in the end after ALOT of experimentation, and the problem was indeed with the wav file like I and you guys suspected. The sound quality is now lower (But I like it more this way), however, for those who may be interested and are suffering a similar problem the render specifications that work are as follows (Or so I believe with the default pygame mixer options):
Audio: 48,000 Hz, 16 Bit, Stereo, PCM
Format = PCM (Uncompressed)
Bit Depth = 16 Bit
Channels = Stereo
Sample Rate = 48,000 Hz
Hope that helps some people.