1 // WARNING: this file is generated, DO NOT EDIT
3 // WARNING: if you haven't read the first line yet, please do so
4 #include "aubiowraphell.h"
15 static char Py_source_doc[] = "source object";
18 Py_source_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
22 uint_t samplerate = 0;
24 static char *kwlist[] = { "uri", "samplerate", "hop_size", NULL };
26 if (!PyArg_ParseTupleAndKeywords (args, kwds, "|sII", kwlist,
27 &uri, &samplerate, &hop_size)) {
31 self = (Py_source *) pytype->tp_alloc (pytype, 0);
43 if ((sint_t)samplerate > 0) {
44 self->samplerate = samplerate;
45 } else if ((sint_t)samplerate < 0) {
46 PyErr_SetString (PyExc_ValueError,
47 "can not use negative value for samplerate");
51 self->hop_size = Py_default_vector_length / 2;
52 if ((sint_t)hop_size > 0) {
53 self->hop_size = hop_size;
54 } else if ((sint_t)hop_size < 0) {
55 PyErr_SetString (PyExc_ValueError,
56 "can not use negative value for hop_size");
60 return (PyObject *) self;
64 Py_source_init (Py_source * self, PyObject * args, PyObject * kwds)
66 self->o = new_aubio_source ( self->uri, self->samplerate, self->hop_size );
67 if (self->o == NULL) {
68 PyErr_SetString (PyExc_StandardError, "error creating object");
71 self->samplerate = aubio_source_get_samplerate ( self->o );
78 /* function Py_source_do */
80 Py_source_do(Py_source * self, PyObject * args)
84 /* output vectors prototypes */
93 /* creating output read_to as a new_fvec of length self->hop_size */
94 read_to = new_fvec (self->hop_size);
98 /* compute _do function */
99 aubio_source_do (self->o, read_to, &read);
101 PyObject *outputs = PyList_New(0);
102 PyList_Append( outputs, (PyObject *)PyAubio_CFvecToArray (read_to));
103 //del_fvec (read_to);
104 PyList_Append( outputs, (PyObject *)PyInt_FromLong (read));
108 AUBIO_MEMBERS_START(source)
109 {"uri", T_STRING, offsetof (Py_source, uri), READONLY, ""},
110 {"samplerate", T_INT, offsetof (Py_source, samplerate), READONLY, ""},
111 {"hop_size", T_INT, offsetof (Py_source, hop_size), READONLY, ""},
112 AUBIO_MEMBERS_STOP(source)
116 Pyaubio_source_get_samplerate (Py_source *self, PyObject *unused)
118 uint_t tmp = aubio_source_get_samplerate (self->o);
119 return (PyObject *)PyInt_FromLong (tmp);
123 Pyaubio_source_get_channels (Py_source *self, PyObject *unused)
125 uint_t tmp = aubio_source_get_channels (self->o);
126 return (PyObject *)PyInt_FromLong (tmp);
129 static PyMethodDef Py_source_methods[] = {
130 {"get_samplerate", (PyCFunction) Pyaubio_source_get_samplerate,
132 {"get_channels", (PyCFunction) Pyaubio_source_get_channels,
134 {NULL} /* sentinel */
137 AUBIO_TYPEOBJECT(source, "aubio.source")