changeset 37:fd249e29a721

Add remaining accessors to plugin; move outputs to getOutputs (distinguishing between static parameters and dynamic output descriptors... is this wise?)
author Chris Cannam
date Wed, 26 Nov 2014 14:20:54 +0000
parents 20a9fcbc2f5f
children e881d77da368
files PyPluginObject.cpp PyPluginObject.h test_process.py
diffstat 3 files changed, 70 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/PyPluginObject.cpp	Wed Nov 26 13:52:15 2014 +0000
+++ b/PyPluginObject.cpp	Wed Nov 26 14:20:54 2014 +0000
@@ -152,8 +152,24 @@
     }
 
     pd->parameters = params;
+    
+    return (PyObject *)pd;
+}
 
-    Plugin::OutputList ol = plugin->getOutputDescriptors();
+static void
+PyPluginObject_dealloc(PyPluginObject *self)
+{
+    delete self->plugin;
+    PyObject_Del(self);
+}
+
+static PyObject *
+getOutputs(PyObject *self, PyObject *args)
+{ 
+    PyPluginObject *pd = getPluginObject(self);
+    if (!pd) return 0;
+
+    Plugin::OutputList ol = pd->plugin->getOutputDescriptors();
     PyObject *outputs = PyList_New(ol.size());
     
     for (int i = 0; i < (int)ol.size(); ++i) {
@@ -198,16 +214,7 @@
         PyList_SET_ITEM(outputs, i, outdict);
     }
 
-    pd->outputs = outputs;
-    
-    return (PyObject *)pd;
-}
-
-static void
-PyPluginObject_dealloc(PyPluginObject *self)
-{
-    delete self->plugin;
-    PyObject_Del(self);
+    return outputs;
 }
 
 static PyObject *
@@ -430,6 +437,38 @@
 }
 
 static PyObject *
+vampyhost_getPreferredBlockSize(PyObject *self, PyObject *)
+{
+    PyPluginObject *pd = getPluginObject(self);
+    if (!pd) return 0;
+    return PyInt_FromLong(pd->plugin->getPreferredBlockSize());
+}
+
+static PyObject *
+vampyhost_getPreferredStepSize(PyObject *self, PyObject *)
+{
+    PyPluginObject *pd = getPluginObject(self);
+    if (!pd) return 0;
+    return PyInt_FromLong(pd->plugin->getPreferredStepSize());
+}
+
+static PyObject *
+vampyhost_getMinChannelCount(PyObject *self, PyObject *)
+{
+    PyPluginObject *pd = getPluginObject(self);
+    if (!pd) return 0;
+    return PyInt_FromLong(pd->plugin->getMinChannelCount());
+}
+
+static PyObject *
+vampyhost_getMaxChannelCount(PyObject *self, PyObject *)
+{
+    PyPluginObject *pd = getPluginObject(self);
+    if (!pd) return 0;
+    return PyInt_FromLong(pd->plugin->getMaxChannelCount());
+}
+    
+static PyObject *
 vampyhost_unload(PyObject *self, PyObject *)
 {
     PyPluginObject *pd = getPluginObject(self);
@@ -452,19 +491,31 @@
 
     {(char *)"parameters", T_OBJECT, offsetof(PyPluginObject, parameters), READONLY,
      xx_foo_doc},
-
-    {(char *)"outputs", T_OBJECT, offsetof(PyPluginObject, outputs), READONLY,
-     xx_foo_doc},
     
     {0, 0}
 };
 
 static PyMethodDef PyPluginObject_methods[] =
 {
-    {"getParameter",	vampyhost_getParameter, METH_VARARGS,
+    {"getOutputs", getOutputs, METH_NOARGS,
+     xx_foo_doc},
+
+    {"getParameterValue",	vampyhost_getParameter, METH_VARARGS,
      xx_foo_doc}, //!!! fix all these!
 
-    {"setParameter",	vampyhost_setParameter, METH_VARARGS,
+    {"setParameterValue",	vampyhost_setParameter, METH_VARARGS,
+     xx_foo_doc},
+
+    {"getPreferredBlockSize",	vampyhost_getPreferredBlockSize, METH_VARARGS,
+     xx_foo_doc}, //!!! fix all these!
+
+    {"getPreferredStepSize",	vampyhost_getPreferredStepSize, METH_VARARGS,
+     xx_foo_doc},
+
+    {"getMinChannelCount",	vampyhost_getMinChannelCount, METH_VARARGS,
+     xx_foo_doc}, //!!! fix all these!
+
+    {"getMaxChannelCount",	vampyhost_getMaxChannelCount, METH_VARARGS,
      xx_foo_doc},
     
     {"initialise",	vampyhost_initialise, METH_VARARGS,
--- a/PyPluginObject.h	Wed Nov 26 13:52:15 2014 +0000
+++ b/PyPluginObject.h	Wed Nov 26 14:20:54 2014 +0000
@@ -54,7 +54,6 @@
     PyObject *info;
     int inputDomain;
     PyObject *parameters;
-    PyObject *outputs;
 };
 
 PyAPI_DATA(PyTypeObject) Plugin_Type;
--- a/test_process.py	Wed Nov 26 13:52:15 2014 +0000
+++ b/test_process.py	Wed Nov 26 14:20:54 2014 +0000
@@ -16,10 +16,10 @@
 
 def test_get_set_parameter():
     plug = vh.loadPlugin(testPluginKey, rate)
-    value = plug.getParameter("produce_output")
+    value = plug.getParameterValue("produce_output")
     assert(value == 1.0)
-    plug.setParameter("produce_output", 0.0)
-    value = plug.getParameter("produce_output")
+    plug.setParameterValue("produce_output", 0.0)
+    value = plug.getParameterValue("produce_output")
     assert(value == 0.0)
     
 def test_process_without_initialise():