I would also suggest looking at more of the Numeric built-ins, such as
"fromfunction".
For example, instead of looping to construct a native python list and
then converting to an array, you can do:
arr_float = fromfunction(lambda x,
y:(sin(x*freq*(6.28318/sample_rate)*length)*volume),
(sample_rate * length, 2))
arr_int = arr_float.astype(Int16)
return arr_int
This converts using sndarray just fine, although not if you are
using NumArray for some reason, you have to be using Numeric. The "sin"
function here is from importing Numeric. The type conversion is because
something complained about using the "int" type coercion inside the lambda.