1 #include "aubio-types.h"
3 static char Py_fft_doc[] = "fft object";
10 // do / rdo input vectors
13 // do / rdo output results
19 Py_fft_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
23 static char *kwlist[] = { "win_s", NULL };
25 if (!PyArg_ParseTupleAndKeywords (args, kwds, "|I", kwlist,
30 self = (Py_fft *) type->tp_alloc (type, 0);
36 self->win_s = Py_default_vector_length;
40 } else if (win_s < 0) {
41 PyErr_SetString (PyExc_ValueError,
42 "can not use negative window size");
46 return (PyObject *) self;
50 Py_fft_init (Py_fft * self, PyObject * args, PyObject * kwds)
52 self->o = new_aubio_fft (self->win_s);
53 if (self->o == NULL) {
55 sprintf(errstr, "error creating fft with win_s=%d", self->win_s);
56 PyErr_SetString (PyExc_Exception, errstr);
60 self->out = new_cvec(self->win_s);
61 self->rout = new_fvec(self->win_s);
67 Py_fft_del (Py_fft *self, PyObject *unused)
69 del_aubio_fft(self->o);
72 Py_TYPE(self)->tp_free((PyObject *) self);
76 Py_fft_do(Py_fft * self, PyObject * args)
80 if (!PyArg_ParseTuple (args, "O", &input)) {
84 if (!PyAubio_ArrayToCFvec(input, &(self->vecin))) {
88 // compute the function
89 aubio_fft_do (((Py_fft *)self)->o, &(self->vecin), self->out);
90 // convert cvec to py_cvec
91 return PyAubio_CCvecToPyCvec(self->out);
94 static PyMemberDef Py_fft_members[] = {
95 {"win_s", T_INT, offsetof (Py_fft, win_s), READONLY,
96 "size of the window"},
101 Py_fft_rdo(Py_fft * self, PyObject * args)
105 if (!PyArg_ParseTuple (args, "O", &input)) {
109 if (!PyAubio_PyCvecToCCvec (input, &(self->cvecin)) ) {
113 // compute the function
114 aubio_fft_rdo (self->o, &(self->cvecin), self->rout);
115 return PyAubio_CFvecToArray(self->rout);
118 static PyMethodDef Py_fft_methods[] = {
119 {"rdo", (PyCFunction) Py_fft_rdo, METH_VARARGS,
120 "synthesis of spectral grain"},
124 PyTypeObject Py_fftType = {
125 PyVarObject_HEAD_INIT (NULL, 0)
129 (destructor) Py_fft_del,
139 (ternaryfunc)Py_fft_do,
160 (initproc) Py_fft_init,