Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -8,6 +8,8 @@ typedef struct · 7 unmodified lines | |||
| 8 | uint_t samplerate; | 8 | uint_t samplerate; |
| 9 | uint_t channels; | 9 | uint_t channels; |
| 10 | uint_t hop_size; | 10 | uint_t hop_size; |
| 11 | fvec_t *read_to; | ||
| 12 | fmat_t *mread_to; | ||
| 11 | } Py_source; | 13 | } Py_source; |
| 12 | 14 | ||
| 13 | static char Py_source_doc[] = "" | 15 | static char Py_source_doc[] = "" |
| @@ -145,10 +147,21 @@ Py_source_init (Py_source * self, PyObject * args, PyObject * kwds) · 131 unmodified lines | |||
| 145 | self->channels = aubio_source_get_channels ( self->o ); | 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 | return 0; | 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 | /* function Py_source_do */ | 166 | /* function Py_source_do */ |
| 154 | static PyObject * | 167 | static PyObject * |
| @@ -157,7 +170,6 @@ Py_source_do(Py_source * self, PyObject * args) · 2 unmodified lines | |||
| 157 | 170 | ||
| 158 | 171 | ||
| 159 | /* output vectors prototypes */ | 172 | /* output vectors prototypes */ |
| 160 | fvec_t* read_to; | ||
| 161 | uint_t read; | 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 | /* creating output read_to as a new_fvec of length self->hop_size */ | 180 | /* creating output read_to as a new_fvec of length self->hop_size */ |
| 169 | read_to = new_fvec (self->hop_size); | ||
| 170 | read = 0; | 181 | read = 0; |
| 171 | 182 | ||
| 172 | 183 | ||
| 173 | /* compute _do function */ | 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 | PyObject *outputs = PyList_New(0); | 187 | PyObject *outputs = PyList_New(0); |
| 177 | PyList_Append( outputs, (PyObject *)PyAubio_CFvecToArray (read_to)); | 188 | PyList_Append( outputs, (PyObject *)PyAubio_CFvecToArray (self->read_to)); |
| 178 | //del_fvec (read_to); | ||
| 179 | PyList_Append( outputs, (PyObject *)PyInt_FromLong (read)); | 189 | PyList_Append( outputs, (PyObject *)PyInt_FromLong (read)); |
| 180 | return outputs; | 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 | /* output vectors prototypes */ | 199 | /* output vectors prototypes */ |
| 190 | fmat_t* read_to; | ||
| 191 | uint_t read; | 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 */ | 207 | /* creating output mread_to as a new_fvec of length self->hop_size */ |
| 199 | read_to = new_fmat (self->channels, self->hop_size); | ||
| 200 | read = 0; | 208 | read = 0; |
| 201 | 209 | ||
| 202 | 210 | ||
| 203 | /* compute _do function */ | 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 | PyObject *outputs = PyList_New(0); | 214 | PyObject *outputs = PyList_New(0); |
| 207 | PyList_Append( outputs, (PyObject *)PyAubio_CFmatToArray (read_to)); | 215 | PyList_Append( outputs, (PyObject *)PyAubio_CFmatToArray (self->mread_to)); |
| 208 | //del_fvec (read_to); | ||
| 209 | PyList_Append( outputs, (PyObject *)PyInt_FromLong (read)); | 216 | PyList_Append( outputs, (PyObject *)PyInt_FromLong (read)); |
| 210 | return outputs; | 217 | return outputs; |
| 211 | } | 218 | } |