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

Re: [pygame] SndArray Question



On Sun, 2005-12-04 at 23:00 -0500, Kris Schnee wrote:
> array([[2, 3],
>         [9, 6],
>         [7, 2],
>         [5, 0],
>         [3, 3]],'s')
> 
> What does this data mean, exactly? I assume that since the length 
> depends on the sound's length and each entry is a two-part list, and the 
> pairs of numbers usually are the same, each entry represents stereo 
> frequency data at a point in time. Is this so? If so, where's the volume 
> data?

You are correct about the format. The sound is using signed integers to
represent the audio data. There is no real "volume" for sound sample
data, but if you had an array of oscillating 0/FULL/0/FULL type values
it would give you the loudest possible static.

When the computer is dealing with sound, it really only lowers the
volume of a given sound. It does this by multiplying each sample to a
lower number. You can multiply the values up, but will often run into
"clipping" when you must clamp numbers to the largest possible amount.

You may start with by creating simple sin waves of sample data. You can
turn those into pygame sound objects and listen to them. The frequence
of the wave controls the pitch, and the amplitude will control the
volume.