Mercurial > hg > vampy-host
diff native/vampyhost.cpp @ 60:2437c52b4d62
Add frame2RealTime
author | Chris Cannam |
---|---|
date | Wed, 14 Jan 2015 10:36:22 +0000 |
parents | a0243984805b |
children | aa8491a11530 |
line wrap: on
line diff
--- 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 */ };