Showing the changes to python/ext (1 of 1 file). Show all
Unified · Split
| @@ -8,6 +8,8 @@ typedef struct · 7 unmodified lines | ||
| 8 | 8 | uint_t samplerate; |
| 9 | 9 | uint_t channels; |
| 10 | 10 | uint_t hop_size; |
| 11 | + fvec_t *read_to; | |
| 12 | + fmat_t *mread_to; | |
| 11 | 13 | } Py_source; |
| 12 | 14 | |
| 13 | 15 | static char Py_source_doc[] = "" |
| @@ -145,10 +147,21 @@ Py_source_init (Py_source * self, PyObject * args, PyObject * kwds) · 131 unmodified lines | ||
| 145 | 147 | self->channels = aubio_source_get_channels ( self->o ); |
| 146 | 148 | } |
| 147 | 149 | |
| 150 | + self->read_to = new_fvec(self->hop_size); | |
| 151 | + self->mread_to = new_fmat (self->channels, self->hop_size); | |
| 152 | + | |
| 148 | 153 | return 0; |
| 149 | 154 | } |
| 150 | 155 | |
| 151 | −AUBIO_DEL(source) | |
| 156 | +static void | |
| 157 | +Py_source_del (Py_source *self, PyObject *unused) | |
| 158 | +{ | |
| 159 | + del_aubio_source(self->o); | |
| 160 | + del_fvec(self->read_to); | |
| 161 | + del_fmat(self->mread_to); | |
| 162 | + self->ob_type->tp_free((PyObject *) self); | |
| 163 | +} | |
| 164 | + | |
| 152 | 165 | |
| 153 | 166 | /* function Py_source_do */ |
| 154 | 167 | static PyObject * |
| @@ -157,7 +170,6 @@ Py_source_do(Py_source * self, PyObject * args) · 2 unmodified lines | ||
| 157 | 170 | |
| 158 | 171 | |
| 159 | 172 | /* output vectors prototypes */ |
| 160 | − fvec_t* read_to; | |
| 161 | 173 | uint_t read; |
| 162 | 174 | |
| 163 | 175 | |
| @@ -166,16 +178,14 @@ Py_source_do(Py_source * self, PyObject * args) · 2 unmodified lines | ||
| 166 | 178 | |
| 167 | 179 | |
| 168 | 180 | /* creating output read_to as a new_fvec of length self->hop_size */ |
| 169 | − read_to = new_fvec (self->hop_size); | |
| 170 | 181 | read = 0; |
| 171 | 182 | |
| 172 | 183 | |
| 173 | 184 | /* compute _do function */ |
| 174 | − aubio_source_do (self->o, read_to, &read); | |
| 185 | + aubio_source_do (self->o, self->read_to, &read); | |
| 175 | 186 | |
| 176 | 187 | PyObject *outputs = PyList_New(0); |
| 177 | − PyList_Append( outputs, (PyObject *)PyAubio_CFvecToArray (read_to)); | |
| 178 | − //del_fvec (read_to); | |
| 188 | + PyList_Append( outputs, (PyObject *)PyAubio_CFvecToArray (self->read_to)); | |
| 179 | 189 | PyList_Append( outputs, (PyObject *)PyInt_FromLong (read)); |
| 180 | 190 | return outputs; |
| 181 | 191 | } |
| @@ -187,7 +197,6 @@ Py_source_do_multi(Py_source * self, PyObject * args) · 5 unmodified lines | ||
| 187 | 197 | |
| 188 | 198 | |
| 189 | 199 | /* output vectors prototypes */ |
| 190 | − fmat_t* read_to; | |
| 191 | 200 | uint_t read; |
| 192 | 201 | |
| 193 | 202 | |
| @@ -195,17 +204,15 @@ Py_source_do_multi(Py_source * self, PyObject * args) · 1 unmodified line | ||
| 195 | 204 | |
| 196 | 205 | |
| 197 | 206 | |
| 198 | − /* creating output read_to as a new_fvec of length self->hop_size */ | |
| 199 | − read_to = new_fmat (self->channels, self->hop_size); | |
| 207 | + /* creating output mread_to as a new_fvec of length self->hop_size */ | |
| 200 | 208 | read = 0; |
| 201 | 209 | |
| 202 | 210 | |
| 203 | 211 | /* compute _do function */ |
| 204 | − aubio_source_do_multi (self->o, read_to, &read); | |
| 212 | + aubio_source_do_multi (self->o, self->mread_to, &read); | |
| 205 | 213 | |
| 206 | 214 | PyObject *outputs = PyList_New(0); |
| 207 | − PyList_Append( outputs, (PyObject *)PyAubio_CFmatToArray (read_to)); | |
| 208 | − //del_fvec (read_to); | |
| 215 | + PyList_Append( outputs, (PyObject *)PyAubio_CFmatToArray (self->mread_to)); | |
| 209 | 216 | PyList_Append( outputs, (PyObject *)PyInt_FromLong (read)); |
| 210 | 217 | return outputs; |
| 211 | 218 | } |