aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/py/scripts')
-rw-r--r--externals/grill/py/scripts/script.py12
-rw-r--r--externals/grill/py/scripts/sig.py64
2 files changed, 67 insertions, 9 deletions
diff --git a/externals/grill/py/scripts/script.py b/externals/grill/py/scripts/script.py
index 88f7afd2..ff41730f 100644
--- a/externals/grill/py/scripts/script.py
+++ b/externals/grill/py/scripts/script.py
@@ -28,17 +28,11 @@ def strlen(arg):
def strcat(*args):
"""Concatenate several symbols"""
- s = ""
- for si in args:
- s += str(si)
- return s
-
+ return reduce(lambda a,b: a+str(b), args,"")
def addall(*args): # variable argument list
- s = 0
- for si in args:
- s += si
- return s
+ """Add a couple of numbers"""
+ return reduce(lambda a,b: a+b, args,0)
def ret1():
diff --git a/externals/grill/py/scripts/sig.py b/externals/grill/py/scripts/sig.py
new file mode 100644
index 00000000..8dccf5fe
--- /dev/null
+++ b/externals/grill/py/scripts/sig.py
@@ -0,0 +1,64 @@
+# 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 signal support.
+
+For numarray see http://numeric.scipy.org
+It will probably once be replaced by Numeric(3)
+"""
+
+try:
+ import pyext
+except:
+ print "ERROR: This script must be loaded by the PD/Max py/pyext external"
+
+try:
+ import psyco
+ psyco.full()
+ print "Using JIT compilation"
+except:
+ # don't care
+ pass
+
+import sys,math
+
+try:
+ import numarray
+except:
+ print "Failed importing numarray module:",sys.exc_value
+
+
+class gain(pyext._class):
+ """Just a simple gain stage"""
+
+ gain = 0
+
+ def _signal(self):
+ # Multiply input vector by gain and copy to output
+ self._outvec(0)[:] = self._invec(0)*self.gain
+
+
+class pan(pyext._class):
+ """Stereo panning"""
+
+ def __init__(self):
+ self.float_1(0.5)
+
+ def float_1(self,pos):
+ """pos ranges from 0 to 1"""
+ x = pos*math.pi/2
+ self.fl = math.cos(x)
+ self.fr = math.sin(x)
+
+ def _signal(self):
+ # Multiply input vector by gain and copy to output
+ iv = self._invec(0)
+ # first process right output channel because left one could be
+ # identical to input
+ # we could also test with 'self._outvec(1)[:] is iv'
+ self._outvec(1)[:] = iv*self.fr
+ self._outvec(0)[:] = iv*self.fl