Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -5,6 +5,7 @@ typedef struct · 4 unmodified lines | ||
| 5 | 5 | PyObject_HEAD |
| 6 | 6 | aubio_filter_t * o; |
| 7 | 7 | uint_t order; |
| 8 | + fvec_t *out; | |
| 8 | 9 | } Py_filter; |
| 9 | 10 | |
| 10 | 11 | static char Py_filter_doc[] = "filter object"; |
| @@ -47,13 +48,14 @@ Py_filter_init (Py_filter * self, PyObject * args, PyObject * kwds) · 36 unmodified lines | ||
| 47 | 48 | if (self->o == NULL) { |
| 48 | 49 | return -1; |
| 49 | 50 | } |
| 50 | − | |
| 51 | + self->out = new_fvec(Py_default_vector_length); | |
| 51 | 52 | return 0; |
| 52 | 53 | } |
| 53 | 54 | |
| 54 | 55 | static void |
| 55 | 56 | Py_filter_del (Py_filter * self) |
| 56 | 57 | { |
| 58 | + del_fvec(self->out); | |
| 57 | 59 | del_aubio_filter (self->o); |
| 58 | 60 | self->ob_type->tp_free ((PyObject *) self); |
| 59 | 61 | } |
| @@ -78,10 +80,14 @@ Py_filter_do(Py_filter * self, PyObject * args) · 18 unmodified lines | ||
| 78 | 80 | return NULL; |
| 79 | 81 | } |
| 80 | 82 | |
| 83 | + // reallocate the output if needed | |
| 84 | + if (vec->length != self->out->length) { | |
| 85 | + del_fvec(self->out); | |
| 86 | + self->out = new_fvec(vec->length); | |
| 87 | + } | |
| 81 | 88 | // compute the function |
| 82 | − fvec_t * out = new_fvec(vec->length); | |
| 83 | − aubio_filter_do_outplace (self->o, vec, out); | |
| 84 | − return PyAubio_CFvecToArray(out); | |
| 89 | + aubio_filter_do_outplace (self->o, vec, self->out); | |
| 90 | + return PyAubio_CFvecToArray(self->out); | |
| 85 | 91 | } |
| 86 | 92 | |
| 87 | 93 | static PyObject * |