[PD-cvs] externals/grill/py/scripts buffer.py, 1.3, 1.4 sig.py, 1.4, 1.5 simple.py, 1.6, 1.7
Thomas Grill
xovo at users.sourceforge.net
Wed Mar 7 14:40:16 CET 2007
- Previous message: [PD-cvs] externals/grill/py/source bound.cpp, 1.18, 1.19 clmeth.cpp, 1.27, 1.28 modmeth.cpp, 1.23, 1.24 py.cpp, 1.35, 1.36 pyatom.cpp, 1.1, 1.2 pyatom.h, 1.1, 1.2 pybase.cpp, 1.17, 1.18 pybase.h, 1.12, 1.13 pybundle.cpp, 1.1, 1.2 pybundle.h, 1.1, 1.2 pydsp.cpp, 1.6, 1.7 pyext.cpp, 1.46, 1.47 pyext.h, 1.30, 1.31 pymeth.cpp, 1.6, 1.7 pyprefix.h, 1.5, 1.6 pysymbol.cpp, 1.6, 1.7 pysymbol.h, 1.4, 1.5
- Next message: [PD-cvs] autobuild: pd-extended-release debian-testing-powerpc 2007-03-07 06.27.16
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/pure-data/externals/grill/py/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18937/scripts
Modified Files:
buffer.py sig.py simple.py
Log Message:
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
Index: sig.py
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/scripts/sig.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** sig.py 10 Apr 2005 22:24:13 -0000 1.4
--- sig.py 7 Mar 2007 13:40:14 -0000 1.5
***************
*** 1,100 ****
! # py/pyext - python script objects for PD and MaxMSP
! #
! # Copyright (c) 2002-2005 Thomas Grill (gr at 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
! try:
! self._outvec(0)[:] = self._invec(0)*self.gain
! except:
! pass
!
!
! class gain2(pyext._class):
! """More optimized version"""
!
! gain = 0
!
! def _dsp(self):
! if not self._arraysupport():
! print "No DSP support"
! return False
!
! # 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:
! self._signal = self.signal1
! else:
! self._signal = self.signal2
! return True
!
! def signal1(self):
! # Multiply signal vector in place
! self.outvec *= self.gain
!
! def signal2(self):
! # Multiply input vector by gain and copy to output
! self.outvec[:] = self.invec*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 _dsp(self):
! # if _dsp is present it must return True to enable DSP
! return pyext._arraysupport()
!
! 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
--- 1,100 ----
! # py/pyext - python script objects for PD and MaxMSP
! #
! # Copyright (c) 2002-2005 Thomas Grill (gr at 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
! try:
! self._outvec(0)[:] = self._invec(0)*self.gain
! except:
! pass
!
!
! class gain2(pyext._class):
! """More optimized version"""
!
! gain = 0
!
! def _dsp(self):
! if not self._arraysupport():
! print "No DSP support"
! return False
!
! # 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:
! self._signal = self.signal1
! else:
! self._signal = self.signal2
! return True
!
! def signal1(self):
! # Multiply signal vector in place
! self.outvec *= self.gain
!
! def signal2(self):
! # Multiply input vector by gain and copy to output
! self.outvec[:] = self.invec*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 _dsp(self):
! # if _dsp is present it must return True to enable DSP
! return pyext._arraysupport()
!
! 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
Index: buffer.py
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/scripts/buffer.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** buffer.py 25 Mar 2005 04:54:16 -0000 1.3
--- buffer.py 7 Mar 2007 13:40:14 -0000 1.4
***************
*** 1,60 ****
! # py/pyext - python script objects for PD and MaxMSP
! #
! # Copyright (c) 2002-2005 Thomas Grill (gr at 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()
--- 1,60 ----
! # py/pyext - python script objects for PD and MaxMSP
! #
! # Copyright (c) 2002-2005 Thomas Grill (gr at 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()
Index: simple.py
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/py/scripts/simple.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** simple.py 19 Jan 2005 04:58:35 -0000 1.6
--- simple.py 7 Mar 2007 13:40:14 -0000 1.7
***************
*** 1,5 ****
# py/pyext - python script objects for PD and MaxMSP
#
! # Copyright (c) 2002-2005 Thomas Grill (gr at grrrr.org)
# For information on usage and redistribution, and for a DISCLAIMER OF ALL
# WARRANTIES, see the file, "license.txt," in this distribution.
--- 1,5 ----
# py/pyext - python script objects for PD and MaxMSP
#
! # Copyright (c) 2002-2007 Thomas Grill (gr at grrrr.org)
# For information on usage and redistribution, and for a DISCLAIMER OF ALL
# WARRANTIES, see the file, "license.txt," in this distribution.
***************
*** 58,61 ****
--- 58,63 ----
or
self._outlet(outlet,arg) ... where arg is a sequence containing only atoms
+
+ Do not use _outlet inside __init__, since the outlets have not been created at that time.
- Use pyext functions and methods:
- Previous message: [PD-cvs] externals/grill/py/source bound.cpp, 1.18, 1.19 clmeth.cpp, 1.27, 1.28 modmeth.cpp, 1.23, 1.24 py.cpp, 1.35, 1.36 pyatom.cpp, 1.1, 1.2 pyatom.h, 1.1, 1.2 pybase.cpp, 1.17, 1.18 pybase.h, 1.12, 1.13 pybundle.cpp, 1.1, 1.2 pybundle.h, 1.1, 1.2 pydsp.cpp, 1.6, 1.7 pyext.cpp, 1.46, 1.47 pyext.h, 1.30, 1.31 pymeth.cpp, 1.6, 1.7 pyprefix.h, 1.5, 1.6 pysymbol.cpp, 1.6, 1.7 pysymbol.h, 1.4, 1.5
- Next message: [PD-cvs] autobuild: pd-extended-release debian-testing-powerpc 2007-03-07 06.27.16
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Pd-cvs
mailing list