Showing the changes to python/ext (1 of 1 file). Show all
Unified · Split
| @@ -2,7 +2,16 @@ · 1 unmodified line | |||
| 2 | 2 | ||
| 3 | static char Py_pvoc_doc[] = "pvoc object"; | 3 | static char Py_pvoc_doc[] = "pvoc object"; |
| 4 | 4 | ||
| 5 | AUBIO_DECLARE(pvoc, uint_t win_s; uint_t hop_s) | 5 | typedef struct |
| 6 | { | ||
| 7 | PyObject_HEAD | ||
| 8 | aubio_pvoc_t * o; | ||
| 9 | uint_t win_s; | ||
| 10 | uint_t hop_s; | ||
| 11 | cvec_t *output; | ||
| 12 | fvec_t *routput; | ||
| 13 | } Py_pvoc; | ||
| 14 | |||
| 6 | 15 | ||
| 7 | //AUBIO_NEW(pvoc) | 16 | //AUBIO_NEW(pvoc) |
| 8 | static PyObject * | 17 | static PyObject * |
| @@ -46,20 +55,30 @@ Py_pvoc_new (PyTypeObject * type, PyObject * args, PyObject * kwds) · 37 unmodified lines | |||
| 46 | return NULL; | 55 | return NULL; |
| 47 | } | 56 | } |
| 48 | 57 | ||
| 58 | self->output = new_cvec(self->win_s); | ||
| 59 | self->routput = new_fvec(self->hop_s); | ||
| 60 | |||
| 49 | return (PyObject *) self; | 61 | return (PyObject *) self; |
| 50 | } | 62 | } |
| 51 | 63 | ||
| 52 | 64 | ||
| 53 | AUBIO_INIT(pvoc, self->win_s, self->hop_s) | 65 | AUBIO_INIT(pvoc, self->win_s, self->hop_s) |
| 54 | 66 | ||
| 55 | AUBIO_DEL(pvoc) | 67 | static void |
| 68 | Py_pvoc_del (Py_pvoc *self, PyObject *unused) | ||
| 69 | { | ||
| 70 | del_aubio_pvoc(self->o); | ||
| 71 | del_cvec(self->output); | ||
| 72 | del_fvec(self->routput); | ||
| 73 | self->ob_type->tp_free((PyObject *) self); | ||
| 74 | } | ||
| 75 | |||
| 56 | 76 | ||
| 57 | static PyObject * | 77 | static PyObject * |
| 58 | Py_pvoc_do(Py_pvoc * self, PyObject * args) | 78 | Py_pvoc_do(Py_pvoc * self, PyObject * args) |
| 59 | { | 79 | { |
| 60 | PyObject *input; | 80 | PyObject *input; |
| 61 | fvec_t *vec; | 81 | fvec_t *vec; |
| 62 | cvec_t *output; | ||
| 63 | 82 | ||
| 64 | if (!PyArg_ParseTuple (args, "O", &input)) { | 83 | if (!PyArg_ParseTuple (args, "O", &input)) { |
| 65 | return NULL; | 84 | return NULL; |
| @@ -71,11 +90,9 @@ Py_pvoc_do(Py_pvoc * self, PyObject * args) · 5 unmodified lines | |||
| 71 | return NULL; | 90 | return NULL; |
| 72 | } | 91 | } |
| 73 | 92 | ||
| 74 | output = new_cvec(self->win_s); | ||
| 75 | |||
| 76 | // compute the function | 93 | // compute the function |
| 77 | aubio_pvoc_do (self->o, vec, output); | 94 | aubio_pvoc_do (self->o, vec, self->output); |
| 78 | return (PyObject *)PyAubio_CCvecToPyCvec(output); | 95 | return (PyObject *)PyAubio_CCvecToPyCvec(self->output); |
| 79 | } | 96 | } |
| 80 | 97 | ||
| 81 | AUBIO_MEMBERS_START(pvoc) | 98 | AUBIO_MEMBERS_START(pvoc) |
| @@ -90,8 +107,6 @@ Py_pvoc_rdo(Py_pvoc * self, PyObject * args) · 8 unmodified lines | |||
| 90 | { | 107 | { |
| 91 | PyObject *input; | 108 | PyObject *input; |
| 92 | cvec_t *vec; | 109 | cvec_t *vec; |
| 93 | fvec_t *output; | ||
| 94 | |||
| 95 | if (!PyArg_ParseTuple (args, "O", &input)) { | 110 | if (!PyArg_ParseTuple (args, "O", &input)) { |
| 96 | return NULL; | 111 | return NULL; |
| 97 | } | 112 | } |
| @@ -102,11 +117,9 @@ Py_pvoc_rdo(Py_pvoc * self, PyObject * args) · 4 unmodified lines | |||
| 102 | return NULL; | 117 | return NULL; |
| 103 | } | 118 | } |
| 104 | 119 | ||
| 105 | output = new_fvec(self->hop_s); | ||
| 106 | |||
| 107 | // compute the function | 120 | // compute the function |
| 108 | aubio_pvoc_rdo (self->o, vec, output); | 121 | aubio_pvoc_rdo (self->o, vec, self->routput); |
| 109 | return (PyObject *)PyAubio_CFvecToArray(output); | 122 | return (PyObject *)PyAubio_CFvecToArray(self->routput); |
| 110 | } | 123 | } |
| 111 | 124 | ||
| 112 | static PyMethodDef Py_pvoc_methods[] = { | 125 | static PyMethodDef Py_pvoc_methods[] = { |