1 #include "aubiowraphell.h"
3 static char Py_pvoc_doc[] = "pvoc object";
5 AUBIO_DECLARE(pvoc, uint_t win_s; uint_t hop_s; uint_t channels)
9 Py_pvoc_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
11 int win_s = 0, hop_s = 0, channels = 0;
13 static char *kwlist[] = { "win_s", "hop_s", "channels", NULL };
15 if (!PyArg_ParseTupleAndKeywords (args, kwds, "|III", kwlist,
16 &win_s, &hop_s, &channels)) {
20 self = (Py_pvoc *) type->tp_alloc (type, 0);
26 self->win_s = Py_default_vector_length;
27 self->hop_s = Py_default_vector_length/2;
28 self->channels = Py_default_vector_channels;
36 } else if (win_s < 0) {
37 PyErr_SetString (PyExc_ValueError,
38 "can not use negative window size");
44 } else if (hop_s < 0) {
45 PyErr_SetString (PyExc_ValueError,
46 "can not use negative hop size");
51 self->channels = channels;
52 } else if (channels < 0) {
53 PyErr_SetString (PyExc_ValueError,
54 "can not use negative number of filters");
58 return (PyObject *) self;
62 AUBIO_INIT(pvoc, self->win_s, self->hop_s, self->channels)
67 Py_pvoc_do(PyObject * self, PyObject * args)
73 if (!PyArg_ParseTuple (args, "O", &input)) {
77 vec = PyAubio_ArrayToFvec (input);
83 output = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
84 output->channels = vec->channels;
85 output->length = ((Py_pvoc *) self)->win_s;
86 output->o = new_cvec(((Py_pvoc *) self)->win_s, vec->channels);
88 // compute the function
89 aubio_pvoc_do (((Py_pvoc *)self)->o, vec->o, output->o);
91 return (PyObject *)output;
92 //return (PyObject *)PyAubio_CvecToArray(output);
95 AUBIO_MEMBERS_START(pvoc)
96 {"win_s", T_INT, offsetof (Py_pvoc, win_s), READONLY,
97 "size of the window"},
98 {"hop_s", T_INT, offsetof (Py_pvoc, hop_s), READONLY,
100 {"channels", T_INT, offsetof (Py_pvoc, channels), READONLY,
101 "number of channels"},
102 AUBIO_MEMBERS_STOP(pvoc)
105 Py_pvoc_rdo(PyObject * self, PyObject * args)
111 if (!PyArg_ParseTuple (args, "O", &input)) {
115 vec = PyAubio_ArrayToCvec (input);
121 output = (Py_fvec*) PyObject_New (Py_fvec, &Py_fvecType);
122 output->channels = vec->channels;
123 output->length = ((Py_pvoc *) self)->hop_s;
124 output->o = new_fvec(output->length, output->channels);
126 // compute the function
127 aubio_pvoc_rdo (((Py_pvoc *)self)->o, vec->o, output->o);
128 return (PyObject *)PyAubio_FvecToArray(output);
131 static PyMethodDef Py_pvoc_methods[] = {
132 {"rdo", (PyCFunction) Py_pvoc_rdo, METH_VARARGS,
133 "synthesis of spectral grain"},
137 AUBIO_TYPEOBJECT(pvoc, "aubio.pvoc")