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