Showing the changes to python/ext (1 of 2 files). Show all
Unified · Split
| @@ -69,6 +69,11 @@ static char Py_source_close_doc[] = "" · 68 unmodified lines | |||
| 69 | "\n" | 69 | "\n" |
| 70 | "Close this source now."; | 70 | "Close this source now."; |
| 71 | 71 | ||
| 72 | static char Py_source_seek_doc[] = "" | ||
| 73 | "x.seek(position)\n" | ||
| 74 | "\n" | ||
| 75 | "Seek to resampled frame position."; | ||
| 76 | |||
| 72 | static PyObject * | 77 | static PyObject * |
| 73 | Py_source_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds) | 78 | Py_source_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds) |
| 74 | { | 79 | { |
| @@ -238,6 +243,25 @@ Pyaubio_source_close (Py_source *self, PyObject *unused) · 163 unmodified lines | |||
| 238 | Py_RETURN_NONE; | 243 | Py_RETURN_NONE; |
| 239 | } | 244 | } |
| 240 | 245 | ||
| 246 | static PyObject * | ||
| 247 | Pyaubio_source_seek (Py_source *self, PyObject *args) | ||
| 248 | { | ||
| 249 | uint_t err = 0; | ||
| 250 | |||
| 251 | uint_t position; | ||
| 252 | if (!PyArg_ParseTuple (args, "I", &position)) { | ||
| 253 | return NULL; | ||
| 254 | } | ||
| 255 | |||
| 256 | err = aubio_source_seek(self->o, position); | ||
| 257 | if (err != 0) { | ||
| 258 | PyErr_SetString (PyExc_ValueError, | ||
| 259 | "error when seeking in source"); | ||
| 260 | return NULL; | ||
| 261 | } | ||
| 262 | Py_RETURN_NONE; | ||
| 263 | } | ||
| 264 | |||
| 241 | static PyMethodDef Py_source_methods[] = { | 265 | static PyMethodDef Py_source_methods[] = { |
| 242 | {"get_samplerate", (PyCFunction) Pyaubio_source_get_samplerate, | 266 | {"get_samplerate", (PyCFunction) Pyaubio_source_get_samplerate, |
| 243 | METH_NOARGS, Py_source_get_samplerate_doc}, | 267 | METH_NOARGS, Py_source_get_samplerate_doc}, |
| @@ -249,6 +273,8 @@ static PyMethodDef Py_source_methods[] = { · 5 unmodified lines | |||
| 249 | METH_NOARGS, Py_source_do_multi_doc}, | 273 | METH_NOARGS, Py_source_do_multi_doc}, |
| 250 | {"close", (PyCFunction) Pyaubio_source_close, | 274 | {"close", (PyCFunction) Pyaubio_source_close, |
| 251 | METH_NOARGS, Py_source_close_doc}, | 275 | METH_NOARGS, Py_source_close_doc}, |
| 276 | {"seek", (PyCFunction) Pyaubio_source_seek, | ||
| 277 | METH_VARARGS, Py_source_seek_doc}, | ||
| 252 | {NULL} /* sentinel */ | 278 | {NULL} /* sentinel */ |
| 253 | }; | 279 | }; |
| 254 | 280 | ||