Changeset b5bef11 for python/ext/py-phasevoc.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-phasevoc.c
rbfe8256 rb5bef11 9 9 uint_t win_s; 10 10 uint_t hop_s; 11 fvec_t *vecin; 11 12 cvec_t *output; 13 Py_cvec *py_out; 14 cvec_t *cvecin; 12 15 fvec_t *routput; 13 16 } Py_pvoc; … … 69 72 } 70 73 74 self->cvecin = (cvec_t *)malloc(sizeof(cvec_t)); 75 self->vecin = (fvec_t *)malloc(sizeof(fvec_t)); 76 71 77 self->output = new_cvec(self->win_s); 78 self->py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType); 72 79 self->routput = new_fvec(self->hop_s); 73 80 … … 82 89 del_cvec(self->output); 83 90 del_fvec(self->routput); 91 free(self->cvecin); 92 free(self->vecin); 84 93 Py_TYPE(self)->tp_free((PyObject *) self); 85 94 } 86 95 87 96 88 static PyObject * 97 static PyObject * 89 98 Py_pvoc_do(Py_pvoc * self, PyObject * args) 90 99 { 91 100 PyObject *input; 92 fvec_t *vec;93 101 94 102 if (!PyArg_ParseTuple (args, "O", &input)) { … … 96 104 } 97 105 98 vec = PyAubio_ArrayToCFvec (input); 99 100 if (vec == NULL) { 106 if (!PyAubio_ArrayToCFvec (input, self->vecin)) { 101 107 return NULL; 102 108 } 103 109 104 110 // compute the function 105 aubio_pvoc_do (self->o, vec, self->output); 106 return (PyObject *)PyAubio_CCvecToPyCvec(self->output); 111 aubio_pvoc_do (self->o, self->vecin, 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 … … 119 132 { 120 133 PyObject *input; 121 cvec_t *vec;122 134 if (!PyArg_ParseTuple (args, "O", &input)) { 123 135 return NULL; 124 136 } 125 137 126 vec = PyAubio_ArrayToCCvec (input); 127 128 if (vec == NULL) { 138 if (!PyAubio_ArrayToCCvec (input, self->cvecin)) { 129 139 return NULL; 130 140 } 131 141 132 142 // compute the function 133 aubio_pvoc_rdo (self->o, vec, self->routput);134 return (PyObject *)PyAubio_CFvecToArray(self->routput);143 aubio_pvoc_rdo (self->o, self->cvecin, self->routput); 144 return PyAubio_CFvecToArray(self->routput); 135 145 } 136 146
Note: See TracChangeset
for help on using the changeset viewer.