[Tutor] how to play arrays as audio signal

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Oct 20 03:36:15 CEST 2004

On Tue, 19 Oct 2004, Hans Fangohr wrote:

> I would like to 'acoustically play' values in an array (or list, tupel,
> ...) as if the position of the speaker membrane at different times was
> given by the value in that array. Is there a module (in the best case a
> standard module) that would do this for me? (I will need this on
> Windows.)

Hi Hans,

Your best bet is probably the pygame module:


In fact:


uses Numeric Python arrays to generate sounds.


shows sample code to play a sound out of a Numeric Python array.

However, PyGame has not have adopted 'numarray' yet: it looks like they're
still using the older Numeric Python 'numpy' library.

The switch to 'numarray' appears to be a TODO for the PyGame folks:


Until then, it might be easiest to use Numeric Python's arrays with

Good luck to you!

More information about the Tutor mailing list