1 #include "aubio-types.h"
3 static char Py_pvoc_doc[] = "pvoc object";
21 Py_pvoc_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
23 int win_s = 0, hop_s = 0;
25 static char *kwlist[] = { "win_s", "hop_s", NULL };
27 if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
32 self = (Py_pvoc *) type->tp_alloc (type, 0);
38 self->win_s = Py_default_vector_length;
39 self->hop_s = Py_default_vector_length/2;
47 } else if (win_s < 0) {
48 PyErr_SetString (PyExc_ValueError,
49 "can not use negative window size");
55 } else if (hop_s < 0) {
56 PyErr_SetString (PyExc_ValueError,
57 "can not use negative hop size");
61 return (PyObject *) self;
65 Py_pvoc_init (Py_pvoc * self, PyObject * args, PyObject * kwds)
67 self->o = new_aubio_pvoc ( self->win_s, self->hop_s);
68 if (self->o == NULL) {
70 sprintf(errstr, "error creating pvoc with %d, %d", self->win_s, self->hop_s);
71 PyErr_SetString (PyExc_RuntimeError, errstr);
75 self->output = new_py_cvec(self->win_s);
76 self->routput = new_py_fvec(self->hop_s);
83 Py_pvoc_del (Py_pvoc *self, PyObject *unused)
85 Py_XDECREF(self->output);
86 Py_XDECREF(self->routput);
87 del_aubio_pvoc(self->o);
88 Py_TYPE(self)->tp_free((PyObject *) self);
93 Py_pvoc_do(Py_pvoc * self, PyObject * args)
97 if (!PyArg_ParseTuple (args, "O", &input)) {
101 if (!PyAubio_ArrayToCFvec (input, &(self->vecin) )) {
105 Py_INCREF(self->output);
106 if (!PyAubio_PyCvecToCCvec (self->output, &(self->c_output))) {
109 // compute the function
110 aubio_pvoc_do (self->o, &(self->vecin), &(self->c_output));
114 static PyMemberDef Py_pvoc_members[] = {
115 {"win_s", T_INT, offsetof (Py_pvoc, win_s), READONLY,
116 "size of the window"},
117 {"hop_s", T_INT, offsetof (Py_pvoc, hop_s), READONLY,
123 Py_pvoc_rdo(Py_pvoc * self, PyObject * args)
126 if (!PyArg_ParseTuple (args, "O", &input)) {
130 if (!PyAubio_PyCvecToCCvec (input, &(self->cvecin) )) {
134 Py_INCREF(self->routput);
135 if (!PyAubio_ArrayToCFvec(self->routput, &(self->c_routput)) ) {
138 // compute the function
139 aubio_pvoc_rdo (self->o, &(self->cvecin), &(self->c_routput));
140 return self->routput;
143 static PyMethodDef Py_pvoc_methods[] = {
144 {"rdo", (PyCFunction) Py_pvoc_rdo, METH_VARARGS,
145 "synthesis of spectral grain"},
149 PyTypeObject Py_pvocType = {
150 PyVarObject_HEAD_INIT (NULL, 0)
154 (destructor) Py_pvoc_del,
164 (ternaryfunc)Py_pvoc_do,
185 (initproc) Py_pvoc_init,