Reading/writing .wav data

Adam Hupp hupp at upl.cs.wisc.edu
Tue Dec 31 15:11:12 EST 2002


On Mon, 30 Dec 2002 09:34:27 +0000, sj wrote:

> I have figured out how to use wave.open to get an instance of wave.Wave_read 
> and then use wave.readframes(n) to read the first n data frames. The 
> problem is I don't know how to convert the string returned by readframes to 
> something numerically usefull.  I want to convert the string to either a 
> numeric array or list.  The test file I  have been using is a simple 1 
> second sine with sr=44100 and 2 bytes per frame. 

To create a Numeric array you could use the fromstring function (untested,
but it should work):

Numeric.fromstring(wave.readframes(-1),  typecode=Numeric.Int16)

-Adam



More information about the Python-list mailing list