Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -9,8 +9,10 @@ typedef struct · 8 unmodified lines | ||
| 9 | 9 | uint_t channels; |
| 10 | 10 | uint_t hop_size; |
| 11 | 11 | uint_t duration; |
| 12 | − fvec_t *read_to; | |
| 13 | − fmat_t *mread_to; | |
| 12 | + PyObject *read_to; | |
| 13 | + fvec_t c_read_to; | |
| 14 | + PyObject *mread_to; | |
| 15 | + fmat_t c_mread_to; | |
| 14 | 16 | } Py_source; |
| 15 | 17 | |
| 16 | 18 | static char Py_source_doc[] = "" |
| @@ -149,8 +151,8 @@ Py_source_init (Py_source * self, PyObject * args, PyObject * kwds) · 132 unmodified lines | ||
| 149 | 151 | } |
| 150 | 152 | self->duration = aubio_source_get_duration ( self->o ); |
| 151 | 153 | |
| 152 | − self->read_to = new_fvec(self->hop_size); | |
| 153 | − self->mread_to = new_fmat (self->channels, self->hop_size); | |
| 154 | + self->read_to = new_py_fvec(self->hop_size); | |
| 155 | + self->mread_to = new_py_fmat(self->channels, self->hop_size); | |
| 154 | 156 | |
| 155 | 157 | return 0; |
| 156 | 158 | } |
| @@ -159,8 +161,9 @@ static void · 2 unmodified lines | ||
| 159 | 161 | Py_source_del (Py_source *self, PyObject *unused) |
| 160 | 162 | { |
| 161 | 163 | del_aubio_source(self->o); |
| 162 | − del_fvec(self->read_to); | |
| 163 | − del_fmat(self->mread_to); | |
| 164 | + //del_fvec(self->read_to); | |
| 165 | + Py_XDECREF(self->read_to); | |
| 166 | + Py_XDECREF(self->mread_to); | |
| 164 | 167 | Py_TYPE(self)->tp_free((PyObject *) self); |
| 165 | 168 | } |
| 166 | 169 | |
| @@ -169,25 +172,18 @@ Py_source_del (Py_source *self, PyObject *unused) · 2 unmodified lines | ||
| 169 | 172 | static PyObject * |
| 170 | 173 | Py_source_do(Py_source * self, PyObject * args) |
| 171 | 174 | { |
| 172 | − | |
| 173 | − | |
| 174 | − /* output vectors prototypes */ | |
| 175 | 175 | uint_t read; |
| 176 | − | |
| 177 | − | |
| 178 | − | |
| 179 | − | |
| 180 | − | |
| 181 | − | |
| 182 | − /* creating output read_to as a new_fvec of length self->hop_size */ | |
| 183 | 176 | read = 0; |
| 184 | 177 | |
| 185 | − | |
| 178 | + Py_INCREF(self->read_to); | |
| 179 | + if (!PyAubio_ArrayToCFvec(self->read_to, &(self->c_read_to))) { | |
| 180 | + return NULL; | |
| 181 | + } | |
| 186 | 182 | /* compute _do function */ |
| 187 | − aubio_source_do (self->o, self->read_to, &read); | |
| 183 | + aubio_source_do (self->o, &(self->c_read_to), &read); | |
| 188 | 184 | |
| 189 | 185 | PyObject *outputs = PyTuple_New(2); |
| 190 | − PyTuple_SetItem( outputs, 0, (PyObject *)PyAubio_CFvecToArray (self->read_to) ); | |
| 186 | + PyTuple_SetItem( outputs, 0, self->read_to ); | |
| 191 | 187 | PyTuple_SetItem( outputs, 1, (PyObject *)PyLong_FromLong(read)); |
| 192 | 188 | return outputs; |
| 193 | 189 | } |
| @@ -196,25 +192,18 @@ Py_source_do(Py_source * self, PyObject * args) · 2 unmodified lines | ||
| 196 | 192 | static PyObject * |
| 197 | 193 | Py_source_do_multi(Py_source * self, PyObject * args) |
| 198 | 194 | { |
| 199 | − | |
| 200 | − | |
| 201 | − /* output vectors prototypes */ | |
| 202 | 195 | uint_t read; |
| 203 | − | |
| 204 | − | |
| 205 | − | |
| 206 | − | |
| 207 | − | |
| 208 | − | |
| 209 | − /* creating output mread_to as a new_fvec of length self->hop_size */ | |
| 210 | 196 | read = 0; |
| 211 | 197 | |
| 212 | − | |
| 198 | + Py_INCREF(self->mread_to); | |
| 199 | + if (!PyAubio_ArrayToCFmat(self->mread_to, &(self->c_mread_to))) { | |
| 200 | + return NULL; | |
| 201 | + } | |
| 213 | 202 | /* compute _do function */ |
| 214 | − aubio_source_do_multi (self->o, self->mread_to, &read); | |
| 203 | + aubio_source_do_multi (self->o, &(self->c_mread_to), &read); | |
| 215 | 204 | |
| 216 | 205 | PyObject *outputs = PyTuple_New(2); |
| 217 | − PyTuple_SetItem( outputs, 0, (PyObject *)PyAubio_CFmatToArray (self->mread_to)); | |
| 206 | + PyTuple_SetItem( outputs, 0, self->mread_to); | |
| 218 | 207 | PyTuple_SetItem( outputs, 1, (PyObject *)PyLong_FromLong(read)); |
| 219 | 208 | return outputs; |
| 220 | 209 | } |