1 #include "aubiowraphell.h"
3 static char Py_fft_doc[] = "fft object";
16 Py_fft_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
20 static char *kwlist[] = { "win_s", NULL };
22 if (!PyArg_ParseTupleAndKeywords (args, kwds, "|I", kwlist,
27 self = (Py_fft *) type->tp_alloc (type, 0);
33 self->win_s = Py_default_vector_length;
37 } else if (win_s < 0) {
38 PyErr_SetString (PyExc_ValueError,
39 "can not use negative window size");
43 return (PyObject *) self;
47 Py_fft_init (Py_fft * self, PyObject * args, PyObject * kwds)
49 self->o = new_aubio_fft (self->win_s);
50 if (self->o == NULL) {
52 sprintf(errstr, "error creating fft with win_s=%d", self->win_s);
53 PyErr_SetString (PyExc_StandardError, errstr);
56 self->out = new_cvec(self->win_s);
57 self->rout = new_fvec(self->win_s);
63 Py_fft_del (Py_fft *self, PyObject *unused)
65 del_aubio_fft(self->o);
68 self->ob_type->tp_free((PyObject *) self);
72 Py_fft_do(Py_fft * self, PyObject * args)
77 if (!PyArg_ParseTuple (args, "O", &input)) {
81 vec = PyAubio_ArrayToCFvec (input);
87 // compute the function
88 aubio_fft_do (((Py_fft *)self)->o, vec, self->out);
89 return (PyObject *)PyAubio_CCvecToPyCvec(self->out);
92 AUBIO_MEMBERS_START(fft)
93 {"win_s", T_INT, offsetof (Py_fft, win_s), READONLY,
94 "size of the window"},
95 AUBIO_MEMBERS_STOP(fft)
98 Py_fft_rdo(Py_fft * self, PyObject * args)
103 if (!PyArg_ParseTuple (args, "O", &input)) {
107 vec = PyAubio_ArrayToCCvec (input);
113 // compute the function
114 aubio_fft_rdo (((Py_fft *)self)->o, vec, self->rout);
115 return (PyObject *)PyAubio_CFvecToArray(self->rout);
118 static PyMethodDef Py_fft_methods[] = {
119 {"rdo", (PyCFunction) Py_fft_rdo, METH_VARARGS,
120 "synthesis of spectral grain"},
124 AUBIO_TYPEOBJECT(fft, "aubio.fft")