Showing the changes to python/ext (8 of 9 files). Show all
Unified · Split
| @@ -83,7 +83,7 @@ static PyObject * · 82 unmodified lines | ||
| 83 | 83 | Py_alpha_norm (PyObject * self, PyObject * args) |
| 84 | 84 | { |
| 85 | 85 | PyObject *input; |
| 86 | − fvec_t *vec; | |
| 86 | + fvec_t vec; | |
| 87 | 87 | smpl_t alpha; |
| 88 | 88 | PyObject *result; |
| 89 | 89 | |
| @@ -95,15 +95,12 @@ Py_alpha_norm (PyObject * self, PyObject * args) · 5 unmodified lines | ||
| 95 | 95 | return NULL; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | − vec = (fvec_t *)malloc(sizeof(fvec_t)); | |
| 99 | − if (!PyAubio_ArrayToCFvec(input, vec)) { | |
| 100 | − free(vec); | |
| 98 | + if (!PyAubio_ArrayToCFvec(input, &vec)) { | |
| 101 | 99 | return NULL; |
| 102 | 100 | } |
| 103 | 101 | |
| 104 | 102 | // compute the function |
| 105 | − result = Py_BuildValue ("f", fvec_alpha_norm (vec, alpha)); | |
| 106 | − free(vec); | |
| 103 | + result = Py_BuildValue ("f", fvec_alpha_norm (&vec, alpha)); | |
| 107 | 104 | if (result == NULL) { |
| 108 | 105 | return NULL; |
| 109 | 106 | } |
| @@ -175,7 +172,7 @@ static PyObject * · 65 unmodified lines | ||
| 175 | 172 | Py_zero_crossing_rate (PyObject * self, PyObject * args) |
| 176 | 173 | { |
| 177 | 174 | PyObject *input; |
| 178 | − fvec_t *vec; | |
| 175 | + fvec_t vec; | |
| 179 | 176 | PyObject *result; |
| 180 | 177 | |
| 181 | 178 | if (!PyArg_ParseTuple (args, "O:zero_crossing_rate", &input)) { |
| @@ -186,15 +183,12 @@ Py_zero_crossing_rate (PyObject * self, PyObject * args) · 4 unmodified lines | ||
| 186 | 183 | return NULL; |
| 187 | 184 | } |
| 188 | 185 | |
| 189 | − vec = (fvec_t *)malloc(sizeof(fvec_t)); | |
| 190 | − if (!PyAubio_ArrayToCFvec(input, vec)) { | |
| 191 | − free(vec); | |
| 186 | + if (!PyAubio_ArrayToCFvec(input, &vec)) { | |
| 192 | 187 | return NULL; |
| 193 | 188 | } |
| 194 | 189 | |
| 195 | 190 | // compute the function |
| 196 | − result = Py_BuildValue ("f", aubio_zero_crossing_rate (vec)); | |
| 197 | − free(vec); | |
| 191 | + result = Py_BuildValue ("f", aubio_zero_crossing_rate (&vec)); | |
| 198 | 192 | if (result == NULL) { |
| 199 | 193 | return NULL; |
| 200 | 194 | } |
| @@ -206,7 +200,7 @@ static PyObject * · 5 unmodified lines | ||
| 206 | 200 | Py_min_removal(PyObject * self, PyObject * args) |
| 207 | 201 | { |
| 208 | 202 | PyObject *input; |
| 209 | − fvec_t *vec; | |
| 203 | + fvec_t vec; | |
| 210 | 204 | |
| 211 | 205 | if (!PyArg_ParseTuple (args, "O:min_removal", &input)) { |
| 212 | 206 | return NULL; |
| @@ -216,19 +210,17 @@ Py_min_removal(PyObject * self, PyObject * args) · 3 unmodified lines | ||
| 216 | 210 | return NULL; |
| 217 | 211 | } |
| 218 | 212 | |
| 219 | − vec = (fvec_t *)malloc(sizeof(fvec_t)); | |
| 220 | − if (!PyAubio_ArrayToCFvec(input, vec)) { | |
| 221 | − free(vec); | |
| 213 | + if (!PyAubio_ArrayToCFvec(input, &vec)) { | |
| 222 | 214 | return NULL; |
| 223 | 215 | } |
| 224 | 216 | |
| 225 | 217 | // compute the function |
| 226 | − fvec_min_removal (vec); | |
| 218 | + fvec_min_removal (&vec); | |
| 227 | 219 | |
| 228 | 220 | // since this function does not return, we could return None |
| 229 | 221 | //Py_RETURN_NONE; |
| 230 | 222 | // however it is convenient to return the modified vector |
| 231 | − return (PyObject *) PyAubio_CFvecToArray(vec); | |
| 223 | + return (PyObject *) PyAubio_CFvecToArray(&vec); | |
| 232 | 224 | // or even without converting it back to an array |
| 233 | 225 | //Py_INCREF(vec); |
| 234 | 226 | //return (PyObject *)vec; |
| @@ -143,17 +143,15 @@ PyAubio_ArrayToCFmat (PyObject *input, fmat_t *mat) { · 142 unmodified lines | ||
| 143 | 143 | return 0; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | − if (mat->height != (uint_t)PyArray_DIM ((PyArrayObject *)input, 0)) { | |
| 147 | − /* | |
| 148 | − free(mat->data); | |
| 149 | − mat->height = (uint_t)PyArray_DIM ((PyArrayObject *)input, 0); | |
| 150 | − mat->data = (smpl_t **)malloc(sizeof(smpl_t*) * mat->height); | |
| 151 | − */ | |
| 152 | − PyErr_Format(PyExc_ValueError, "too many rows, %d but %ld expected", | |
| 153 | − mat->height, PyArray_DIM ((PyArrayObject *)input, 0) ); | |
| 154 | − return 0; | |
| 146 | + uint_t new_height = (uint_t)PyArray_DIM ((PyArrayObject *)input, 0); | |
| 147 | + if (mat->height != new_height) { | |
| 148 | + if (mat->data) { | |
| 149 | + free(mat->data); | |
| 150 | + } | |
| 151 | + mat->data = (smpl_t **)malloc(sizeof(smpl_t*) * new_height); | |
| 155 | 152 | } |
| 156 | 153 | |
| 154 | + mat->height = new_height; | |
| 157 | 155 | mat->length = (uint_t)PyArray_DIM ((PyArrayObject *)input, 1); |
| 158 | 156 | for (i=0; i< mat->height; i++) { |
| 159 | 157 | mat->data[i] = (smpl_t*)PyArray_GETPTR1 ((PyArrayObject *)input, i); |
| @@ -7,11 +7,14 @@ typedef struct · 6 unmodified lines | ||
| 7 | 7 | PyObject_HEAD |
| 8 | 8 | aubio_fft_t * o; |
| 9 | 9 | uint_t win_s; |
| 10 | − fvec_t *vecin; | |
| 10 | + // do / rdo input vectors | |
| 11 | + fvec_t vecin; | |
| 12 | + cvec_t cvecin; | |
| 13 | + // do / rdo output results | |
| 11 | 14 | cvec_t *out; |
| 12 | − Py_cvec *py_out; | |
| 13 | − cvec_t *cvecin; | |
| 14 | 15 | fvec_t *rout; |
| 16 | + // bridge for cvec output | |
| 17 | + Py_cvec *py_out; | |
| 15 | 18 | } Py_fft; |
| 16 | 19 | |
| 17 | 20 | static PyObject * |
| @@ -56,9 +59,6 @@ Py_fft_init (Py_fft * self, PyObject * args, PyObject * kwds) · 38 unmodified lines | ||
| 56 | 59 | return -1; |
| 57 | 60 | } |
| 58 | 61 | |
| 59 | − self->cvecin = (cvec_t *)malloc(sizeof(cvec_t)); | |
| 60 | − self->vecin = (fvec_t *)malloc(sizeof(fvec_t)); | |
| 61 | − | |
| 62 | 62 | self->out = new_cvec(self->win_s); |
| 63 | 63 | self->py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType); |
| 64 | 64 | Py_XINCREF(self->py_out); |
| @@ -74,8 +74,6 @@ Py_fft_del (Py_fft *self, PyObject *unused) · 9 unmodified lines | ||
| 74 | 74 | del_aubio_fft(self->o); |
| 75 | 75 | del_cvec(self->out); |
| 76 | 76 | del_fvec(self->rout); |
| 77 | − free(self->cvecin); | |
| 78 | − free(self->vecin); | |
| 79 | 77 | Py_TYPE(self)->tp_free((PyObject *) self); |
| 80 | 78 | } |
| 81 | 79 | |
| @@ -88,12 +86,12 @@ Py_fft_do(Py_fft * self, PyObject * args) · 6 unmodified lines | ||
| 88 | 86 | return NULL; |
| 89 | 87 | } |
| 90 | 88 | |
| 91 | − if (!PyAubio_ArrayToCFvec(input, self->vecin)) { | |
| 89 | + if (!PyAubio_ArrayToCFvec(input, &(self->vecin))) { | |
| 92 | 90 | return NULL; |
| 93 | 91 | } |
| 94 | 92 | |
| 95 | 93 | // compute the function |
| 96 | − aubio_fft_do (((Py_fft *)self)->o, self->vecin, self->out); | |
| 94 | + aubio_fft_do (((Py_fft *)self)->o, &(self->vecin), self->out); | |
| 97 | 95 | #if 0 |
| 98 | 96 | Py_cvec * py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType); |
| 99 | 97 | PyObject* output = PyAubio_CCvecToPyCvec(self->out, py_out); |
| @@ -119,12 +117,12 @@ Py_fft_rdo(Py_fft * self, PyObject * args) · 19 unmodified lines | ||
| 119 | 117 | return NULL; |
| 120 | 118 | } |
| 121 | 119 | |
| 122 | − if (!PyAubio_ArrayToCCvec (input, self->cvecin) ) { | |
| 120 | + if (!PyAubio_ArrayToCCvec (input, &(self->cvecin)) ) { | |
| 123 | 121 | return NULL; |
| 124 | 122 | } |
| 125 | 123 | |
| 126 | 124 | // compute the function |
| 127 | − aubio_fft_rdo (self->o, self->cvecin, self->rout); | |
| 125 | + aubio_fft_rdo (self->o, &(self->cvecin), self->rout); | |
| 128 | 126 | return PyAubio_CFvecToArray(self->rout); |
| 129 | 127 | } |
| 130 | 128 | |
| @@ -5,7 +5,7 @@ typedef struct · 4 unmodified lines | ||
| 5 | 5 | PyObject_HEAD |
| 6 | 6 | aubio_filter_t * o; |
| 7 | 7 | uint_t order; |
| 8 | − fvec_t *vec; | |
| 8 | + fvec_t vec; | |
| 9 | 9 | fvec_t *out; |
| 10 | 10 | } Py_filter; |
| 11 | 11 | |
| @@ -50,7 +50,6 @@ Py_filter_init (Py_filter * self, PyObject * args, PyObject * kwds) · 38 unmodified lines | ||
| 50 | 50 | return -1; |
| 51 | 51 | } |
| 52 | 52 | self->out = new_fvec(Py_default_vector_length); |
| 53 | − self->vec = (fvec_t *)malloc(sizeof(fvec_t)); | |
| 54 | 53 | return 0; |
| 55 | 54 | } |
| 56 | 55 | |
| @@ -59,7 +58,6 @@ Py_filter_del (Py_filter * self) · 2 unmodified lines | ||
| 59 | 58 | { |
| 60 | 59 | del_fvec(self->out); |
| 61 | 60 | del_aubio_filter (self->o); |
| 62 | − free(self->vec); | |
| 63 | 61 | Py_TYPE(self)->tp_free ((PyObject *) self); |
| 64 | 62 | } |
| 65 | 63 | |
| @@ -76,17 +74,17 @@ Py_filter_do(Py_filter * self, PyObject * args) · 10 unmodified lines | ||
| 76 | 74 | return NULL; |
| 77 | 75 | } |
| 78 | 76 | |
| 79 | − if (!PyAubio_ArrayToCFvec(input, self->vec)) { | |
| 77 | + if (!PyAubio_ArrayToCFvec(input, &(self->vec))) { | |
| 80 | 78 | return NULL; |
| 81 | 79 | } |
| 82 | 80 | |
| 83 | 81 | // reallocate the output if needed |
| 84 | − if (self->vec->length != self->out->length) { | |
| 82 | + if (self->vec.length != self->out->length) { | |
| 85 | 83 | del_fvec(self->out); |
| 86 | − self->out = new_fvec(self->vec->length); | |
| 84 | + self->out = new_fvec(self->vec.length); | |
| 87 | 85 | } |
| 88 | 86 | // compute the function |
| 89 | − aubio_filter_do_outplace (self->o, self->vec, self->out); | |
| 87 | + aubio_filter_do_outplace (self->o, &(self->vec), self->out); | |
| 90 | 88 | return PyAubio_CFvecToArray(self->out); |
| 91 | 89 | } |
| 92 | 90 | |
| @@ -8,10 +8,10 @@ typedef struct · 7 unmodified lines | ||
| 8 | 8 | aubio_filterbank_t * o; |
| 9 | 9 | uint_t n_filters; |
| 10 | 10 | uint_t win_s; |
| 11 | − cvec_t *vec; | |
| 11 | + cvec_t vec; | |
| 12 | + fvec_t freqs; | |
| 13 | + fmat_t coeffs; | |
| 12 | 14 | fvec_t *out; |
| 13 | − fvec_t *freqs; | |
| 14 | − fmat_t *coeffs; | |
| 15 | 15 | } Py_filterbank; |
| 16 | 16 | |
| 17 | 17 | static PyObject * |
| @@ -66,14 +66,6 @@ Py_filterbank_init (Py_filterbank * self, PyObject * args, PyObject * kwds) · 48 unmodified lines | ||
| 66 | 66 | } |
| 67 | 67 | self->out = new_fvec(self->n_filters); |
| 68 | 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 | − | |
| 77 | 69 | return 0; |
| 78 | 70 | } |
| 79 | 71 | |
| @@ -82,10 +74,7 @@ Py_filterbank_del (Py_filterbank *self, PyObject *unused) · 2 unmodified lines | ||
| 82 | 74 | { |
| 83 | 75 | del_aubio_filterbank(self->o); |
| 84 | 76 | del_fvec(self->out); |
| 85 | − free(self->vec); | |
| 86 | − free(self->freqs); | |
| 87 | − free(self->coeffs->data); | |
| 88 | − free(self->coeffs); | |
| 77 | + free(self->coeffs.data); | |
| 89 | 78 | Py_TYPE(self)->tp_free((PyObject *) self); |
| 90 | 79 | } |
| 91 | 80 | |
| @@ -98,12 +87,12 @@ Py_filterbank_do(Py_filterbank * self, PyObject * args) · 6 unmodified lines | ||
| 98 | 87 | return NULL; |
| 99 | 88 | } |
| 100 | 89 | |
| 101 | − if (!PyAubio_ArrayToCCvec(input, self->vec)) { | |
| 90 | + if (!PyAubio_ArrayToCCvec(input, &(self->vec) )) { | |
| 102 | 91 | return NULL; |
| 103 | 92 | } |
| 104 | 93 | |
| 105 | 94 | // compute the function |
| 106 | − aubio_filterbank_do (self->o, self->vec, self->out); | |
| 95 | + aubio_filterbank_do (self->o, &(self->vec), self->out); | |
| 107 | 96 | return (PyObject *)PyAubio_CFvecToArray(self->out); |
| 108 | 97 | } |
| 109 | 98 | |
| @@ -130,12 +119,12 @@ Py_filterbank_set_triangle_bands (Py_filterbank * self, PyObject *args) · 20 unmodified lines | ||
| 130 | 119 | return NULL; |
| 131 | 120 | } |
| 132 | 121 | |
| 133 | − if (!PyAubio_ArrayToCFvec(input, self->freqs)) { | |
| 122 | + if (!PyAubio_ArrayToCFvec(input, &(self->freqs) )) { | |
| 134 | 123 | return NULL; |
| 135 | 124 | } |
| 136 | 125 | |
| 137 | 126 | err = aubio_filterbank_set_triangle_bands (self->o, |
| 138 | − self->freqs, samplerate); | |
| 127 | + &(self->freqs), samplerate); | |
| 139 | 128 | if (err > 0) { |
| 140 | 129 | PyErr_SetString (PyExc_ValueError, |
| 141 | 130 | "error when setting filter to A-weighting"); |
| @@ -173,11 +162,11 @@ Py_filterbank_set_coeffs (Py_filterbank * self, PyObject *args) · 31 unmodified lines | ||
| 173 | 162 | return NULL; |
| 174 | 163 | } |
| 175 | 164 | |
| 176 | − if (!PyAubio_ArrayToCFmat(input, self->coeffs)) { | |
| 165 | + if (!PyAubio_ArrayToCFmat(input, &(self->coeffs))) { | |
| 177 | 166 | return NULL; |
| 178 | 167 | } |
| 179 | 168 | |
| 180 | − err = aubio_filterbank_set_coeffs (self->o, self->coeffs); | |
| 169 | + err = aubio_filterbank_set_coeffs (self->o, &(self->coeffs)); | |
| 181 | 170 | |
| 182 | 171 | if (err > 0) { |
| 183 | 172 | PyErr_SetString (PyExc_ValueError, |
| @@ -25,7 +25,7 @@ PyObject * · 24 unmodified lines | ||
| 25 | 25 | Py_aubio_level_lin(PyObject *self, PyObject *args) |
| 26 | 26 | { |
| 27 | 27 | PyObject *input; |
| 28 | − fvec_t *vec; | |
| 28 | + fvec_t vec; | |
| 29 | 29 | PyObject *level_lin; |
| 30 | 30 | |
| 31 | 31 | if (!PyArg_ParseTuple (args, "O:level_lin", &input)) { |
| @@ -37,14 +37,11 @@ Py_aubio_level_lin(PyObject *self, PyObject *args) · 5 unmodified lines | ||
| 37 | 37 | return NULL; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | − vec = (fvec_t *)malloc(sizeof(fvec_t)); | |
| 41 | − if (!PyAubio_ArrayToCFvec(input, vec)) { | |
| 42 | − free(vec); | |
| 40 | + if (!PyAubio_ArrayToCFvec(input, &vec)) { | |
| 43 | 41 | return NULL; |
| 44 | 42 | } |
| 45 | 43 | |
| 46 | − level_lin = Py_BuildValue("f", aubio_level_lin(vec)); | |
| 47 | − free(vec); | |
| 44 | + level_lin = Py_BuildValue("f", aubio_level_lin(&vec)); | |
| 48 | 45 | if (level_lin == NULL) { |
| 49 | 46 | PyErr_SetString (PyExc_ValueError, "failed computing level_lin"); |
| 50 | 47 | return NULL; |
| @@ -57,7 +54,7 @@ PyObject * · 6 unmodified lines | ||
| 57 | 54 | Py_aubio_db_spl(PyObject *self, PyObject *args) |
| 58 | 55 | { |
| 59 | 56 | PyObject *input; |
| 60 | − fvec_t *vec; | |
| 57 | + fvec_t vec; | |
| 61 | 58 | PyObject *db_spl; |
| 62 | 59 | |
| 63 | 60 | if (!PyArg_ParseTuple (args, "O:db_spl", &input)) { |
| @@ -69,14 +66,11 @@ Py_aubio_db_spl(PyObject *self, PyObject *args) · 5 unmodified lines | ||
| 69 | 66 | return NULL; |
| 70 | 67 | } |
| 71 | 68 | |
| 72 | − vec = (fvec_t *)malloc(sizeof(fvec_t)); | |
| 73 | − if (!PyAubio_ArrayToCFvec(input, vec)) { | |
| 74 | − free(vec); | |
| 69 | + if (!PyAubio_ArrayToCFvec(input, &vec)) { | |
| 75 | 70 | return NULL; |
| 76 | 71 | } |
| 77 | 72 | |
| 78 | − db_spl = Py_BuildValue("f", aubio_db_spl(vec)); | |
| 79 | − free(vec); | |
| 73 | + db_spl = Py_BuildValue("f", aubio_db_spl(&vec)); | |
| 80 | 74 | if (db_spl == NULL) { |
| 81 | 75 | PyErr_SetString (PyExc_ValueError, "failed computing db_spl"); |
| 82 | 76 | return NULL; |
| @@ -89,7 +83,7 @@ PyObject * · 6 unmodified lines | ||
| 89 | 83 | Py_aubio_silence_detection(PyObject *self, PyObject *args) |
| 90 | 84 | { |
| 91 | 85 | PyObject *input; |
| 92 | − fvec_t *vec; | |
| 86 | + fvec_t vec; | |
| 93 | 87 | PyObject *silence_detection; |
| 94 | 88 | smpl_t threshold; |
| 95 | 89 | |
| @@ -102,14 +96,11 @@ Py_aubio_silence_detection(PyObject *self, PyObject *args) · 6 unmodified lines | ||
| 102 | 96 | return NULL; |
| 103 | 97 | } |
| 104 | 98 | |
| 105 | − vec = (fvec_t *)malloc(sizeof(fvec_t)); | |
| 106 | − if (!PyAubio_ArrayToCFvec(input, vec)) { | |
| 107 | − free(vec); | |
| 99 | + if (!PyAubio_ArrayToCFvec(input, &vec)) { | |
| 108 | 100 | return NULL; |
| 109 | 101 | } |
| 110 | 102 | |
| 111 | − silence_detection = Py_BuildValue("I", aubio_silence_detection(vec, threshold)); | |
| 112 | − free(vec); | |
| 103 | + silence_detection = Py_BuildValue("I", aubio_silence_detection(&vec, threshold)); | |
| 113 | 104 | if (silence_detection == NULL) { |
| 114 | 105 | PyErr_SetString (PyExc_ValueError, "failed computing silence_detection"); |
| 115 | 106 | return NULL; |
| @@ -122,7 +113,7 @@ PyObject * · 6 unmodified lines | ||
| 122 | 113 | Py_aubio_level_detection(PyObject *self, PyObject *args) |
| 123 | 114 | { |
| 124 | 115 | PyObject *input; |
| 125 | − fvec_t *vec; | |
| 116 | + fvec_t vec; | |
| 126 | 117 | PyObject *level_detection; |
| 127 | 118 | smpl_t threshold; |
| 128 | 119 | |
| @@ -135,14 +126,11 @@ Py_aubio_level_detection(PyObject *self, PyObject *args) · 6 unmodified lines | ||
| 135 | 126 | return NULL; |
| 136 | 127 | } |
| 137 | 128 | |
| 138 | − vec = (fvec_t *)malloc(sizeof(fvec_t)); | |
| 139 | − if (!PyAubio_ArrayToCFvec(input, vec)) { | |
| 140 | − free(vec); | |
| 129 | + if (!PyAubio_ArrayToCFvec(input, &vec)) { | |
| 141 | 130 | return NULL; |
| 142 | 131 | } |
| 143 | 132 | |
| 144 | − level_detection = Py_BuildValue("f", aubio_level_detection(vec, threshold)); | |
| 145 | − free(vec); | |
| 133 | + level_detection = Py_BuildValue("f", aubio_level_detection(&vec, threshold)); | |
| 146 | 134 | if (level_detection == NULL) { |
| 147 | 135 | PyErr_SetString (PyExc_ValueError, "failed computing level_detection"); |
| 148 | 136 | return NULL; |
| @@ -1,17 +1,15 @@ | ||
| 1 | 1 | #include "aubio-types.h" |
| 2 | 2 | |
| 3 | −static char Py_pvoc_doc[] = "pvoc object"; | |
| 4 | − | |
| 5 | 3 | typedef struct |
| 6 | 4 | { |
| 7 | 5 | PyObject_HEAD |
| 8 | 6 | aubio_pvoc_t * o; |
| 9 | 7 | uint_t win_s; |
| 10 | 8 | uint_t hop_s; |
| 11 | − fvec_t *vecin; | |
| 9 | + fvec_t vecin; | |
| 12 | 10 | cvec_t *output; |
| 13 | 11 | Py_cvec *py_out; |
| 14 | − cvec_t *cvecin; | |
| 12 | + cvec_t cvecin; | |
| 15 | 13 | fvec_t *routput; |
| 16 | 14 | } Py_pvoc; |
| 17 | 15 | |
| @@ -71,9 +69,6 @@ Py_pvoc_init (Py_pvoc * self, PyObject * args, PyObject * kwds) · 53 unmodified lines | ||
| 71 | 69 | return -1; |
| 72 | 70 | } |
| 73 | 71 | |
| 74 | − self->cvecin = (cvec_t *)malloc(sizeof(cvec_t)); | |
| 75 | − self->vecin = (fvec_t *)malloc(sizeof(fvec_t)); | |
| 76 | − | |
| 77 | 72 | self->output = new_cvec(self->win_s); |
| 78 | 73 | self->py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType); |
| 79 | 74 | self->routput = new_fvec(self->hop_s); |
| @@ -88,8 +83,6 @@ Py_pvoc_del (Py_pvoc *self, PyObject *unused) · 8 unmodified lines | ||
| 88 | 83 | del_aubio_pvoc(self->o); |
| 89 | 84 | del_cvec(self->output); |
| 90 | 85 | del_fvec(self->routput); |
| 91 | − free(self->cvecin); | |
| 92 | − free(self->vecin); | |
| 93 | 86 | Py_TYPE(self)->tp_free((PyObject *) self); |
| 94 | 87 | } |
| 95 | 88 | |
| @@ -103,12 +96,12 @@ Py_pvoc_do(Py_pvoc * self, PyObject * args) · 7 unmodified lines | ||
| 103 | 96 | return NULL; |
| 104 | 97 | } |
| 105 | 98 | |
| 106 | − if (!PyAubio_ArrayToCFvec (input, self->vecin)) { | |
| 99 | + if (!PyAubio_ArrayToCFvec (input, &(self->vecin) )) { | |
| 107 | 100 | return NULL; |
| 108 | 101 | } |
| 109 | 102 | |
| 110 | 103 | // compute the function |
| 111 | − aubio_pvoc_do (self->o, self->vecin, self->output); | |
| 104 | + aubio_pvoc_do (self->o, &(self->vecin), self->output); | |
| 112 | 105 | #if 0 |
| 113 | 106 | Py_cvec * py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType); |
| 114 | 107 | PyObject* output = PyAubio_CCvecToPyCvec(self->output, py_out); |
| @@ -135,12 +128,12 @@ Py_pvoc_rdo(Py_pvoc * self, PyObject * args) · 20 unmodified lines | ||
| 135 | 128 | return NULL; |
| 136 | 129 | } |
| 137 | 130 | |
| 138 | − if (!PyAubio_ArrayToCCvec (input, self->cvecin)) { | |
| 131 | + if (!PyAubio_ArrayToCCvec (input, &(self->cvecin) )) { | |
| 139 | 132 | return NULL; |
| 140 | 133 | } |
| 141 | 134 | |
| 142 | 135 | // compute the function |
| 143 | − aubio_pvoc_rdo (self->o, self->cvecin, self->routput); | |
| 136 | + aubio_pvoc_rdo (self->o, &(self->cvecin), self->routput); | |
| 144 | 137 | return PyAubio_CFvecToArray(self->routput); |
| 145 | 138 | } |
| 146 | 139 | |
| @@ -7,8 +7,8 @@ typedef struct · 6 unmodified lines | ||
| 7 | 7 | char_t* uri; |
| 8 | 8 | uint_t samplerate; |
| 9 | 9 | uint_t channels; |
| 10 | − fvec_t *write_data; | |
| 11 | − fmat_t *mwrite_data; | |
| 10 | + fvec_t write_data; | |
| 11 | + fmat_t mwrite_data; | |
| 12 | 12 | } Py_sink; |
| 13 | 13 | |
| 14 | 14 | static char Py_sink_doc[] = "" |
| @@ -123,10 +123,6 @@ Py_sink_init (Py_sink * self, PyObject * args, PyObject * kwds) · 108 unmodified lines | ||
| 123 | 123 | self->samplerate = aubio_sink_get_samplerate ( self->o ); |
| 124 | 124 | self->channels = aubio_sink_get_channels ( self->o ); |
| 125 | 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); | |
| 130 | 126 | return 0; |
| 131 | 127 | } |
| 132 | 128 | |
| @@ -134,9 +130,7 @@ static void · 1 unmodified line | ||
| 134 | 130 | Py_sink_del (Py_sink *self, PyObject *unused) |
| 135 | 131 | { |
| 136 | 132 | del_aubio_sink(self->o); |
| 137 | − free(self->write_data); | |
| 138 | − free(self->mwrite_data->data); | |
| 139 | − free(self->mwrite_data); | |
| 133 | + free(self->mwrite_data.data); | |
| 140 | 134 | Py_TYPE(self)->tp_free((PyObject *) self); |
| 141 | 135 | } |
| 142 | 136 | |
| @@ -156,13 +150,13 @@ Py_sink_do(Py_sink * self, PyObject * args) · 13 unmodified lines | ||
| 156 | 150 | } |
| 157 | 151 | |
| 158 | 152 | /* input vectors parsing */ |
| 159 | − if (!PyAubio_ArrayToCFvec(write_data_obj, self->write_data)) { | |
| 153 | + if (!PyAubio_ArrayToCFvec(write_data_obj, &(self->write_data))) { | |
| 160 | 154 | return NULL; |
| 161 | 155 | } |
| 162 | 156 | |
| 163 | 157 | |
| 164 | 158 | /* compute _do function */ |
| 165 | − aubio_sink_do (self->o, self->write_data, write); | |
| 159 | + aubio_sink_do (self->o, &(self->write_data), write); | |
| 166 | 160 | |
| 167 | 161 | Py_RETURN_NONE; |
| 168 | 162 | } |
| @@ -184,12 +178,12 @@ Py_sink_do_multi(Py_sink * self, PyObject * args) · 15 unmodified lines | ||
| 184 | 178 | |
| 185 | 179 | |
| 186 | 180 | /* input vectors parsing */ |
| 187 | − if (!PyAubio_ArrayToCFmat(write_data_obj, self->mwrite_data)) { | |
| 181 | + if (!PyAubio_ArrayToCFmat(write_data_obj, &(self->mwrite_data))) { | |
| 188 | 182 | return NULL; |
| 189 | 183 | } |
| 190 | 184 | |
| 191 | 185 | /* compute _do function */ |
| 192 | − aubio_sink_do_multi (self->o, self->mwrite_data, write); | |
| 186 | + aubio_sink_do_multi (self->o, &(self->mwrite_data), write); | |
| 193 | 187 | Py_RETURN_NONE; |
| 194 | 188 | } |
| 195 | 189 | |