我的程序在pygame中加载.wav文件时崩溃了。我没有设法弄清楚出了什么问题,所以我用另一个改变了.wav文件并且它有效。然后我尝试了一堆不同的文件,看看是不是只有一个文件不能正常工作,但事实证明它们中的一些是有效的,有些却没有。在我的媒体播放器上播放时,所有文件都能正常工作。
我在Spyder 2.3.8上运行程序,在Linux上使用Python 3.5.2 64位。
所以我可以输入:
>>> import pygame
>>> pygame.mixer.init(22050, -16, 2, 4096)
>>> bob = pygame.mixer.Sound('beep.wav')
>>> bob.play()
听到一声小小的嘟嘟声时,会得到以下输出:
<Channel object at 0x7fe31f5ca558>
然后我输入几乎完全相同的东西(除了我之前没有达到播放方法,因为它之前崩溃了):
>>> import pygame
>>> pygame.mixer.init(22050, -16, 2, 4096)
>>> bob = pygame.mixer.Sound('spell.wav')
我的控制台会冻结而且我得到了这个(我无法复制粘贴整个东西,因为它太长了):
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]
有关为什么不起作用的任何知识?它可以修复,还是我只能选择有效的.wav文件?