aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/scripts
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2005-03-09 04:58:11 +0000
committerThomas Grill <xovo@users.sourceforge.net>2005-03-09 04:58:11 +0000
commite854889b99b9e515dc69d237b1031b5705e83b60 (patch)
tree6b525184d850f15012e316ca51cf0a11563261ea /externals/grill/py/scripts
parent9ccbbc943fa25426542b4fb6d6bc280c3281001b (diff)
fixes for detached operation and single-threaded version
use lock count instead of message queuing to avoid py->py messaging deadlock support for buffer objects (preliminary) updated build system little restructuring fixes for single-threaded compilation added support for numarray svn path=/trunk/; revision=2610
Diffstat (limited to 'externals/grill/py/scripts')
-rw-r--r--externals/grill/py/scripts/buffer.py46
-rw-r--r--externals/grill/py/scripts/threads.py4
2 files changed, 49 insertions, 1 deletions
diff --git a/externals/grill/py/scripts/buffer.py b/externals/grill/py/scripts/buffer.py
new file mode 100644
index 00000000..4c81caab
--- /dev/null
+++ b/externals/grill/py/scripts/buffer.py
@@ -0,0 +1,46 @@
+# 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 imported to and exported from numarray arrays.
+For numarray see http://numeric.scipy.org
+It will probably once be replaced by Numeric
+
+- _import(buffer): copy contents from the buffer to a new numarray object
+- _export(buffer,numarray): export contents of numarray object to the buffer
+"""
+
+import sys
+
+try:
+ import pyext
+except:
+ print "ERROR: This script must be loaded by the PD/Max pyext external"
+
+try:
+ from numarray import *
+except:
+ print "Failed importing numarray module:",sys.exc_value
+
+def mul(*args):
+ c = pyext.Buffer(args[0])
+ dst = c.array()
+ dst[:] = 0
+ a = pyext.Buffer(args[1]).array()
+ b = pyext.Buffer(args[2]).array()
+ dst += a*b
+ c.dirty()
+
+def add(*args):
+ c = pyext.Buffer(args[0])
+ dst = c.array()
+ dst[:] = 0
+ a = pyext.Buffer(args[1]).array()
+ b = pyext.Buffer(args[2]).array()
+ dst += a+b
+ c.dirty()
diff --git a/externals/grill/py/scripts/threads.py b/externals/grill/py/scripts/threads.py
index e1a91351..b0299101 100644
--- a/externals/grill/py/scripts/threads.py
+++ b/externals/grill/py/scripts/threads.py
@@ -39,7 +39,9 @@ class ex1(pyext._class):
def bang_(self,n):
for i in xrange(self.loops):
# if _shouldexit is true, the thread ought to stop
- if self._shouldexit: break
+ if self._shouldexit:
+ print "BREAK"
+ break
self._outlet(n,i)
sleep(self.sltime)