[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)) { |
---|
| 11 | PyErr_SetString (PyExc_ValueError, "failed parsing arguments"); |
---|
[913a7f1] | 12 | return NULL; |
---|
| 13 | } |
---|
| 14 | |
---|
[efa62ce] | 15 | window = new_aubio_window(wintype, winlen); |
---|
| 16 | if (window == NULL) { |
---|
| 17 | PyErr_SetString (PyExc_ValueError, "failed computing window"); |
---|
| 18 | return NULL; |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | return (PyObject *) PyAubio_CFvecToArray(window); |
---|
[913a7f1] | 22 | } |
---|
[5a7e2c3] | 23 | |
---|
| 24 | PyObject * |
---|
| 25 | Py_aubio_level_lin(PyObject *self, PyObject *args) |
---|
| 26 | { |
---|
| 27 | PyObject *input; |
---|
| 28 | fvec_t *vec; |
---|
| 29 | PyObject *level_lin; |
---|
| 30 | |
---|
| 31 | if (!PyArg_ParseTuple (args, "O:level_lin", &input)) { |
---|
| 32 | PyErr_SetString (PyExc_ValueError, "failed parsing arguments"); |
---|
| 33 | return NULL; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | if (input == NULL) { |
---|
| 37 | return NULL; |
---|
| 38 | } |
---|
| 39 | |
---|
[b5bef11] | 40 | vec = (fvec_t *)malloc(sizeof(fvec_t)); |
---|
| 41 | if (!PyAubio_ArrayToCFvec(input, vec)) { |
---|
| 42 | free(vec); |
---|
[5a7e2c3] | 43 | return NULL; |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | level_lin = Py_BuildValue("f", aubio_level_lin(vec)); |
---|
[b5bef11] | 47 | free(vec); |
---|
[5a7e2c3] | 48 | if (level_lin == NULL) { |
---|
| 49 | PyErr_SetString (PyExc_ValueError, "failed computing level_lin"); |
---|
| 50 | return NULL; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | return level_lin; |
---|
| 54 | } |
---|
[4615886a] | 55 | |
---|
| 56 | PyObject * |
---|
| 57 | Py_aubio_db_spl(PyObject *self, PyObject *args) |
---|
| 58 | { |
---|
| 59 | PyObject *input; |
---|
| 60 | fvec_t *vec; |
---|
| 61 | PyObject *db_spl; |
---|
| 62 | |
---|
| 63 | if (!PyArg_ParseTuple (args, "O:db_spl", &input)) { |
---|
| 64 | PyErr_SetString (PyExc_ValueError, "failed parsing arguments"); |
---|
| 65 | return NULL; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | if (input == NULL) { |
---|
| 69 | return NULL; |
---|
| 70 | } |
---|
| 71 | |
---|
[b5bef11] | 72 | vec = (fvec_t *)malloc(sizeof(fvec_t)); |
---|
| 73 | if (!PyAubio_ArrayToCFvec(input, vec)) { |
---|
| 74 | free(vec); |
---|
[4615886a] | 75 | return NULL; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | db_spl = Py_BuildValue("f", aubio_db_spl(vec)); |
---|
[b5bef11] | 79 | free(vec); |
---|
[4615886a] | 80 | if (db_spl == NULL) { |
---|
| 81 | PyErr_SetString (PyExc_ValueError, "failed computing db_spl"); |
---|
| 82 | return NULL; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | return db_spl; |
---|
| 86 | } |
---|
[31a09d2] | 87 | |
---|
| 88 | PyObject * |
---|
| 89 | Py_aubio_silence_detection(PyObject *self, PyObject *args) |
---|
| 90 | { |
---|
| 91 | PyObject *input; |
---|
| 92 | fvec_t *vec; |
---|
| 93 | PyObject *silence_detection; |
---|
| 94 | smpl_t threshold; |
---|
| 95 | |
---|
| 96 | if (!PyArg_ParseTuple (args, "Of:silence_detection", &input, &threshold)) { |
---|
| 97 | PyErr_SetString (PyExc_ValueError, "failed parsing arguments"); |
---|
| 98 | return NULL; |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | if (input == NULL) { |
---|
| 102 | return NULL; |
---|
| 103 | } |
---|
| 104 | |
---|
[b5bef11] | 105 | vec = (fvec_t *)malloc(sizeof(fvec_t)); |
---|
| 106 | if (!PyAubio_ArrayToCFvec(input, vec)) { |
---|
| 107 | free(vec); |
---|
[31a09d2] | 108 | return NULL; |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | silence_detection = Py_BuildValue("I", aubio_silence_detection(vec, threshold)); |
---|
[b5bef11] | 112 | free(vec); |
---|
[31a09d2] | 113 | if (silence_detection == NULL) { |
---|
| 114 | PyErr_SetString (PyExc_ValueError, "failed computing silence_detection"); |
---|
| 115 | return NULL; |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | return silence_detection; |
---|
| 119 | } |
---|
[9c8c8a6] | 120 | |
---|
| 121 | PyObject * |
---|
| 122 | Py_aubio_level_detection(PyObject *self, PyObject *args) |
---|
| 123 | { |
---|
| 124 | PyObject *input; |
---|
| 125 | fvec_t *vec; |
---|
| 126 | PyObject *level_detection; |
---|
| 127 | smpl_t threshold; |
---|
| 128 | |
---|
| 129 | if (!PyArg_ParseTuple (args, "Of:level_detection", &input, &threshold)) { |
---|
| 130 | PyErr_SetString (PyExc_ValueError, "failed parsing arguments"); |
---|
| 131 | return NULL; |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | if (input == NULL) { |
---|
| 135 | return NULL; |
---|
| 136 | } |
---|
| 137 | |
---|
[b5bef11] | 138 | vec = (fvec_t *)malloc(sizeof(fvec_t)); |
---|
| 139 | if (!PyAubio_ArrayToCFvec(input, vec)) { |
---|
| 140 | free(vec); |
---|
[9c8c8a6] | 141 | return NULL; |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | level_detection = Py_BuildValue("f", aubio_level_detection(vec, threshold)); |
---|
[b5bef11] | 145 | free(vec); |
---|
[9c8c8a6] | 146 | if (level_detection == NULL) { |
---|
| 147 | PyErr_SetString (PyExc_ValueError, "failed computing level_detection"); |
---|
| 148 | return NULL; |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | return level_detection; |
---|
| 152 | } |
---|