Ask and ye shall receive. Here are a couple publicly available files that
demonstrate what appear to be two different problems with sndarray in the
blessed Pygame example.

WAV http://www.freesound.org/samplesViewSingle.php?id=4359 blows up on line
88, "ValueError: shape mismatch: objects cannot be broadcast to a single
shape". This one kinda surprised me.

OGG http://www.freesound.org/samplesViewSingle.php?id=32083 blows up on line
108, "ValueError: buffer size must be a multiple of element size".

Gumm

On Fri, Aug 6, 2010 at 10:28 AM, Lenard Lindstrom <le...@telus.net> wrote:

> I don't know. Try the sndarray example:
>
> python -m pygame.examples.sound_array_demos
>
> Otherwise there is something different about your sound files. Without an
> example that causes the problem there is nothing I can do.
>
> Lenard
>
>
> On 05/08/10 03:45 PM, B W wrote:
>
>> Thanks for responding, Lenard, though it doesn't seem this applies to my
>> problem. The sound file is loaded successfully. I can play() the loaded
>> sound just fine. It is the conversion of the mixer.Sound object to a
>> sndarray.array object that's blowing up.
>>
>> Gumm
>>
>> On Thu, Aug 5, 2010 at 12:26 PM, Lenard Lindstrom <le...@telus.net<mailto:
>> le...@telus.net>> wrote:
>>
>>    Okay, this is technically not a bug. If the string is not a valid
>>    file path then it is assumed to be sound data. This has to be
>>    fixed somehow.
>>
>>    Lenard
>>
>>
>>    On 05/08/10 11:36 AM, Lenard Lindstrom wrote:
>>
>>         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>
>>            <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
>>
>>
>>
>>
>>
>>
>

Reply via email to