Hi Gumm,
You have found a bug. pygame.mixer.Sound does handle ogg/vorbis files.
But it doesn't raise an exception when it can't find the file. Also, on
Windows you may find that calling pygame.init() before
pygame.mixer.init() will prevent playback, no sound. Either remove
pygame.init, place it after pygame.mixer.init or set the SDL_AUDIODRIVER
environment variable to 'waveout'.
Lenard Lindstrom
On 03/08/10 11:03 AM, B W wrote:
Howdy, folks.
Seeking enlightenment. Anyone seen this before, and how do I rassle it
into submission? Docs and web have been unhelpful so far. I'm using
pre-built software packages; been using these for months without any
issues.
This problem occurs with all ogg and wav files. I see that Numpy is
raising the exception, but I can't tell if it's a problem internal to
Numpy or a result of how numpysnd.array is using Numpy.
Summary:
1. load OGG-Vorbis sound file with pygame.mixer.Sound
2. convert sound using pygame.sndarray.array
3. scratch head
<CODE>
import os, sys, numpy, pygame
from pygame.locals import *
pygame.init()
pygame.mixer.init(44100, 16, 2, 1)
sound = pygame.mixer.Sound('../sounds/laser_26667.ogg')
for n,v in [('OS',os.name
<http://os.name>),('Python',sys.version),('Pygame',pygame.version.vernum),
('Numpy',numpy.version.version),('Array
type',pygame.sndarray.get_arraytype())]:
print '%s: %s' % (n,v)
sound_data = pygame.sndarray.array(sound)
</CODE>
C:/Python26/pythonw.exe -u
"C:/cygwin/home/Gumm/devel/python/project/gummball/blah.py"
OS: nt
Python: 2.6.5 (r265:79063, Mar 20 2010, 14:22:52) [MSC v.1500 32 bit
(Intel)]
Pygame: (1, 9, 1)
Numpy: 1.4.1
Array type: numpy
Traceback (most recent call last):
File "C:/cygwin/home/Gumm/devel/python/project/gummball/blah.py",
line 9, in <module>
sound_data = pygame.sndarray.array(sound)
File "C:\Python26\Lib\site-packages\pygame\sndarray.py", line 95, in
array
return numpysnd.array (sound)
File "C:\Python26\Lib\site-packages\pygame\_numpysndarray.py", line
77, in array
return _array_samples(sound, True)
File "C:\Python26\Lib\site-packages\pygame\_numpysndarray.py", line
64, in _array_samples
array = numpy.fromstring (data, typecode)
ValueError: string size must be a multiple of element size
Any assistance appreciated.
Gumm