History

ext/: use new proxy functions

Paul Brossier committed 10 years ago

Commit b5bef111 parent bfe82567 files · +118 −87Browse files

Showing the changes to python/ext (7 of 7 files). Show all

Unified · Split

7 files
  1. python/ext/aubiomodule.c +11 −9
  2. python/ext/py-fft.c +27 −14
  3. python/ext/py-filter.c +7 −7
  4. python/ext/py-filterbank.c +21 −18
  5. python/ext/py-musicutils.c +16 −8
  6. python/ext/py-phasevoc.c +23 −13
  7. python/ext/py-sink.c +13 −18
python/ext/aubiomodule.c+11−9
@@ -95,14 +95,15 @@ Py_alpha_norm (PyObject * self, PyObject * args) · 94 unmodified lines
95 return NULL;95 return NULL;
96 }96 }
97 97
98 vec = PyAubio_ArrayToCFvec (input);98 vec = (fvec_t *)malloc(sizeof(fvec_t));
99 99 if (!PyAubio_ArrayToCFvec(input, vec)) {
100 if (vec == NULL) {100 free(vec);
101 return NULL;101 return NULL;
102 }102 }
103 103
104 // compute the function104 // compute the function
105 result = Py_BuildValue ("f", fvec_alpha_norm (vec, alpha));105 result = Py_BuildValue ("f", fvec_alpha_norm (vec, alpha));
106 free(vec);
106 if (result == NULL) {107 if (result == NULL) {
107 return NULL;108 return NULL;
108 }109 }
@@ -185,14 +186,15 @@ Py_zero_crossing_rate (PyObject * self, PyObject * args) · 76 unmodified lines
185 return NULL;186 return NULL;
186 }187 }
187 188
188 vec = PyAubio_ArrayToCFvec (input);189 vec = (fvec_t *)malloc(sizeof(fvec_t));
189 190 if (!PyAubio_ArrayToCFvec(input, vec)) {
190 if (vec == NULL) {191 free(vec);
191 return NULL;192 return NULL;
192 }193 }
193 194
194 // compute the function195 // compute the function
195 result = Py_BuildValue ("f", aubio_zero_crossing_rate (vec));196 result = Py_BuildValue ("f", aubio_zero_crossing_rate (vec));
197 free(vec);
196 if (result == NULL) {198 if (result == NULL) {
197 return NULL;199 return NULL;
198 }200 }
@@ -214,9 +216,9 @@ Py_min_removal(PyObject * self, PyObject * args) · 15 unmodified lines
214 return NULL;216 return NULL;
215 }217 }
216 218
217 vec = PyAubio_ArrayToCFvec (input);219 vec = (fvec_t *)malloc(sizeof(fvec_t));
218 220 if (!PyAubio_ArrayToCFvec(input, vec)) {
219 if (vec == NULL) {221 free(vec);
220 return NULL;222 return NULL;
221 }223 }
222 224
python/ext/py-fft.c+27−14
@@ -7,7 +7,10 @@ typedef struct · 6 unmodified lines
7 PyObject_HEAD7 PyObject_HEAD
8 aubio_fft_t * o;8 aubio_fft_t * o;
9 uint_t win_s;9 uint_t win_s;
10 fvec_t *vecin;
10 cvec_t *out;11 cvec_t *out;
12 Py_cvec *py_out;
13 cvec_t *cvecin;
11 fvec_t *rout;14 fvec_t *rout;
12} Py_fft;15} Py_fft;
13 16
@@ -52,7 +55,13 @@ Py_fft_init (Py_fft * self, PyObject * args, PyObject * kwds) · 38 unmodified lines
52 PyErr_SetString (PyExc_Exception, errstr);55 PyErr_SetString (PyExc_Exception, errstr);
53 return -1;56 return -1;
54 }57 }
58
59 self->cvecin = (cvec_t *)malloc(sizeof(cvec_t));
60 self->vecin = (fvec_t *)malloc(sizeof(fvec_t));
61
55 self->out = new_cvec(self->win_s);62 self->out = new_cvec(self->win_s);
63 self->py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
64 Py_XINCREF(self->py_out);
56 self->rout = new_fvec(self->win_s);65 self->rout = new_fvec(self->win_s);
57 66
58 return 0;67 return 0;
@@ -61,31 +70,38 @@ Py_fft_init (Py_fft * self, PyObject * args, PyObject * kwds) · 2 unmodified lines
61static void70static void
62Py_fft_del (Py_fft *self, PyObject *unused)71Py_fft_del (Py_fft *self, PyObject *unused)
63{72{
73 Py_XDECREF((PyObject*)(self->py_out));
64 del_aubio_fft(self->o);74 del_aubio_fft(self->o);
65 del_cvec(self->out);75 del_cvec(self->out);
66 del_fvec(self->rout);76 del_fvec(self->rout);
77 free(self->cvecin);
78 free(self->vecin);
67 Py_TYPE(self)->tp_free((PyObject *) self);79 Py_TYPE(self)->tp_free((PyObject *) self);
68}80}
69 81
70static PyObject * 82static PyObject *
71Py_fft_do(Py_fft * self, PyObject * args)83Py_fft_do(Py_fft * self, PyObject * args)
72{84{
73 PyObject *input;85 PyObject *input;
74 fvec_t *vec;
75 86
76 if (!PyArg_ParseTuple (args, "O", &input)) {87 if (!PyArg_ParseTuple (args, "O", &input)) {
77 return NULL;88 return NULL;
78 }89 }
79 90
80 vec = PyAubio_ArrayToCFvec (input);91 if (!PyAubio_ArrayToCFvec(input, self->vecin)) {
81
82 if (vec == NULL) {
83 return NULL;92 return NULL;
84 }93 }
85 94
86 // compute the function95 // compute the function
87 aubio_fft_do (((Py_fft *)self)->o, vec, self->out);96 aubio_fft_do (((Py_fft *)self)->o, self->vecin, self->out);
88 return (PyObject *)PyAubio_CCvecToPyCvec(self->out);97#if 0
98 Py_cvec * py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
99 PyObject* output = PyAubio_CCvecToPyCvec(self->out, py_out);
100 return output;
101#else
102 // convert cvec to py_cvec, incrementing refcount to keep a copy
103 return PyAubio_CCvecToPyCvec(self->out, self->py_out);
104#endif
89}105}
90 106
91static PyMemberDef Py_fft_members[] = {107static PyMemberDef Py_fft_members[] = {
@@ -94,25 +110,22 @@ static PyMemberDef Py_fft_members[] = { · 2 unmodified lines
94 {NULL}110 {NULL}
95};111};
96 112
97static PyObject * 113static PyObject *
98Py_fft_rdo(Py_fft * self, PyObject * args)114Py_fft_rdo(Py_fft * self, PyObject * args)
99{115{
100 PyObject *input;116 PyObject *input;
101 cvec_t *vec;
102 117
103 if (!PyArg_ParseTuple (args, "O", &input)) {118 if (!PyArg_ParseTuple (args, "O", &input)) {
104 return NULL;119 return NULL;
105 }120 }
106 121
107 vec = PyAubio_ArrayToCCvec (input);122 if (!PyAubio_ArrayToCCvec (input, self->cvecin) ) {
108
109 if (vec == NULL) {
110 return NULL;123 return NULL;
111 }124 }
112 125
113 // compute the function126 // compute the function
114 aubio_fft_rdo (((Py_fft *)self)->o, vec, self->rout);127 aubio_fft_rdo (self->o, self->cvecin, self->rout);
115 return (PyObject *)PyAubio_CFvecToArray(self->rout);128 return PyAubio_CFvecToArray(self->rout);
116}129}
117 130
118static PyMethodDef Py_fft_methods[] = {131static PyMethodDef Py_fft_methods[] = {
python/ext/py-filter.c+7−7
@@ -5,6 +5,7 @@ typedef struct · 4 unmodified lines
5 PyObject_HEAD5 PyObject_HEAD
6 aubio_filter_t * o;6 aubio_filter_t * o;
7 uint_t order;7 uint_t order;
8 fvec_t *vec;
8 fvec_t *out;9 fvec_t *out;
9} Py_filter;10} Py_filter;
10 11
@@ -49,6 +50,7 @@ Py_filter_init (Py_filter * self, PyObject * args, PyObject * kwds) · 38 unmodified lines
49 return -1;50 return -1;
50 }51 }
51 self->out = new_fvec(Py_default_vector_length);52 self->out = new_fvec(Py_default_vector_length);
53 self->vec = (fvec_t *)malloc(sizeof(fvec_t));
52 return 0;54 return 0;
53}55}
54 56
@@ -57,6 +59,7 @@ Py_filter_del (Py_filter * self) · 2 unmodified lines
57{59{
58 del_fvec(self->out);60 del_fvec(self->out);
59 del_aubio_filter (self->o);61 del_aubio_filter (self->o);
62 free(self->vec);
60 Py_TYPE(self)->tp_free ((PyObject *) self);63 Py_TYPE(self)->tp_free ((PyObject *) self);
61}64}
62 65
@@ -64,7 +67,6 @@ static PyObject * · 1 unmodified line
64Py_filter_do(Py_filter * self, PyObject * args)67Py_filter_do(Py_filter * self, PyObject * args)
65{68{
66 PyObject *input;69 PyObject *input;
67 fvec_t *vec;
68 70
69 if (!PyArg_ParseTuple (args, "O:digital_filter.do", &input)) {71 if (!PyArg_ParseTuple (args, "O:digital_filter.do", &input)) {
70 return NULL;72 return NULL;
@@ -74,19 +76,17 @@ Py_filter_do(Py_filter * self, PyObject * args) · 3 unmodified lines
74 return NULL;76 return NULL;
75 }77 }
76 78
77 vec = PyAubio_ArrayToCFvec (input);79 if (!PyAubio_ArrayToCFvec(input, self->vec)) {
78
79 if (vec == NULL) {
80 return NULL;80 return NULL;
81 }81 }
82 82
83 // reallocate the output if needed83 // reallocate the output if needed
84 if (vec->length != self->out->length) {84 if (self->vec->length != self->out->length) {
85 del_fvec(self->out);85 del_fvec(self->out);
86 self->out = new_fvec(vec->length);86 self->out = new_fvec(self->vec->length);
87 }87 }
88 // compute the function88 // compute the function
89 aubio_filter_do_outplace (self->o, vec, self->out);89 aubio_filter_do_outplace (self->o, self->vec, self->out);
90 return PyAubio_CFvecToArray(self->out);90 return PyAubio_CFvecToArray(self->out);
91}91}
92 92
python/ext/py-filterbank.c+21−18
@@ -8,7 +8,10 @@ typedef struct · 7 unmodified lines
8 aubio_filterbank_t * o;8 aubio_filterbank_t * o;
9 uint_t n_filters;9 uint_t n_filters;
10 uint_t win_s;10 uint_t win_s;
11 cvec_t *vec;
11 fvec_t *out;12 fvec_t *out;
13 fvec_t *freqs;
14 fmat_t *coeffs;
12} Py_filterbank;15} Py_filterbank;
13 16
14static PyObject *17static PyObject *
@@ -63,6 +66,14 @@ Py_filterbank_init (Py_filterbank * self, PyObject * args, PyObject * kwds) · 48 unmodified lines
63 }66 }
64 self->out = new_fvec(self->n_filters);67 self->out = new_fvec(self->n_filters);
65 68
69 self->vec = (cvec_t *)malloc(sizeof(cvec_t));
70
71 self->freqs = (fvec_t *)malloc(sizeof(fvec_t));
72
73 self->coeffs = (fmat_t *)malloc(sizeof(fmat_t));
74 self->coeffs->data = (smpl_t **)malloc(sizeof(smpl_t*) * self->n_filters);
75 self->coeffs->height = self->n_filters;
76
66 return 0;77 return 0;
67}78}
68 79
@@ -71,6 +82,10 @@ Py_filterbank_del (Py_filterbank *self, PyObject *unused) · 2 unmodified lines
71{82{
72 del_aubio_filterbank(self->o);83 del_aubio_filterbank(self->o);
73 del_fvec(self->out);84 del_fvec(self->out);
85 free(self->vec);
86 free(self->freqs);
87 free(self->coeffs->data);
88 free(self->coeffs);
74 Py_TYPE(self)->tp_free((PyObject *) self);89 Py_TYPE(self)->tp_free((PyObject *) self);
75}90}
76 91
@@ -78,20 +93,17 @@ static PyObject * · 1 unmodified line
78Py_filterbank_do(Py_filterbank * self, PyObject * args)93Py_filterbank_do(Py_filterbank * self, PyObject * args)
79{94{
80 PyObject *input;95 PyObject *input;
81 cvec_t *vec;
82 96
83 if (!PyArg_ParseTuple (args, "O", &input)) {97 if (!PyArg_ParseTuple (args, "O", &input)) {
84 return NULL;98 return NULL;
85 }99 }
86 100
87 vec = PyAubio_ArrayToCCvec (input);101 if (!PyAubio_ArrayToCCvec(input, self->vec)) {
88
89 if (vec == NULL) {
90 return NULL;102 return NULL;
91 }103 }
92 104
93 // compute the function105 // compute the function
94 aubio_filterbank_do (self->o, vec, self->out);106 aubio_filterbank_do (self->o, self->vec, self->out);
95 return (PyObject *)PyAubio_CFvecToArray(self->out);107 return (PyObject *)PyAubio_CFvecToArray(self->out);
96}108}
97 109
@@ -110,7 +122,6 @@ Py_filterbank_set_triangle_bands (Py_filterbank * self, PyObject *args) · 12 unmodified lines
110 122
111 PyObject *input;123 PyObject *input;
112 uint_t samplerate;124 uint_t samplerate;
113 fvec_t *freqs;
114 if (!PyArg_ParseTuple (args, "OI", &input, &samplerate)) {125 if (!PyArg_ParseTuple (args, "OI", &input, &samplerate)) {
115 return NULL;126 return NULL;
116 }127 }
@@ -119,14 +130,12 @@ Py_filterbank_set_triangle_bands (Py_filterbank * self, PyObject *args) · 2 unmodified lines
119 return NULL;130 return NULL;
120 }131 }
121 132
122 freqs = PyAubio_ArrayToCFvec (input);133 if (!PyAubio_ArrayToCFvec(input, self->freqs)) {
123
124 if (freqs == NULL) {
125 return NULL;134 return NULL;
126 }135 }
127 136
128 err = aubio_filterbank_set_triangle_bands (self->o,137 err = aubio_filterbank_set_triangle_bands (self->o,
129 freqs, samplerate);138 self->freqs, samplerate);
130 if (err > 0) {139 if (err > 0) {
131 PyErr_SetString (PyExc_ValueError,140 PyErr_SetString (PyExc_ValueError,
132 "error when setting filter to A-weighting");141 "error when setting filter to A-weighting");
@@ -160,21 +169,15 @@ Py_filterbank_set_coeffs (Py_filterbank * self, PyObject *args) · 27 unmodified lines
160 uint_t err = 0;169 uint_t err = 0;
161 170
162 PyObject *input;171 PyObject *input;
163 fmat_t *coeffs;
164
165 if (!PyArg_ParseTuple (args, "O", &input)) {172 if (!PyArg_ParseTuple (args, "O", &input)) {
166 return NULL;173 return NULL;
167 }174 }
168 175
169 coeffs = PyAubio_ArrayToCFmat (input);176 if (!PyAubio_ArrayToCFmat(input, self->coeffs)) {
170
171 if (coeffs == NULL) {
172 PyErr_SetString (PyExc_ValueError,
173 "unable to parse input array");
174 return NULL;177 return NULL;
175 }178 }
176 179
177 err = aubio_filterbank_set_coeffs (self->o, coeffs);180 err = aubio_filterbank_set_coeffs (self->o, self->coeffs);
178 181
179 if (err > 0) {182 if (err > 0) {
180 PyErr_SetString (PyExc_ValueError,183 PyErr_SetString (PyExc_ValueError,
python/ext/py-musicutils.c+16−8
@@ -37,12 +37,14 @@ Py_aubio_level_lin(PyObject *self, PyObject *args) · 36 unmodified lines
37 return NULL;37 return NULL;
38 }38 }
39 39
40 vec = PyAubio_ArrayToCFvec (input);40 vec = (fvec_t *)malloc(sizeof(fvec_t));
41 if (vec == NULL) {41 if (!PyAubio_ArrayToCFvec(input, vec)) {
42 free(vec);
42 return NULL;43 return NULL;
43 }44 }
44 45
45 level_lin = Py_BuildValue("f", aubio_level_lin(vec));46 level_lin = Py_BuildValue("f", aubio_level_lin(vec));
47 free(vec);
46 if (level_lin == NULL) {48 if (level_lin == NULL) {
47 PyErr_SetString (PyExc_ValueError, "failed computing level_lin");49 PyErr_SetString (PyExc_ValueError, "failed computing level_lin");
48 return NULL;50 return NULL;
@@ -67,12 +69,14 @@ Py_aubio_db_spl(PyObject *self, PyObject *args) · 18 unmodified lines
67 return NULL;69 return NULL;
68 }70 }
69 71
70 vec = PyAubio_ArrayToCFvec (input);72 vec = (fvec_t *)malloc(sizeof(fvec_t));
71 if (vec == NULL) {73 if (!PyAubio_ArrayToCFvec(input, vec)) {
74 free(vec);
72 return NULL;75 return NULL;
73 }76 }
74 77
75 db_spl = Py_BuildValue("f", aubio_db_spl(vec));78 db_spl = Py_BuildValue("f", aubio_db_spl(vec));
79 free(vec);
76 if (db_spl == NULL) {80 if (db_spl == NULL) {
77 PyErr_SetString (PyExc_ValueError, "failed computing db_spl");81 PyErr_SetString (PyExc_ValueError, "failed computing db_spl");
78 return NULL;82 return NULL;
@@ -98,12 +102,14 @@ Py_aubio_silence_detection(PyObject *self, PyObject *args) · 19 unmodified lines
98 return NULL;102 return NULL;
99 }103 }
100 104
101 vec = PyAubio_ArrayToCFvec (input);105 vec = (fvec_t *)malloc(sizeof(fvec_t));
102 if (vec == NULL) {106 if (!PyAubio_ArrayToCFvec(input, vec)) {
107 free(vec);
103 return NULL;108 return NULL;
104 }109 }
105 110
106 silence_detection = Py_BuildValue("I", aubio_silence_detection(vec, threshold));111 silence_detection = Py_BuildValue("I", aubio_silence_detection(vec, threshold));
112 free(vec);
107 if (silence_detection == NULL) {113 if (silence_detection == NULL) {
108 PyErr_SetString (PyExc_ValueError, "failed computing silence_detection");114 PyErr_SetString (PyExc_ValueError, "failed computing silence_detection");
109 return NULL;115 return NULL;
@@ -129,12 +135,14 @@ Py_aubio_level_detection(PyObject *self, PyObject *args) · 19 unmodified lines
129 return NULL;135 return NULL;
130 }136 }
131 137
132 vec = PyAubio_ArrayToCFvec (input);138 vec = (fvec_t *)malloc(sizeof(fvec_t));
133 if (vec == NULL) {139 if (!PyAubio_ArrayToCFvec(input, vec)) {
140 free(vec);
134 return NULL;141 return NULL;
135 }142 }
136 143
137 level_detection = Py_BuildValue("f", aubio_level_detection(vec, threshold));144 level_detection = Py_BuildValue("f", aubio_level_detection(vec, threshold));
145 free(vec);
138 if (level_detection == NULL) {146 if (level_detection == NULL) {
139 PyErr_SetString (PyExc_ValueError, "failed computing level_detection");147 PyErr_SetString (PyExc_ValueError, "failed computing level_detection");
140 return NULL;148 return NULL;
python/ext/py-phasevoc.c+23−13
@@ -8,7 +8,10 @@ typedef struct · 7 unmodified lines
8 aubio_pvoc_t * o;8 aubio_pvoc_t * o;
9 uint_t win_s;9 uint_t win_s;
10 uint_t hop_s;10 uint_t hop_s;
11 fvec_t *vecin;
11 cvec_t *output;12 cvec_t *output;
13 Py_cvec *py_out;
14 cvec_t *cvecin;
12 fvec_t *routput;15 fvec_t *routput;
13} Py_pvoc;16} Py_pvoc;
14 17
@@ -68,7 +71,11 @@ Py_pvoc_init (Py_pvoc * self, PyObject * args, PyObject * kwds) · 53 unmodified lines
68 return -1;71 return -1;
69 }72 }
70 73
74 self->cvecin = (cvec_t *)malloc(sizeof(cvec_t));
75 self->vecin = (fvec_t *)malloc(sizeof(fvec_t));
76
71 self->output = new_cvec(self->win_s);77 self->output = new_cvec(self->win_s);
78 self->py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
72 self->routput = new_fvec(self->hop_s);79 self->routput = new_fvec(self->hop_s);
73 80
74 return 0;81 return 0;
@@ -81,29 +88,35 @@ Py_pvoc_del (Py_pvoc *self, PyObject *unused) · 6 unmodified lines
81 del_aubio_pvoc(self->o);88 del_aubio_pvoc(self->o);
82 del_cvec(self->output);89 del_cvec(self->output);
83 del_fvec(self->routput);90 del_fvec(self->routput);
91 free(self->cvecin);
92 free(self->vecin);
84 Py_TYPE(self)->tp_free((PyObject *) self);93 Py_TYPE(self)->tp_free((PyObject *) self);
85}94}
86 95
87 96
88static PyObject * 97static PyObject *
89Py_pvoc_do(Py_pvoc * self, PyObject * args)98Py_pvoc_do(Py_pvoc * self, PyObject * args)
90{99{
91 PyObject *input;100 PyObject *input;
92 fvec_t *vec;
93 101
94 if (!PyArg_ParseTuple (args, "O", &input)) {102 if (!PyArg_ParseTuple (args, "O", &input)) {
95 return NULL;103 return NULL;
96 }104 }
97 105
98 vec = PyAubio_ArrayToCFvec (input);106 if (!PyAubio_ArrayToCFvec (input, self->vecin)) {
99
100 if (vec == NULL) {
101 return NULL;107 return NULL;
102 }108 }
103 109
104 // compute the function110 // compute the function
105 aubio_pvoc_do (self->o, vec, self->output);111 aubio_pvoc_do (self->o, self->vecin, self->output);
106 return (PyObject *)PyAubio_CCvecToPyCvec(self->output);112#if 0
113 Py_cvec * py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
114 PyObject* output = PyAubio_CCvecToPyCvec(self->output, py_out);
115 return output;
116#else
117 // convert cvec to py_cvec, incrementing refcount to keep a copy
118 return PyAubio_CCvecToPyCvec(self->output, self->py_out);
119#endif
107}120}
108 121
109static PyMemberDef Py_pvoc_members[] = {122static PyMemberDef Py_pvoc_members[] = {
@@ -118,20 +131,17 @@ static PyObject * · 8 unmodified lines
118Py_pvoc_rdo(Py_pvoc * self, PyObject * args)131Py_pvoc_rdo(Py_pvoc * self, PyObject * args)
119{132{
120 PyObject *input;133 PyObject *input;
121 cvec_t *vec;
122 if (!PyArg_ParseTuple (args, "O", &input)) {134 if (!PyArg_ParseTuple (args, "O", &input)) {
123 return NULL;135 return NULL;
124 }136 }
125 137
126 vec = PyAubio_ArrayToCCvec (input);138 if (!PyAubio_ArrayToCCvec (input, self->cvecin)) {
127
128 if (vec == NULL) {
129 return NULL;139 return NULL;
130 }140 }
131 141
132 // compute the function142 // compute the function
133 aubio_pvoc_rdo (self->o, vec, self->routput);143 aubio_pvoc_rdo (self->o, self->cvecin, self->routput);
134 return (PyObject *)PyAubio_CFvecToArray(self->routput);144 return PyAubio_CFvecToArray(self->routput);
135}145}
136 146
137static PyMethodDef Py_pvoc_methods[] = {147static PyMethodDef Py_pvoc_methods[] = {
python/ext/py-sink.c+13−18
@@ -7,6 +7,8 @@ typedef struct · 6 unmodified lines
7 char_t* uri;7 char_t* uri;
8 uint_t samplerate;8 uint_t samplerate;
9 uint_t channels;9 uint_t channels;
10 fvec_t *write_data;
11 fmat_t *mwrite_data;
10} Py_sink;12} Py_sink;
11 13
12static char Py_sink_doc[] = ""14static char Py_sink_doc[] = ""
@@ -121,6 +123,10 @@ Py_sink_init (Py_sink * self, PyObject * args, PyObject * kwds) · 108 unmodified lines
121 self->samplerate = aubio_sink_get_samplerate ( self->o );123 self->samplerate = aubio_sink_get_samplerate ( self->o );
122 self->channels = aubio_sink_get_channels ( self->o );124 self->channels = aubio_sink_get_channels ( self->o );
123 125
126 self->write_data = (fvec_t *)malloc(sizeof(fvec_t));
127 self->mwrite_data = (fmat_t *)malloc(sizeof(fmat_t));
128 self->mwrite_data->height = self->channels;
129 self->mwrite_data->data = (smpl_t **)malloc(sizeof(smpl_t*) * self->channels);
124 return 0;130 return 0;
125}131}
126 132
@@ -128,6 +134,9 @@ static void · 1 unmodified line
128Py_sink_del (Py_sink *self, PyObject *unused)134Py_sink_del (Py_sink *self, PyObject *unused)
129{135{
130 del_aubio_sink(self->o);136 del_aubio_sink(self->o);
137 free(self->write_data);
138 free(self->mwrite_data->data);
139 free(self->mwrite_data);
131 Py_TYPE(self)->tp_free((PyObject *) self);140 Py_TYPE(self)->tp_free((PyObject *) self);
132}141}
133 142
@@ -139,7 +148,6 @@ Py_sink_do(Py_sink * self, PyObject * args) · 5 unmodified lines
139 PyObject * write_data_obj;148 PyObject * write_data_obj;
140 149
141 /* input vectors prototypes */150 /* input vectors prototypes */
142 fvec_t* write_data;
143 uint_t write;151 uint_t write;
144 152
145 153
@@ -147,20 +155,14 @@ Py_sink_do(Py_sink * self, PyObject * args) · 1 unmodified line
147 return NULL;155 return NULL;
148 }156 }
149 157
150
151 /* input vectors parsing */158 /* input vectors parsing */
152 write_data = PyAubio_ArrayToCFvec (write_data_obj);159 if (!PyAubio_ArrayToCFvec(write_data_obj, self->write_data)) {
153
154 if (write_data == NULL) {
155 return NULL;160 return NULL;
156 }161 }
157 162
158 163
159
160
161
162 /* compute _do function */164 /* compute _do function */
163 aubio_sink_do (self->o, write_data, write);165 aubio_sink_do (self->o, self->write_data, write);
164 166
165 Py_RETURN_NONE;167 Py_RETURN_NONE;
166}168}
@@ -173,7 +175,6 @@ Py_sink_do_multi(Py_sink * self, PyObject * args) · 6 unmodified lines
173 PyObject * write_data_obj;175 PyObject * write_data_obj;
174 176
175 /* input vectors prototypes */177 /* input vectors prototypes */
176 fmat_t * write_data;
177 uint_t write;178 uint_t write;
178 179
179 180
@@ -183,18 +184,12 @@ Py_sink_do_multi(Py_sink * self, PyObject * args) · 3 unmodified lines
183 184
184 185
185 /* input vectors parsing */186 /* input vectors parsing */
186 write_data = PyAubio_ArrayToCFmat (write_data_obj);187 if (!PyAubio_ArrayToCFmat(write_data_obj, self->mwrite_data)) {
187
188 if (write_data == NULL) {
189 return NULL;188 return NULL;
190 }189 }
191 190
192
193
194
195
196 /* compute _do function */191 /* compute _do function */
197 aubio_sink_do_multi (self->o, write_data, write);192 aubio_sink_do_multi (self->o, self->mwrite_data, write);
198 Py_RETURN_NONE;193 Py_RETURN_NONE;
199}194}
200 195

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