Showing the changes to python/ext/py-filter.c (1 of 7 files). 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 *vec; | |
| 8 | 9 | fvec_t *out; |
| 9 | 10 | } Py_filter; |
| 10 | 11 | |
| @@ -49,6 +50,7 @@ Py_filter_init (Py_filter * self, PyObject * args, PyObject * kwds) · 38 unmodified lines | ||
| 49 | 50 | return -1; |
| 50 | 51 | } |
| 51 | 52 | self->out = new_fvec(Py_default_vector_length); |
| 53 | + self->vec = (fvec_t *)malloc(sizeof(fvec_t)); | |
| 52 | 54 | return 0; |
| 53 | 55 | } |
| 54 | 56 | |
| @@ -57,6 +59,7 @@ Py_filter_del (Py_filter * self) · 2 unmodified lines | ||
| 57 | 59 | { |
| 58 | 60 | del_fvec(self->out); |
| 59 | 61 | del_aubio_filter (self->o); |
| 62 | + free(self->vec); | |
| 60 | 63 | Py_TYPE(self)->tp_free ((PyObject *) self); |
| 61 | 64 | } |
| 62 | 65 | |
| @@ -64,7 +67,6 @@ static PyObject * · 1 unmodified line | ||
| 64 | 67 | Py_filter_do(Py_filter * self, PyObject * args) |
| 65 | 68 | { |
| 66 | 69 | PyObject *input; |
| 67 | − fvec_t *vec; | |
| 68 | 70 | |
| 69 | 71 | if (!PyArg_ParseTuple (args, "O:digital_filter.do", &input)) { |
| 70 | 72 | return NULL; |
| @@ -74,19 +76,17 @@ Py_filter_do(Py_filter * self, PyObject * args) · 3 unmodified lines | ||
| 74 | 76 | return NULL; |
| 75 | 77 | } |
| 76 | 78 | |
| 77 | − vec = PyAubio_ArrayToCFvec (input); | |
| 78 | − | |
| 79 | − if (vec == NULL) { | |
| 79 | + if (!PyAubio_ArrayToCFvec(input, self->vec)) { | |
| 80 | 80 | return NULL; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // reallocate the output if needed |
| 84 | − if (vec->length != self->out->length) { | |
| 84 | + if (self->vec->length != self->out->length) { | |
| 85 | 85 | del_fvec(self->out); |
| 86 | − self->out = new_fvec(vec->length); | |
| 86 | + self->out = new_fvec(self->vec->length); | |
| 87 | 87 | } |
| 88 | 88 | // compute the function |
| 89 | − aubio_filter_do_outplace (self->o, vec, self->out); | |
| 89 | + aubio_filter_do_outplace (self->o, self->vec, self->out); | |
| 90 | 90 | return PyAubio_CFvecToArray(self->out); |
| 91 | 91 | } |
| 92 | 92 | |