Changeset d6f9b3a


Ignore:
Timestamp:
Nov 15, 2009, 3:01:06 PM (15 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
4bc098c
Parents:
965ea78
Message:

py-fvec.c: add PyAubio_CFvecToArray

Location:
interfaces/python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • interfaces/python/aubio-types.h

    r965ea78 rd6f9b3a  
    3636extern PyTypeObject Py_fvecType;
    3737extern PyObject *PyAubio_FvecToArray (Py_fvec * self);
     38extern PyObject *PyAubio_CFvecToArray (fvec_t * self);
    3839extern Py_fvec *PyAubio_ArrayToFvec (PyObject * self);
    3940
  • interfaces/python/py-fvec.c

    r965ea78 rd6f9b3a  
    177177
    178178PyObject *
     179PyAubio_CFvecToArray (fvec_t * self)
     180{
     181  PyObject *array = NULL;
     182  uint_t i;
     183  npy_intp dims[] = { self->length, 1 };
     184  PyObject *concat = PyList_New (0), *tmp = NULL;
     185  for (i = 0; i < self->channels; i++) {
     186    tmp = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->data[i]);
     187    PyList_Append (concat, tmp);
     188    Py_DECREF (tmp);
     189  }
     190  array = PyArray_FromObject (concat, AUBIO_NPY_SMPL, 2, 2);
     191  Py_DECREF (concat);
     192  return array;
     193}
     194
     195PyObject *
    179196PyAubio_FvecToArray (Py_fvec * self)
    180197{
     
    265282static PyMethodDef Py_fvec_methods[] = {
    266283  {"__array__", (PyCFunction) PyAubio_FvecToArray, METH_NOARGS,
    267       "Returns the first channel as a numpy array."},
     284      "Returns the vector as a numpy array."},
    268285  {NULL}
    269286};
Note: See TracChangeset for help on using the changeset viewer.