History

python/ext/py-phasevoc.c: use new_py_fvec, new_py_cvec

Paul Brossier committed 10 years ago

Commit 307fdfc1 parent 1ee5e211 file · +21 −12Browse files

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

Unified · Split

python/ext/py-phasevoc.c+21−12
@@ -9,9 +9,11 @@ typedef struct · 8 unmodified lines
99 uint_t win_s;
1010 uint_t hop_s;
1111 fvec_t vecin;
12− cvec_t *output;
1312 cvec_t cvecin;
14− fvec_t *routput;
13+ PyObject *output;
14+ cvec_t c_output;
15+ PyObject *routput;
16+ fvec_t c_routput;
1517 } Py_pvoc;
1618
1719
@@ -70,8 +72,8 @@ Py_pvoc_init (Py_pvoc * self, PyObject * args, PyObject * kwds) · 52 unmodified lines
7072 return -1;
7173 }
7274
73− self->output = new_cvec(self->win_s);
74− self->routput = new_fvec(self->hop_s);
75+ self->output = new_py_cvec(self->win_s);
76+ self->routput = new_py_fvec(self->hop_s);
7577
7678 return 0;
7779 }
@@ -80,9 +82,9 @@ Py_pvoc_init (Py_pvoc * self, PyObject * args, PyObject * kwds) · 2 unmodified lines
8082 static void
8183 Py_pvoc_del (Py_pvoc *self, PyObject *unused)
8284 {
85+ Py_XDECREF(self->output);
86+ Py_XDECREF(self->routput);
8387 del_aubio_pvoc(self->o);
84− del_cvec(self->output);
85− del_fvec(self->routput);
8688 Py_TYPE(self)->tp_free((PyObject *) self);
8789 }
8890
@@ -100,10 +102,13 @@ Py_pvoc_do(Py_pvoc * self, PyObject * args) · 11 unmodified lines
100102 return NULL;
101103 }
102104
105+ Py_INCREF(self->output);
106+ if (!PyAubio_PyCvecToCCvec (self->output, &(self->c_output))) {
107+ return NULL;
108+ }
103109 // compute the function
104− aubio_pvoc_do (self->o, &(self->vecin), self->output);
105− // convert cvec to py_cvec
106− return PyAubio_CCvecToPyCvec(self->output);
110+ aubio_pvoc_do (self->o, &(self->vecin), &(self->c_output));
111+ return self->output;
107112 }
108113
109114 static PyMemberDef Py_pvoc_members[] = {
@@ -114,7 +119,7 @@ static PyMemberDef Py_pvoc_members[] = { · 4 unmodified lines
114119 { NULL } // sentinel
115120 };
116121
117−static PyObject *
122+static PyObject *
118123 Py_pvoc_rdo(Py_pvoc * self, PyObject * args)
119124 {
120125 PyObject *input;
@@ -126,9 +131,13 @@ Py_pvoc_rdo(Py_pvoc * self, PyObject * args) · 5 unmodified lines
126131 return NULL;
127132 }
128133
134+ Py_INCREF(self->routput);
135+ if (!PyAubio_ArrayToCFvec(self->routput, &(self->c_routput)) ) {
136+ return NULL;
137+ }
129138 // compute the function
130− aubio_pvoc_rdo (self->o, &(self->cvecin), self->routput);
131− return PyAubio_CFvecToArray(self->routput);
139+ aubio_pvoc_rdo (self->o, &(self->cvecin), &(self->c_routput));
140+ return self->routput;
132141 }
133142
134143 static PyMethodDef Py_pvoc_methods[] = {

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