Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -265,6 +265,52 @@ Py_filterbank_get_coeffs (Py_filterbank * self, PyObject *unused) · 264 unmodified lines | ||
| 265 | 265 | aubio_filterbank_get_coeffs (self->o) ); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | +static PyObject * | |
| 269 | +Py_filterbank_set_power(Py_filterbank *self, PyObject *args) | |
| 270 | +{ | |
| 271 | + uint_t playing; | |
| 272 | + | |
| 273 | + if (!PyArg_ParseTuple (args, "I", &playing)) { | |
| 274 | + return NULL; | |
| 275 | + } | |
| 276 | + if(aubio_filterbank_set_power (self->o, playing)) { | |
| 277 | + if (PyErr_Occurred() == NULL) { | |
| 278 | + PyErr_SetString (PyExc_ValueError, | |
| 279 | + "error running filterbank.set_power"); | |
| 280 | + } else { | |
| 281 | + // change the RuntimeError into ValueError | |
| 282 | + PyObject *type, *value, *traceback; | |
| 283 | + PyErr_Fetch(&type, &value, &traceback); | |
| 284 | + PyErr_Restore(PyExc_ValueError, value, traceback); | |
| 285 | + } | |
| 286 | + return NULL; | |
| 287 | + } | |
| 288 | + Py_RETURN_NONE; | |
| 289 | +} | |
| 290 | + | |
| 291 | +static PyObject * | |
| 292 | +Py_filterbank_set_norm(Py_filterbank *self, PyObject *args) | |
| 293 | +{ | |
| 294 | + uint_t playing; | |
| 295 | + | |
| 296 | + if (!PyArg_ParseTuple (args, "I", &playing)) { | |
| 297 | + return NULL; | |
| 298 | + } | |
| 299 | + if(aubio_filterbank_set_norm (self->o, playing)) { | |
| 300 | + if (PyErr_Occurred() == NULL) { | |
| 301 | + PyErr_SetString (PyExc_ValueError, | |
| 302 | + "error running filterbank.set_power"); | |
| 303 | + } else { | |
| 304 | + // change the RuntimeError into ValueError | |
| 305 | + PyObject *type, *value, *traceback; | |
| 306 | + PyErr_Fetch(&type, &value, &traceback); | |
| 307 | + PyErr_Restore(PyExc_ValueError, value, traceback); | |
| 308 | + } | |
| 309 | + return NULL; | |
| 310 | + } | |
| 311 | + Py_RETURN_NONE; | |
| 312 | +} | |
| 313 | + | |
| 268 | 314 | static PyMethodDef Py_filterbank_methods[] = { |
| 269 | 315 | {"set_triangle_bands", (PyCFunction) Py_filterbank_set_triangle_bands, |
| 270 | 316 | METH_VARARGS, "set coefficients of filterbanks"}, |
| @@ -278,6 +324,10 @@ static PyMethodDef Py_filterbank_methods[] = { · 7 unmodified lines | ||
| 278 | 324 | METH_NOARGS, "get coefficients of filterbank"}, |
| 279 | 325 | {"set_coeffs", (PyCFunction) Py_filterbank_set_coeffs, |
| 280 | 326 | METH_VARARGS, "set coefficients of filterbank"}, |
| 327 | + {"set_power", (PyCFunction) Py_filterbank_set_power, | |
| 328 | + METH_VARARGS, "set power applied to filterbank input spectrum"}, | |
| 329 | + {"set_norm", (PyCFunction) Py_filterbank_set_norm, | |
| 330 | + METH_VARARGS, "set norm applied to filterbank input spectrum"}, | |
| 281 | 331 | {NULL} |
| 282 | 332 | }; |
| 283 | 333 | |