aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/scripts/buffer.py
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2007-03-07 13:40:14 +0000
committerThomas Grill <xovo@users.sourceforge.net>2007-03-07 13:40:14 +0000
commit03c7468fcc51888c8271b904e4d6400ed5c1cbb1 (patch)
tree411627e2da0f574bba30fb6d6a5b772bff07e448 /externals/grill/py/scripts/buffer.py
parent2f2aaa03a0ace959c6ff911d8b11b45f143c7d6e (diff)
multiply inlets for py (hot and cold inlets)
small optimizations and fixes use PyGILState_\*() functionality (enabled with PY_USE_GIL) updates for DSP processing __str__ method for pyext, to enable print self calls added message bundle functionality (pyext.Bundle class) enable compiled-only scripts (without .py) enable optimization of Python code in reease build let _inlets and _outlets default to 0 fix for numpy some ASSERTs for explicitly created pyext classes (should be runtime checks i guess) open editor for script under OS X fixing numpy initialization quirks enable symbol binding for all callables (not only functions and methods) _isthreaded is now a data member instead of a method fix for gcc4 added pyext._list and pyext._tuple to convert input lists to Python sequence objects enable module packages (module/__init__.py[co]), now also for Max python-like dotted module.function syntax cleaned up float vs. int pyext tags compiler flag to exclude DSP objects some optimizations and py reload fix more safety for calls where association python-pd has already been removed always run Python interpreter in the background svn path=/trunk/; revision=7474
Diffstat (limited to 'externals/grill/py/scripts/buffer.py')
-rw-r--r--externals/grill/py/scripts/buffer.py120
1 files changed, 60 insertions, 60 deletions
diff --git a/externals/grill/py/scripts/buffer.py b/externals/grill/py/scripts/buffer.py
index 2bd36203..46c47991 100644
--- a/externals/grill/py/scripts/buffer.py
+++ b/externals/grill/py/scripts/buffer.py
@@ -1,60 +1,60 @@
-# py/pyext - python script objects for PD and MaxMSP
-#
-# Copyright (c) 2002-2005 Thomas Grill (gr@grrrr.org)
-# For information on usage and redistribution, and for a DISCLAIMER OF ALL
-# WARRANTIES, see the file, "license.txt," in this distribution.
-#
-
-"""This is an example script for the py/pyext object's buffer support.
-
-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
-
-try:
- import pyext
-except:
- print "ERROR: This script must be loaded by the PD/Max py/pyext external"
-
-try:
- from numarray import *
-except:
- print "Failed importing numarray module:",sys.exc_value
-
-def mul(*args):
- # create buffer objects
- # as long as these variables live the underlying buffers are locked
- c = pyext.Buffer(args[0])
- a = pyext.Buffer(args[1])
- b = pyext.Buffer(args[2])
-
- # 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[:]
-
-def add(*args):
- c = pyext.Buffer(args[0])
- a = pyext.Buffer(args[1])
- b = pyext.Buffer(args[2])
-
- # this is also possible, but is probably slower
- # 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
-
-def fadein(target):
- a = pyext.Buffer(target)
- # in place operations are ok
- a *= arange(len(a),type=Float32)/len(a)
-
-def neg(target):
- a = pyext.Buffer(target)
- # in place transformation (see Python array ufuncs)
- negative(a[:],a[:])
- # must mark buffer content as dirty to update graph
- # (no explicit assignment occurred)
- a.dirty()
+# py/pyext - python script objects for PD and MaxMSP
+#
+# Copyright (c) 2002-2005 Thomas Grill (gr@grrrr.org)
+# For information on usage and redistribution, and for a DISCLAIMER OF ALL
+# WARRANTIES, see the file, "license.txt," in this distribution.
+#
+
+"""This is an example script for the py/pyext object's buffer support.
+
+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
+
+try:
+ import pyext
+except:
+ print "ERROR: This script must be loaded by the PD/Max py/pyext external"
+
+try:
+ from numarray import *
+except:
+ print "Failed importing numarray module:",sys.exc_value
+
+def mul(*args):
+ # create buffer objects
+ # as long as these variables live the underlying buffers are locked
+ c = pyext.Buffer(args[0])
+ a = pyext.Buffer(args[1])
+ b = pyext.Buffer(args[2])
+
+ # 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[:]
+
+def add(*args):
+ c = pyext.Buffer(args[0])
+ a = pyext.Buffer(args[1])
+ b = pyext.Buffer(args[2])
+
+ # this is also possible, but is probably slower
+ # 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
+
+def fadein(target):
+ a = pyext.Buffer(target)
+ # in place operations are ok
+ a *= arange(len(a),type=Float32)/len(a)
+
+def neg(target):
+ a = pyext.Buffer(target)
+ # in place transformation (see Python array ufuncs)
+ negative(a[:],a[:])
+ # must mark buffer content as dirty to update graph
+ # (no explicit assignment occurred)
+ a.dirty()