# HG changeset patch # User Chris Cannam # Date 1421231782 0 # Node ID 2437c52b4d62a0bca6bb96d3873a6982da39218f # Parent 2809245a2fe7f7329364e60ae691792f966524f4 Add frame2RealTime diff -r 2809245a2fe7 -r 2437c52b4d62 native/vampyhost.cpp --- a/native/vampyhost.cpp Wed Jan 14 10:23:06 2015 +0000 +++ b/native/vampyhost.cpp Wed Jan 14 10:36:22 2015 +0000 @@ -205,9 +205,26 @@ return PyPluginObject_From_Plugin(plugin); } +static PyObject * +frame2RealTime(PyObject *self, PyObject *args) +{ + int frame; + int rate; + + if (!PyArg_ParseTuple(args, "nn", + &frame, + &rate)) { + PyErr_SetString(PyExc_TypeError, + "frame2RealTime() takes frame (int) and sample rate (int) arguments"); + return 0; } + + RealTime rt = RealTime::frame2RealTime(frame, rate); + return PyRealTime_FromRealTime(rt); +} + // module methods table static PyMethodDef vampyhost_methods[] = { - + {"listPlugins", enumeratePlugins, METH_NOARGS, "listPlugins() -> Return a list of the plugin keys of all installed Vamp plugins." }, @@ -226,6 +243,9 @@ {"loadPlugin", loadPlugin, METH_VARARGS, "loadPlugin(pluginKey, samplerate) -> Load the plugin that has the given key, if installed, and return the plugin object."}, + {"frame2RealTime", frame2RealTime, METH_VARARGS, + "frame2RealTime() -> Convert sample frame number and sample rate to a RealTime object." }, + {0, 0} /* sentinel */ };