} Py_fvec;
extern PyTypeObject Py_fvecType;
extern PyObject *PyAubio_FvecToArray (Py_fvec * self);
+extern PyObject *PyAubio_CFvecToArray (fvec_t * self);
extern Py_fvec *PyAubio_ArrayToFvec (PyObject * self);
typedef struct
return NULL;
}
+PyObject *
+PyAubio_CFvecToArray (fvec_t * self)
+{
+ PyObject *array = NULL;
+ uint_t i;
+ npy_intp dims[] = { self->length, 1 };
+ PyObject *concat = PyList_New (0), *tmp = NULL;
+ for (i = 0; i < self->channels; i++) {
+ tmp = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->data[i]);
+ PyList_Append (concat, tmp);
+ Py_DECREF (tmp);
+ }
+ array = PyArray_FromObject (concat, AUBIO_NPY_SMPL, 2, 2);
+ Py_DECREF (concat);
+ return array;
+}
+
PyObject *
PyAubio_FvecToArray (Py_fvec * self)
{
static PyMethodDef Py_fvec_methods[] = {
{"__array__", (PyCFunction) PyAubio_FvecToArray, METH_NOARGS,
- "Returns the first channel as a numpy array."},
+ "Returns the vector as a numpy array."},
{NULL}
};