Ignore:
Timestamp:
Jul 12, 2012, 1:38:40 AM (12 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, pitchshift, sampler, timestretch, yinfft+
Children:
5e3ed60
Parents:
93004d5
Message:

py-filterbank.c: add set_coeffs

File:
1 edited

Legend:

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

    r93004d5 rf6cbefe  
    5050AUBIO_DEL(filterbank)
    5151
    52 static PyObject * 
     52static PyObject *
    5353Py_filterbank_do(Py_filterbank * self, PyObject * args)
    5454{
     
    7474}
    7575
    76 AUBIO_MEMBERS_START(filterbank) 
     76AUBIO_MEMBERS_START(filterbank)
    7777  {"win_s", T_INT, offsetof (Py_filterbank, win_s), READONLY,
    7878    "size of the window"},
     
    8181AUBIO_MEMBERS_STOP(filterbank)
    8282
    83 static PyObject * 
     83static PyObject *
    8484Py_filterbank_set_triangle_bands (Py_filterbank * self, PyObject *args)
    8585{
     
    113113}
    114114
    115 static PyObject * 
     115static PyObject *
    116116Py_filterbank_set_mel_coeffs_slaney (Py_filterbank * self, PyObject *args)
    117117{
     
    132132}
    133133
    134 static PyObject *
     134static PyObject *
     135Py_filterbank_set_coeffs (Py_filterbank * self, PyObject *args)
     136{
     137  uint_t err = 0;
     138
     139  PyObject *input;
     140  fmat_t *coeffs;
     141
     142  if (!PyArg_ParseTuple (args, "O", &input)) {
     143    return NULL;
     144  }
     145
     146  coeffs = PyAubio_ArrayToCFmat (input);
     147
     148  if (coeffs == NULL) {
     149    PyErr_SetString (PyExc_ValueError,
     150        "unable to parse input array");
     151    return NULL;
     152  }
     153
     154  err = aubio_filterbank_set_coeffs (self->o, coeffs);
     155
     156  if (err > 0) {
     157    PyErr_SetString (PyExc_ValueError,
     158        "error when setting filter coefficients");
     159    return NULL;
     160  }
     161  return Py_None;
     162}
     163
     164static PyObject *
    135165Py_filterbank_get_coeffs (Py_filterbank * self, PyObject *unused)
    136166{
     
    146176  {"get_coeffs", (PyCFunction) Py_filterbank_get_coeffs,
    147177    METH_NOARGS, "get coefficients of filterbank"},
     178  {"set_coeffs", (PyCFunction) Py_filterbank_set_coeffs,
     179    METH_VARARGS, "set coefficients of filterbank"},
    148180  {NULL}
    149181};
Note: See TracChangeset for help on using the changeset viewer.