[913a7f1] | 1 | #include "aubio-types.h" |
---|
| 2 | |
---|
| 3 | PyObject * |
---|
| 4 | Py_aubio_window(PyObject *self, PyObject *args) |
---|
| 5 | { |
---|
| 6 | char_t *wintype = NULL; |
---|
| 7 | uint_t winlen = 0; |
---|
[efa62ce] | 8 | fvec_t *window = NULL; |
---|
[913a7f1] | 9 | |
---|
[efa62ce] | 10 | if (!PyArg_ParseTuple (args, "|sI", &wintype, &winlen)) { |
---|
[913a7f1] | 11 | return NULL; |
---|
| 12 | } |
---|
| 13 | |
---|
[efa62ce] | 14 | window = new_aubio_window(wintype, winlen); |
---|
| 15 | if (window == NULL) { |
---|
| 16 | PyErr_SetString (PyExc_ValueError, "failed computing window"); |
---|
| 17 | return NULL; |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | return (PyObject *) PyAubio_CFvecToArray(window); |
---|
[913a7f1] | 21 | } |
---|
[5a7e2c3] | 22 | |
---|
| 23 | PyObject * |
---|
| 24 | Py_aubio_level_lin(PyObject *self, PyObject *args) |
---|
| 25 | { |
---|
| 26 | PyObject *input; |
---|
[569b363] | 27 | fvec_t vec; |
---|
[5a7e2c3] | 28 | PyObject *level_lin; |
---|
| 29 | |
---|
| 30 | if (!PyArg_ParseTuple (args, "O:level_lin", &input)) { |
---|
| 31 | return NULL; |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | if (input == NULL) { |
---|
| 35 | return NULL; |
---|
| 36 | } |
---|
| 37 | |
---|
[569b363] | 38 | if (!PyAubio_ArrayToCFvec(input, &vec)) { |
---|
[5a7e2c3] | 39 | return NULL; |
---|
| 40 | } |
---|
| 41 | |
---|
[a617bf3] | 42 | level_lin = PyFloat_FromDouble(aubio_level_lin(&vec)); |
---|
[5a7e2c3] | 43 | if (level_lin == NULL) { |
---|
| 44 | PyErr_SetString (PyExc_ValueError, "failed computing level_lin"); |
---|
| 45 | return NULL; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | return level_lin; |
---|
| 49 | } |
---|
[4615886a] | 50 | |
---|
| 51 | PyObject * |
---|
| 52 | Py_aubio_db_spl(PyObject *self, PyObject *args) |
---|
| 53 | { |
---|
| 54 | PyObject *input; |
---|
[569b363] | 55 | fvec_t vec; |
---|
[4615886a] | 56 | PyObject *db_spl; |
---|
| 57 | |
---|
| 58 | if (!PyArg_ParseTuple (args, "O:db_spl", &input)) { |
---|
| 59 | return NULL; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | if (input == NULL) { |
---|
| 63 | return NULL; |
---|
| 64 | } |
---|
| 65 | |
---|
[569b363] | 66 | if (!PyAubio_ArrayToCFvec(input, &vec)) { |
---|
[4615886a] | 67 | return NULL; |
---|
| 68 | } |
---|
| 69 | |
---|
[a617bf3] | 70 | db_spl = PyFloat_FromDouble(aubio_db_spl(&vec)); |
---|
[4615886a] | 71 | if (db_spl == NULL) { |
---|
| 72 | PyErr_SetString (PyExc_ValueError, "failed computing db_spl"); |
---|
| 73 | return NULL; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | return db_spl; |
---|
| 77 | } |
---|
[31a09d2] | 78 | |
---|
| 79 | PyObject * |
---|
| 80 | Py_aubio_silence_detection(PyObject *self, PyObject *args) |
---|
| 81 | { |
---|
| 82 | PyObject *input; |
---|
[569b363] | 83 | fvec_t vec; |
---|
[31a09d2] | 84 | PyObject *silence_detection; |
---|
| 85 | smpl_t threshold; |
---|
| 86 | |
---|
[c6388f4] | 87 | if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":silence_detection", &input, &threshold)) { |
---|
[31a09d2] | 88 | return NULL; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | if (input == NULL) { |
---|
| 92 | return NULL; |
---|
| 93 | } |
---|
| 94 | |
---|
[569b363] | 95 | if (!PyAubio_ArrayToCFvec(input, &vec)) { |
---|
[31a09d2] | 96 | return NULL; |
---|
| 97 | } |
---|
| 98 | |
---|
[a617bf3] | 99 | silence_detection = PyLong_FromLong(aubio_silence_detection(&vec, threshold)); |
---|
[31a09d2] | 100 | if (silence_detection == NULL) { |
---|
| 101 | PyErr_SetString (PyExc_ValueError, "failed computing silence_detection"); |
---|
| 102 | return NULL; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | return silence_detection; |
---|
| 106 | } |
---|
[9c8c8a6] | 107 | |
---|
| 108 | PyObject * |
---|
| 109 | Py_aubio_level_detection(PyObject *self, PyObject *args) |
---|
| 110 | { |
---|
| 111 | PyObject *input; |
---|
[569b363] | 112 | fvec_t vec; |
---|
[9c8c8a6] | 113 | PyObject *level_detection; |
---|
| 114 | smpl_t threshold; |
---|
| 115 | |
---|
[c6388f4] | 116 | if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":level_detection", &input, &threshold)) { |
---|
[9c8c8a6] | 117 | return NULL; |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | if (input == NULL) { |
---|
| 121 | return NULL; |
---|
| 122 | } |
---|
| 123 | |
---|
[569b363] | 124 | if (!PyAubio_ArrayToCFvec(input, &vec)) { |
---|
[9c8c8a6] | 125 | return NULL; |
---|
| 126 | } |
---|
| 127 | |
---|
[a617bf3] | 128 | level_detection = PyFloat_FromDouble(aubio_level_detection(&vec, threshold)); |
---|
[9c8c8a6] | 129 | if (level_detection == NULL) { |
---|
| 130 | PyErr_SetString (PyExc_ValueError, "failed computing level_detection"); |
---|
| 131 | return NULL; |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | return level_detection; |
---|
| 135 | } |
---|
[b532275] | 136 | |
---|
| 137 | PyObject * |
---|
| 138 | Py_aubio_shift(PyObject *self, PyObject *args) |
---|
| 139 | { |
---|
| 140 | PyObject *input; |
---|
| 141 | fvec_t vec; |
---|
| 142 | |
---|
| 143 | if (!PyArg_ParseTuple (args, "O:shift", &input)) { |
---|
| 144 | return NULL; |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | if (input == NULL) { |
---|
| 148 | return NULL; |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | if (!PyAubio_ArrayToCFvec(input, &vec)) { |
---|
| 152 | return NULL; |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | fvec_shift(&vec); |
---|
| 156 | |
---|
| 157 | //Py_RETURN_NONE; |
---|
| 158 | return (PyObject *) PyAubio_CFvecToArray(&vec); |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | PyObject * |
---|
| 162 | Py_aubio_ishift(PyObject *self, PyObject *args) |
---|
| 163 | { |
---|
| 164 | PyObject *input; |
---|
| 165 | fvec_t vec; |
---|
| 166 | |
---|
| 167 | if (!PyArg_ParseTuple (args, "O:shift", &input)) { |
---|
| 168 | return NULL; |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | if (input == NULL) { |
---|
| 172 | return NULL; |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | if (!PyAubio_ArrayToCFvec(input, &vec)) { |
---|
| 176 | return NULL; |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | fvec_ishift(&vec); |
---|
| 180 | |
---|
| 181 | //Py_RETURN_NONE; |
---|
| 182 | return (PyObject *) PyAubio_CFvecToArray(&vec); |
---|
| 183 | } |
---|
[bc66f1d] | 184 | |
---|
| 185 | PyObject* |
---|
| 186 | Py_aubio_hztomel(PyObject *self, PyObject *args, PyObject *kwds) |
---|
| 187 | { |
---|
| 188 | smpl_t v; |
---|
| 189 | PyObject *htk = NULL; |
---|
| 190 | static char *kwlist[] = {"f", "htk", NULL}; |
---|
| 191 | if (!PyArg_ParseTupleAndKeywords(args, kwds, AUBIO_NPY_SMPL_CHR "|O", |
---|
| 192 | kwlist, &v, &htk)) |
---|
| 193 | { |
---|
| 194 | return NULL; |
---|
| 195 | } |
---|
| 196 | if (htk != NULL && PyObject_IsTrue(htk) == 1) |
---|
[ca9d5aa] | 197 | return PyFloat_FromDouble(aubio_hztomel_htk(v)); |
---|
[bc66f1d] | 198 | else |
---|
[ca9d5aa] | 199 | return PyFloat_FromDouble(aubio_hztomel(v)); |
---|
[bc66f1d] | 200 | } |
---|
| 201 | |
---|
| 202 | PyObject* |
---|
| 203 | Py_aubio_meltohz(PyObject *self, PyObject *args, PyObject *kwds) |
---|
| 204 | { |
---|
| 205 | smpl_t v; |
---|
| 206 | PyObject *htk = NULL; |
---|
| 207 | static char *kwlist[] = {"m", "htk", NULL}; |
---|
| 208 | if (!PyArg_ParseTupleAndKeywords(args, kwds, AUBIO_NPY_SMPL_CHR "|O", |
---|
| 209 | kwlist, &v, &htk)) |
---|
| 210 | { |
---|
| 211 | return NULL; |
---|
| 212 | } |
---|
| 213 | if (htk != NULL && PyObject_IsTrue(htk) == 1) |
---|
[ca9d5aa] | 214 | return PyFloat_FromDouble(aubio_meltohz_htk(v)); |
---|
[bc66f1d] | 215 | else |
---|
[ca9d5aa] | 216 | return PyFloat_FromDouble(aubio_meltohz(v)); |
---|
[bc66f1d] | 217 | } |
---|
| 218 | |
---|
| 219 | PyObject* |
---|
| 220 | Py_aubio_hztomel_htk(PyObject *self, PyObject *args) |
---|
| 221 | { |
---|
| 222 | smpl_t v; |
---|
| 223 | if (!PyArg_ParseTuple(args, AUBIO_NPY_SMPL_CHR, &v)) { |
---|
| 224 | return NULL; |
---|
| 225 | } |
---|
[ca9d5aa] | 226 | return PyFloat_FromDouble(aubio_hztomel_htk(v)); |
---|
[bc66f1d] | 227 | } |
---|
| 228 | |
---|
| 229 | PyObject* |
---|
| 230 | Py_aubio_meltohz_htk(PyObject *self, PyObject *args) |
---|
| 231 | { |
---|
| 232 | smpl_t v; |
---|
| 233 | if (!PyArg_ParseTuple(args, AUBIO_NPY_SMPL_CHR, &v)) { |
---|
| 234 | return NULL; |
---|
| 235 | } |
---|
[ca9d5aa] | 236 | return PyFloat_FromDouble(aubio_meltohz_htk(v)); |
---|
[bc66f1d] | 237 | } |
---|