#include <numpy/arrayobject.h>
#include <aubio.h>
+#define Py_fvec_default_length 1024
+#define Py_fvec_default_channels 1
+
+#ifdef HAVE_AUBIO_DOUBLE
+#define AUBIO_FLOAT NPY_FLOAT
+#else
+#define AUBIO_FLOAT NPY_LONG
+#endif
+
+/**
+
+Defining this constant to 1 will allow PyAubio_CastToFvec to convert from data
+types different than NPY_FLOAT to and fvec, and therefore creating a copy of
+it.
+
+*/
+#define AUBIO_DO_CASTING 0
+
typedef struct
{
PyObject_HEAD fvec_t * o;
uint_t channels;
} Py_fvec;
extern PyTypeObject Py_fvecType;
+
+extern PyObject *PyAubio_FvecToArray (Py_fvec * self);
+
+extern Py_fvec *PyAubio_ArrayToFvec (PyObject * self);
*/
-#define Py_fvec_default_length 1024
-#define Py_fvec_default_channels 1
-
static char Py_fvec_doc[] = "fvec object";
static PyObject *
return Py_None;
}
-static PyObject *
-Py_fvec_array (Py_fvec * self)
+PyObject *
+PyAubio_FvecToArray (Py_fvec * self)
{
PyObject *array = NULL;
if (self->channels == 1) {
static PyMethodDef Py_fvec_methods[] = {
{"dump", (PyCFunction) Py_fvec_print, METH_NOARGS,
"Dumps the contents of the vector to stdout."},
- {"__array__", (PyCFunction) Py_fvec_array, METH_NOARGS,
+ {"__array__", (PyCFunction) PyAubio_FvecToArray, METH_NOARGS,
"Returns the first channel as a numpy array."},
{NULL}
};
PyTypeObject Py_fvecType = {
PyObject_HEAD_INIT (NULL)
0, /* ob_size */
- "fvec", /* tp_name */
+ "aubio.fvec", /* tp_name */
sizeof (Py_fvec), /* tp_basicsize */
0, /* tp_itemsize */
(destructor) Py_fvec_del, /* tp_dealloc */