History

python/ext/py-source.c: use new_py_foo here too

Paul Brossier committed 10 years ago

Commit 1ee5e211 parent ede5d381 file · +21 −32Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/ext/py-source.c+21−32
@@ -9,8 +9,10 @@ typedef struct · 8 unmodified lines
9 uint_t channels;9 uint_t channels;
10 uint_t hop_size;10 uint_t hop_size;
11 uint_t duration;11 uint_t duration;
12 fvec_t *read_to;12 PyObject *read_to;
13 fmat_t *mread_to;13 fvec_t c_read_to;
14 PyObject *mread_to;
15 fmat_t c_mread_to;
14} Py_source;16} Py_source;
15 17
16static char Py_source_doc[] = ""18static char Py_source_doc[] = ""
@@ -149,8 +151,8 @@ Py_source_init (Py_source * self, PyObject * args, PyObject * kwds) · 132 unmodified lines
149 }151 }
150 self->duration = aubio_source_get_duration ( self->o );152 self->duration = aubio_source_get_duration ( self->o );
151 153
152 self->read_to = new_fvec(self->hop_size);154 self->read_to = new_py_fvec(self->hop_size);
153 self->mread_to = new_fmat (self->channels, self->hop_size);155 self->mread_to = new_py_fmat(self->channels, self->hop_size);
154 156
155 return 0;157 return 0;
156}158}
@@ -159,8 +161,9 @@ static void · 2 unmodified lines
159Py_source_del (Py_source *self, PyObject *unused)161Py_source_del (Py_source *self, PyObject *unused)
160{162{
161 del_aubio_source(self->o);163 del_aubio_source(self->o);
162 del_fvec(self->read_to);164 //del_fvec(self->read_to);
163 del_fmat(self->mread_to);165 Py_XDECREF(self->read_to);
166 Py_XDECREF(self->mread_to);
164 Py_TYPE(self)->tp_free((PyObject *) self);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
169static PyObject *172static PyObject *
170Py_source_do(Py_source * self, PyObject * args)173Py_source_do(Py_source * self, PyObject * args)
171{174{
172
173
174 /* output vectors prototypes */
175 uint_t read;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 read = 0;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 /* compute _do function */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 PyObject *outputs = PyTuple_New(2);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 PyTuple_SetItem( outputs, 1, (PyObject *)PyLong_FromLong(read));187 PyTuple_SetItem( outputs, 1, (PyObject *)PyLong_FromLong(read));
192 return outputs;188 return outputs;
193}189}
@@ -196,25 +192,18 @@ Py_source_do(Py_source * self, PyObject * args) · 2 unmodified lines
196static PyObject *192static PyObject *
197Py_source_do_multi(Py_source * self, PyObject * args)193Py_source_do_multi(Py_source * self, PyObject * args)
198{194{
199
200
201 /* output vectors prototypes */
202 uint_t read;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 read = 0;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 /* compute _do function */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 PyObject *outputs = PyTuple_New(2);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 PyTuple_SetItem( outputs, 1, (PyObject *)PyLong_FromLong(read));207 PyTuple_SetItem( outputs, 1, (PyObject *)PyLong_FromLong(read));
219 return outputs;208 return outputs;
220}209}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t