[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 | |
---|
[c6388f4] | 42 | level_lin = Py_BuildValue(AUBIO_NPY_SMPL_CHR, 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 | |
---|
[c6388f4] | 70 | db_spl = Py_BuildValue(AUBIO_NPY_SMPL_CHR, 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 | |
---|
[569b363] | 99 | silence_detection = Py_BuildValue("I", 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 | |
---|
[c6388f4] | 128 | level_detection = Py_BuildValue(AUBIO_NPY_SMPL_CHR, 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 | } |
---|