[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Why does pygame.sndarray.make_sound seemingly quadruple the sound duration?



good call, thanks!

On Mon, May 21, 2012 at 3:59 PM, Nicholas Seward
<nicholas.seward@xxxxxxxxx> wrote:
> a = a.astype(numpy.float16)
> should convert the array over for you.
> Note: float16 did not exist prior to numpy1.6.  The default version of
> numpy that I got from the ubuntu repo was only version 1.5.1.
>
> On Mon, May 21, 2012 at 1:29 PM, Mike Lawrence <mike.lwrnc@xxxxxxxxx> wrote:
>> Thanks for your response. Support for your suggestion comes from
>> observation that changing the size from -16 to -8 yields an octupling
>> of the duration. So it seems that pygame.sndarray.make_sound isn't
>> properly accounting for the bit depth of the numpy array.
>>
>> On Mon, May 21, 2012 at 3:03 PM, Nicholas Seward
>> <nicholas.seward@xxxxxxxxx> wrote:
>>> Could it be that a is an array of 64bit floats and each array element
>>> becomes 4 16-bit samples?
>>>
>>> On Mon, May 21, 2012 at 12:54 PM, Mike Lawrence <mike.lwrnc@xxxxxxxxx> wrote:
>>>> The following code:
>>>>
>>>>    import pygame, numpy
>>>>    pygame.mixer.pre_init(frequency=96000,size=-16,channels=1)
>>>>    pygame.init()
>>>>    a = numpy.random.randn(96000)
>>>>    sound = pygame.sndarray.make_sound(a)
>>>>    print sound.get_length()
>>>>
>>>> yields a print-out of 4.0, suggesting that the specified duration of
>>>> 96000 samples at a 96000kHz sampling rate was somehow quadrupled
>>>> somewhere along the way. Any idea what I'm missing here? Or is this a
>>>> bug?