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->doout = new_py_cvec(self->win_s);
61 self->rdoout = new_py_fvec(self->win_s);
67 Py_fft_del (Py_fft *self, PyObject *unused)
69 Py_XDECREF(self->doout);
70 Py_XDECREF(self->rdoout);
71 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))) {
89 Py_INCREF(self->doout);
90 if (!PyAubio_PyCvecToCCvec(self->doout, &c_out)) {
93 // compute the function
94 aubio_fft_do (self->o, &(self->vecin), &c_out);
98 static PyMemberDef Py_fft_members[] = {
99 {"win_s", T_INT, offsetof (Py_fft, win_s), READONLY,
100 "size of the window"},
105 Py_fft_rdo(Py_fft * self, PyObject * args)
109 if (!PyArg_ParseTuple (args, "O", &input)) {
113 if (!PyAubio_PyCvecToCCvec (input, &(self->cvecin)) ) {
118 Py_INCREF(self->rdoout);
119 if (!PyAubio_ArrayToCFvec(self->rdoout, &out) ) {
122 // compute the function
123 aubio_fft_rdo (self->o, &(self->cvecin), &out);
127 static PyMethodDef Py_fft_methods[] = {
128 {"rdo", (PyCFunction) Py_fft_rdo, METH_VARARGS,
129 "synthesis of spectral grain"},
133 PyTypeObject Py_fftType = {
134 PyVarObject_HEAD_INIT (NULL, 0)
138 (destructor) Py_fft_del,
148 (ternaryfunc)Py_fft_do,
169 (initproc) Py_fft_init,