From 7b21867fc1b9af84cd0f097b71f3bf456c9b5afd Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Fri, 25 Mar 2005 04:54:17 +0000 Subject: fixes for maxmsp added generic numpy support (not working) svn path=/trunk/; revision=2645 --- externals/grill/py/scripts/buffer.py | 16 ++++++++-------- externals/grill/py/scripts/sig.py | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'externals/grill/py/scripts') diff --git a/externals/grill/py/scripts/buffer.py b/externals/grill/py/scripts/buffer.py index 19b6f5d3..2bd36203 100644 --- a/externals/grill/py/scripts/buffer.py +++ b/externals/grill/py/scripts/buffer.py @@ -7,9 +7,9 @@ """This is an example script for the py/pyext object's buffer support. -PD/Max buffers can be mapped to numarray arrays. -For numarray see http://numeric.scipy.org -It will probably once be replaced by Numeric(3) +PD/Max buffers can be mapped to Python arrays. +Currently, there are three implementations: +Numeric, numarray and Numeric3 (for all of them see http://numeric.scipy.org) """ import sys @@ -19,7 +19,7 @@ try: except: print "ERROR: This script must be loaded by the PD/Max py/pyext external" -try: +try: from numarray import * except: print "Failed importing numarray module:",sys.exc_value @@ -31,7 +31,7 @@ def mul(*args): a = pyext.Buffer(args[1]) b = pyext.Buffer(args[2]) - # slicing causes numarrays (mapped to buffers) to be created + # slicing causes Python arrays (mapped to buffers) to be created # note the c[:] - to assign contents you must assign to a slice of the buffer c[:] = a[:]*b[:] @@ -41,8 +41,8 @@ def add(*args): b = pyext.Buffer(args[2]) # this is also possible, but is probably slower - # the + converts a into a numarray, the argument b is taken as a sequence - # depending on the implementation in numarray this may be as fast + # the + converts a into a Python array, the argument b is taken as a sequence + # depending on the implementation this may be as fast # as above or not c[:] = a+b @@ -53,7 +53,7 @@ def fadein(target): def neg(target): a = pyext.Buffer(target) - # in place transformation (see numarray ufuncs) + # in place transformation (see Python array ufuncs) negative(a[:],a[:]) # must mark buffer content as dirty to update graph # (no explicit assignment occurred) diff --git a/externals/grill/py/scripts/sig.py b/externals/grill/py/scripts/sig.py index 0eac237a..23fc4c60 100644 --- a/externals/grill/py/scripts/sig.py +++ b/externals/grill/py/scripts/sig.py @@ -48,8 +48,8 @@ class gain2(pyext._class): gain = 0 def _dsp(self): - # cache vectors - self.invec =self._invec(0) + # cache vectors in this scope + self.invec = self._invec(0) self.outvec = self._outvec(0) # initialize _signal method here for optimized version if self.invec is self.outvec: -- cgit v1.2.1