[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; |
---|
[569b363] | 28 | fvec_t vec; |
---|
[5a7e2c3] | 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 | |
---|
[569b363] | 40 | if (!PyAubio_ArrayToCFvec(input, &vec)) { |
---|
[5a7e2c3] | 41 | return NULL; |
---|
| 42 | } |
---|
| 43 | |
---|
[c6388f4] | 44 | level_lin = Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_level_lin(&vec)); |
---|
[5a7e2c3] | 45 | if (level_lin == NULL) { |
---|
| 46 | PyErr_SetString (PyExc_ValueError, "failed computing level_lin"); |
---|
| 47 | return NULL; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | return level_lin; |
---|
| 51 | } |
---|
[4615886a] | 52 | |
---|
| 53 | PyObject * |
---|
| 54 | Py_aubio_db_spl(PyObject *self, PyObject *args) |
---|
| 55 | { |
---|
| 56 | PyObject *input; |
---|
[569b363] | 57 | fvec_t vec; |
---|
[4615886a] | 58 | PyObject *db_spl; |
---|
| 59 | |
---|
| 60 | if (!PyArg_ParseTuple (args, "O:db_spl", &input)) { |
---|
| 61 | PyErr_SetString (PyExc_ValueError, "failed parsing arguments"); |
---|
| 62 | return NULL; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | if (input == NULL) { |
---|
| 66 | return NULL; |
---|
| 67 | } |
---|
| 68 | |
---|
[569b363] | 69 | if (!PyAubio_ArrayToCFvec(input, &vec)) { |
---|
[4615886a] | 70 | return NULL; |
---|
| 71 | } |
---|
| 72 | |
---|
[c6388f4] | 73 | db_spl = Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_db_spl(&vec)); |
---|
[4615886a] | 74 | if (db_spl == NULL) { |
---|
| 75 | PyErr_SetString (PyExc_ValueError, "failed computing db_spl"); |
---|
| 76 | return NULL; |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | return db_spl; |
---|
| 80 | } |
---|
[31a09d2] | 81 | |
---|
| 82 | PyObject * |
---|
| 83 | Py_aubio_silence_detection(PyObject *self, PyObject *args) |
---|
| 84 | { |
---|
| 85 | PyObject *input; |
---|
[569b363] | 86 | fvec_t vec; |
---|
[31a09d2] | 87 | PyObject *silence_detection; |
---|
| 88 | smpl_t threshold; |
---|
| 89 | |
---|
[c6388f4] | 90 | if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":silence_detection", &input, &threshold)) { |
---|
[31a09d2] | 91 | PyErr_SetString (PyExc_ValueError, "failed parsing arguments"); |
---|
| 92 | return NULL; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | if (input == NULL) { |
---|
| 96 | return NULL; |
---|
| 97 | } |
---|
| 98 | |
---|
[569b363] | 99 | if (!PyAubio_ArrayToCFvec(input, &vec)) { |
---|
[31a09d2] | 100 | return NULL; |
---|
| 101 | } |
---|
| 102 | |
---|
[569b363] | 103 | silence_detection = Py_BuildValue("I", aubio_silence_detection(&vec, threshold)); |
---|
[31a09d2] | 104 | if (silence_detection == NULL) { |
---|
| 105 | PyErr_SetString (PyExc_ValueError, "failed computing silence_detection"); |
---|
| 106 | return NULL; |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | return silence_detection; |
---|
| 110 | } |
---|
[9c8c8a6] | 111 | |
---|
| 112 | PyObject * |
---|
| 113 | Py_aubio_level_detection(PyObject *self, PyObject *args) |
---|
| 114 | { |
---|
| 115 | PyObject *input; |
---|
[569b363] | 116 | fvec_t vec; |
---|
[9c8c8a6] | 117 | PyObject *level_detection; |
---|
| 118 | smpl_t threshold; |
---|
| 119 | |
---|
[c6388f4] | 120 | if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":level_detection", &input, &threshold)) { |
---|
[9c8c8a6] | 121 | PyErr_SetString (PyExc_ValueError, "failed parsing arguments"); |
---|
| 122 | return NULL; |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | if (input == NULL) { |
---|
| 126 | return NULL; |
---|
| 127 | } |
---|
| 128 | |
---|
[569b363] | 129 | if (!PyAubio_ArrayToCFvec(input, &vec)) { |
---|
[9c8c8a6] | 130 | return NULL; |
---|
| 131 | } |
---|
| 132 | |
---|
[c6388f4] | 133 | level_detection = Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_level_detection(&vec, threshold)); |
---|
[9c8c8a6] | 134 | if (level_detection == NULL) { |
---|
| 135 | PyErr_SetString (PyExc_ValueError, "failed computing level_detection"); |
---|
| 136 | return NULL; |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | return level_detection; |
---|
| 140 | } |
---|