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