From 3ce0fb7e8ad57909fadcd4072817d69bc54e3a66 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Sun, 13 Mar 2005 04:59:47 +0000 Subject: pydsp: share dsp buffer objects at inplace operation DSP support for py/pyext: new objects pyext~,pyx~,pyext.~,pyx.~ new base class for py and pyext classes preset sys.argv for module loading support for buffer objects (preliminary) py: bang in left inlet now really triggers without arguments fixes for detached operation and single-threaded version little restructuring adjust pd and py files for correct argument passing more optimizations update for new flext callback naming use lock count instead of message queuing to avoid py->py messaging deadlock pyext: fix for inlet count svn path=/trunk/; revision=2624 --- externals/grill/py/source/clmeth.cpp | 59 +++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 5 deletions(-) (limited to 'externals/grill/py/source/clmeth.cpp') diff --git a/externals/grill/py/source/clmeth.cpp b/externals/grill/py/source/clmeth.cpp index 6062eda9..cfd8604a 100644 --- a/externals/grill/py/source/clmeth.cpp +++ b/externals/grill/py/source/clmeth.cpp @@ -29,6 +29,9 @@ PyMethodDef pyext::meth_tbl[] = { "_stop", pyext::pyext_stop, METH_VARARGS,"Stop running threads" }, #endif { "_isthreaded", pyext::pyext_isthreaded, METH_O,"Query whether threading is enabled" }, + + { "_invec", pyext::pyext_invec, METH_VARARGS,"Get input vector" }, + { "_outvec", pyext::pyext_outvec, METH_VARARGS,"Get output vector" }, {NULL, NULL, 0, NULL} /* Sentinel */ }; @@ -36,7 +39,7 @@ PyMethodDef pyext::attr_tbl[] = { { "__setattr__", pyext::pyext_setattr, METH_VARARGS,"Set class attribute" }, { "__getattr__", pyext::pyext_getattr, METH_VARARGS,"Get class attribute" }, - { NULL, NULL,0,NULL }, + { NULL, NULL,0,NULL }, }; @@ -174,6 +177,9 @@ PyObject *pyext::pyext_outlet(PyObject *,PyObject *args) if(lst) { int o = PyInt_AsLong(outl); if(o >= 1 && o <= ext->Outlets()) { + // offset outlet by signal outlets + o += ext->sigoutlets; + // by using the queue there is no immediate call of the next object // deadlock would occur if this was another py/pyext object! if(lst->Count() && IsSymbol((*lst)[0])) @@ -195,7 +201,10 @@ PyObject *pyext::pyext_outlet(PyObject *,PyObject *args) if(!tp) Py_DECREF(val); } - if(!ok) post("pyext - Syntax: _outlet(self,outlet,args...)"); + if(!ok) { + PyErr_SetString(PyExc_SyntaxError,"pyext - Syntax: _outlet(self,outlet,args...)"); + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -211,7 +220,8 @@ PyObject *pyext::pyext_detach(PyObject *,PyObject *args) int val; if(!PyArg_ParseTuple(args, "Oi:pyext_detach",&self,&val)) { // handle error - post("pyext - Syntax: _detach(self,[0/1])"); + PyErr_SetString(PyExc_SyntaxError,"pyext - Syntax: _detach(self,[0/1])"); + return NULL; } else { pyext *ext = GetThis(self); @@ -229,7 +239,8 @@ PyObject *pyext::pyext_stop(PyObject *,PyObject *args) int val = -1; if(!PyArg_ParseTuple(args, "O|i:pyext_stop",&self,&val)) { // handle error - post("pyext - Syntax: _stop(self,{wait time}"); + PyErr_SetString(PyExc_SyntaxError,"pyext - Syntax: _stop(self,{wait time})"); + return NULL; } else { pyext *ext = GetThis(self); @@ -305,12 +316,50 @@ PyObject *pyext::pyext_tocanvas(PyObject *,PyObject *args) if(!tp) Py_DECREF(val); } - if(!ok) post("pyext - Syntax: _tocanvas(self,args...)"); + if(!ok) { + PyErr_SetString(PyExc_SyntaxError,"pyext - Syntax: _tocanvas(self,args...)"); + return NULL; + } Py_INCREF(Py_None); return Py_None; } #endif +PyObject *pyext::pyext_invec(PyObject *,PyObject *args) +{ + PyObject *self; + int val = -1; + if(!PyArg_ParseTuple(args, "O|i:pyext_invec",&self,&val)) { + // handle error + PyErr_SetString(PyExc_SyntaxError,"pyext - Syntax: _invec(self,inlet)"); + return NULL; + } + else { + pyext *ext = GetThis(self); + PyObject *b = ext->GetSig(val,true); + if(b) return b; + } + Py_INCREF(Py_None); + return Py_None; +} +PyObject *pyext::pyext_outvec(PyObject *,PyObject *args) +{ + PyObject *self; + int val = -1; + if(!PyArg_ParseTuple(args, "O|i:pyext_outvec",&self,&val)) { + // handle error + PyErr_SetString(PyExc_SyntaxError,"pyext - Syntax: _outvec(self,inlet)"); + return NULL; + } + else { + pyext *ext = GetThis(self); + PyObject *b = ext->GetSig(val,false); + if(b) return b; + } + + Py_INCREF(Py_None); + return Py_None; +} -- cgit v1.2.1