0

My program was crashing while loading a .wav file in pygame. I didn't manage to figure out what was wrong, so I changed the .wav file with another and it worked. I then tried a bunch of different ones to see if it was just that one file that wasn't working, but it turns out some of them work and some of them don't. All of the files work fine when played on my media player.

I am running the program from Spyder 2.3.8 with Python 3.5.2 64bits on Linux.

So I might type:

>>> import pygame
>>> pygame.mixer.init(22050, -16, 2, 4096)
>>> bob = pygame.mixer.Sound('beep.wav')
>>> bob.play()

And will get the following output while hearing a nice little beep:

<Channel object at 0x7fe31f5ca558>

But then I type nearly the exact same thing (except I don't even get to the play method because it crashes before):

>>> import pygame
>>> pygame.mixer.init(22050, -16, 2, 4096)
>>> bob = pygame.mixer.Sound('spell.wav')

And my console will freeze and I get this (I couldn't copy paste the whole thing because it's too long):

7f8092fce000-7f8092fcf000 r-xp 00000000 08:02 951168       /usr/lib/python3.5/lib-dynload/_opcode.cpython-35m-x86_64-linux-gnu.so
7f8092fcf000-7f80931ce000 ---p 00001000 08:02 951168       /usr/lib/python3.5/lib-dynload/_opcode.cpython-35m-x86_64-linux-gnu.so
7f80931ce000-7f80931cf000 r--p 00000000 08:02 951168       /usr/lib/python3.5/lib-dynload/_opcode.cpython-35m-x86_64-linux-gnu.so
7f80931cf000-7f80931d0000 rw-p 00001000 08:02 951168       /usr/lib/python3.5/lib-dynload/_opcode.cpython-35m-x86_64-linux-gnu.so
7f80931f1000-7f8093331000 rw-p 00000000 00:00 0 
7f8093331000-7f809373a000 r--p 00000000 08:02 921965       /usr/lib/locale/locale-archive
7f809373a000-7f8093842000 r-xp 00000000 08:02 10002184       /lib/x86_64-linux-gnu/libm-2.23.so
7f8093842000-7f8093a41000 ---p 00108000 08:02 10002184       /lib/x86_64-linux-gnu/libm-2.23.so
7f8093a41000-7f8093a42000 r--p 00107000 08:02 10002184       /lib/x86_64-linux-gnu/libm-2.23.so
7f8093a42000-7f8093a43000 rw-p 00108000 08:02 10002184       /lib/x86_64-linux-gnu/libm-2.23.so
7f8093a43000-7f8093a5c000 r-xp 00000000 08:02 9984920      /lib/x86_64-linux-gnu/libz.so.1.2.8
7f8093a5c000-7f8093c5b000 ---p 00019000 08:02 9984920      /lib/x86_64-linux-gnu/libz.so.1.2.8
7f8093c5b000-7f8093c5c000 r--p 00018000 08:02 9984920      /lib/x86_64-linux-gnu/libz.so.1.2.8
7f8093c5c000-7f8093c5d000 rw-p 00019000 08:02 9984920      /lib/x86_64-linux-gnu/libz.so.1.2.8
7f8093c5d000-7f8093c83000 r-xp 00000000 08:02 9981005      /lib/x86_64-linux-gnu/libexpat.so.1.6.0
7f8093c83000-7f8093e83000 ---p 00026000 08:02 9981005      /lib/x86_64-linux-gnu/libexpat.so.1.6.0
7f8093e83000-7f8093e85000 r--p 00026000 08:02 9981005      /lib/x86_64-linux-gnu/libexpat.so.1.6.0
7f8093e85000-7f8093e86000 rw-p 00028000 08:02 9981005      /lib/x86_64-linux-gnu/libexpat.so.1.6.0
7f8093e86000-7f8093e88000 r-xp 00000000 08:02 9997250      /lib/x86_64-linux-gnu/libutil-2.23.so
7f8093e88000-7f8094087000 ---p 00002000 08:02 9997250      /lib/x86_64-linux-gnu/libutil-2.23.so
7f8094087000-7f8094088000 r--p 00001000 08:02 9997250      /lib/x86_64-linux-gnu/libutil-2.23.so
7f8094088000-7f8094089000 rw-p 00002000 08:02 9997250      /lib/x86_64-linux-gnu/libutil-2.23.so
7f8094089000-7f809408c000 r-xp 00000000 08:02 10002178       /lib/x86_64-linux-gnu/libdl-2.23.so
7f809408c000-7f809428b000 ---p 00003000 08:02 10002178       /lib/x86_64-linux-gnu/libdl-2.23.so
7f809428b000-7f809428c000 r--p 00002000 08:02 10002178       /lib/x86_64-linux-gnu/libdl-2.23.so
7f809428c000-7f809428d000 rw-p 00003000 08:02 10002178       /lib/x86_64-linux-gnu/libdl-2.23.so
7f809428d000-7f809444c000 r-xp 00000000 08:02 10002179       /lib/x86_64-linux-gnu/libc-2.23.so
7f809444c000-7f809464c000 ---p 001bf000 08:02 10002179       /lib/x86_64-linux-gnu/libc-2.23.so
7f809464c000-7f8094650000 r--p 001bf000 08:02 10002179       /lib/x86_64-linux-gnu/libc-2.23.so
7f8094650000-7f8094652000 rw-p 001c3000 08:02 10002179       /lib/x86_64-linux-gnu/libc-2.23.so
7f8094652000-7f8094656000 rw-p 00000000 00:00 0 
7f8094656000-7f809466e000 r-xp 00000000 08:02 10002185       /lib/x86_64-linux-gnu/libpthread-2.23.so
7f809466e000-7f809486d000 ---p 00018000 08:02 10002185       /lib/x86_64-linux-gnu/libpthread-2.23.so
7f809486d000-7f809486e000 r--p 00017000 08:02 10002185       /lib/x86_64-linux-gnu/libpthread-2.23.so
7f809486e000-7f809486f000 rw-p 00018000 08:02 10002185       /lib/x86_64-linux-gnu/libpthread-2.23.so
7f809486f000-7f8094873000 rw-p 00000000 00:00 0 
7f8094873000-7f8094899000 r-xp 00000000 08:02 9993856      /lib/x86_64-linux-gnu/ld-2.23.so
7f80948ab000-7f8094a70000 rw-p 00000000 00:00 0 
7f8094a8d000-7f8094a8e000 rw-p 00000000 00:00 0 
7f8094a8e000-7f8094a8f000 rwxp 00000000 00:00 0 
7f8094a8f000-7f8094a96000 r--s 00000000 08:02 1323058      /usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache
7f8094a96000-7f8094a98000 rw-p 00000000 00:00 0 
7f8094a98000-7f8094a99000 r--p 00025000 08:02 9993856      /lib/x86_64-linux-gnu/ld-2.23.so
7f8094a99000-7f8094a9a000 rw-p 00026000 08:02 9993856      /lib/x86_64-linux-gnu/ld-2.23.so
7f8094a9a000-7f8094a9b000 rw-p 00000000 00:00 0 
7ffd82f83000-7ffd82fa4000 rw-p 00000000 00:00 0      [stack]
7ffd82faf000-7ffd82fb1000 r--p 00000000 00:00 0      [vvar]
7ffd82fb1000-7ffd82fb3000 r-xp 00000000 00:00 0      [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0      [vsyscall]

Any knowledge on why this is not working? Can it be fixed or must I only choose .wav files which work?

  • If this helps the only pattern I found in the faulty files were that they were produced by Pro Tools... – Thomas Delacroix May 18 '17 at 20:40
  • it may be helpful to upload a working and not working wav file somewhere so they can be viewed in detail – Nick is tired May 18 '17 at 21:44
  • Here are two files as @NickA requested (beep works, spell doesn't) [link] (https://drive.google.com/drive/folders/0B2dXw1jpCyKjbUZnMmpJeFNaUHM?usp=sharing) – Thomas Delacroix May 19 '17 at 07:33
  • Your file `spell.wav` seems to be a Broadcast Wave Format (BWF) file. You can open it in Python e.g. with the [soundfile](http://pysoundfile.readthedocs.io/) module, or you can convert it to a "normal" WAV beforehand (e.g. with [SoX](http://sox.sourceforge.net/)). – Matthias May 19 '17 at 09:23
  • Thanks a lot @Matthias, that did the trick! – Thomas Delacroix May 19 '17 at 18:44

0 Answers0