Changeset b5bef11 for python/ext/py-filterbank.c
- Timestamp:
- Apr 21, 2016, 9:31:10 PM (8 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- a7f398d
- Parents:
- bfe8256
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/ext/py-filterbank.c
rbfe8256 rb5bef11 9 9 uint_t n_filters; 10 10 uint_t win_s; 11 cvec_t *vec; 11 12 fvec_t *out; 13 fvec_t *freqs; 14 fmat_t *coeffs; 12 15 } Py_filterbank; 13 16 … … 64 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 77 return 0; 67 78 } … … 72 83 del_aubio_filterbank(self->o); 73 84 del_fvec(self->out); 85 free(self->vec); 86 free(self->freqs); 87 free(self->coeffs->data); 88 free(self->coeffs); 74 89 Py_TYPE(self)->tp_free((PyObject *) self); 75 90 } … … 79 94 { 80 95 PyObject *input; 81 cvec_t *vec;82 96 83 97 if (!PyArg_ParseTuple (args, "O", &input)) { … … 85 99 } 86 100 87 vec = PyAubio_ArrayToCCvec (input); 88 89 if (vec == NULL) { 101 if (!PyAubio_ArrayToCCvec(input, self->vec)) { 90 102 return NULL; 91 103 } 92 104 93 105 // compute the function 94 aubio_filterbank_do (self->o, vec, self->out);106 aubio_filterbank_do (self->o, self->vec, self->out); 95 107 return (PyObject *)PyAubio_CFvecToArray(self->out); 96 108 } … … 111 123 PyObject *input; 112 124 uint_t samplerate; 113 fvec_t *freqs;114 125 if (!PyArg_ParseTuple (args, "OI", &input, &samplerate)) { 115 126 return NULL; … … 120 131 } 121 132 122 freqs = PyAubio_ArrayToCFvec (input); 123 124 if (freqs == NULL) { 133 if (!PyAubio_ArrayToCFvec(input, self->freqs)) { 125 134 return NULL; 126 135 } 127 136 128 137 err = aubio_filterbank_set_triangle_bands (self->o, 129 freqs, samplerate);138 self->freqs, samplerate); 130 139 if (err > 0) { 131 140 PyErr_SetString (PyExc_ValueError, … … 161 170 162 171 PyObject *input; 163 fmat_t *coeffs;164 165 172 if (!PyArg_ParseTuple (args, "O", &input)) { 166 173 return NULL; 167 174 } 168 175 169 coeffs = PyAubio_ArrayToCFmat (input); 170 171 if (coeffs == NULL) { 172 PyErr_SetString (PyExc_ValueError, 173 "unable to parse input array"); 174 return NULL; 175 } 176 177 err = aubio_filterbank_set_coeffs (self->o, coeffs); 176 if (!PyAubio_ArrayToCFmat(input, self->coeffs)) { 177 return NULL; 178 } 179 180 err = aubio_filterbank_set_coeffs (self->o, self->coeffs); 178 181 179 182 if (err > 0) {
Note: See TracChangeset
for help on using the changeset viewer.