1 #include "aubiowraphell.h"
3 static char Py_pvoc_doc[] = "pvoc object";
18 Py_pvoc_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
20 int win_s = 0, hop_s = 0;
22 static char *kwlist[] = { "win_s", "hop_s", NULL };
24 if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
29 self = (Py_pvoc *) type->tp_alloc (type, 0);
35 self->win_s = Py_default_vector_length;
36 self->hop_s = Py_default_vector_length/2;
44 } else if (win_s < 0) {
45 PyErr_SetString (PyExc_ValueError,
46 "can not use negative window size");
52 } else if (hop_s < 0) {
53 PyErr_SetString (PyExc_ValueError,
54 "can not use negative hop size");
58 self->output = new_cvec(self->win_s);
59 self->routput = new_fvec(self->hop_s);
61 return (PyObject *) self;
65 AUBIO_INIT(pvoc, self->win_s, self->hop_s)
68 Py_pvoc_del (Py_pvoc *self, PyObject *unused)
70 del_aubio_pvoc(self->o);
71 del_cvec(self->output);
72 del_fvec(self->routput);
73 self->ob_type->tp_free((PyObject *) self);
78 Py_pvoc_do(Py_pvoc * self, PyObject * args)
83 if (!PyArg_ParseTuple (args, "O", &input)) {
87 vec = PyAubio_ArrayToCFvec (input);
93 // compute the function
94 aubio_pvoc_do (self->o, vec, self->output);
95 return (PyObject *)PyAubio_CCvecToPyCvec(self->output);
98 AUBIO_MEMBERS_START(pvoc)
99 {"win_s", T_INT, offsetof (Py_pvoc, win_s), READONLY,
100 "size of the window"},
101 {"hop_s", T_INT, offsetof (Py_pvoc, hop_s), READONLY,
103 AUBIO_MEMBERS_STOP(pvoc)
106 Py_pvoc_rdo(Py_pvoc * self, PyObject * args)
110 if (!PyArg_ParseTuple (args, "O", &input)) {
114 vec = PyAubio_ArrayToCCvec (input);
120 // compute the function
121 aubio_pvoc_rdo (self->o, vec, self->routput);
122 return (PyObject *)PyAubio_CFvecToArray(self->routput);
125 static PyMethodDef Py_pvoc_methods[] = {
126 {"rdo", (PyCFunction) Py_pvoc_rdo, METH_VARARGS,
127 "synthesis of spectral grain"},
131 AUBIO_TYPEOBJECT(pvoc, "aubio.pvoc")