Changeset 78706cd


Ignore:
Timestamp:
Nov 17, 2018, 12:23:45 PM (5 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
Children:
16f0c27
Parents:
831f702
Message:

[py] add filterbank.set_power and set_norm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/ext/py-filterbank.c

    r831f702 r78706cd  
    264264  return (PyObject *)PyAubio_CFmatToArray(
    265265      aubio_filterbank_get_coeffs (self->o) );
     266}
     267
     268static PyObject *
     269Py_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
     291static PyObject *
     292Py_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;
    266312}
    267313
     
    279325  {"set_coeffs", (PyCFunction) Py_filterbank_set_coeffs,
    280326    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"},
    281331  {NULL}
    282332};
Note: See TracChangeset for help on using the changeset viewer.