Changeset 1164bcdf


Ignore:
Timestamp:
Feb 23, 2014, 8:13:43 PM (11 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:
31a5c405
Parents:
4a1378c
Message:

python/ext/py-source.c: add do_multi and channels

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/ext/py-source.c

    r4a1378c r1164bcdf  
    77  char_t* uri;
    88  uint_t samplerate;
     9  uint_t channels;
    910  uint_t hop_size;
    1011} Py_source;
     
    6768  }
    6869  self->samplerate = aubio_source_get_samplerate ( self->o );
     70  self->channels = aubio_source_get_channels ( self->o );
    6971
    7072  return 0;
     
    7476
    7577/* function Py_source_do */
    76 static PyObject * 
     78static PyObject *
    7779Py_source_do(Py_source * self, PyObject * args)
    7880{
     
    8789
    8890
    89  
     91
    9092  /* creating output read_to as a new_fvec of length self->hop_size */
    9193  read_to = new_fvec (self->hop_size);
     
    103105}
    104106
     107/* function Py_source_do_multi */
     108static PyObject *
     109Py_source_do_multi(Py_source * self, PyObject * args)
     110{
     111
     112
     113  /* output vectors prototypes */
     114  fmat_t* read_to;
     115  uint_t read;
     116
     117
     118
     119
     120
     121
     122  /* creating output read_to as a new_fvec of length self->hop_size */
     123  read_to = new_fmat (self->channels, self->hop_size);
     124  read = 0;
     125
     126
     127  /* compute _do function */
     128  aubio_source_do_multi (self->o, read_to, &read);
     129
     130  PyObject *outputs = PyList_New(0);
     131  PyList_Append( outputs, (PyObject *)PyAubio_CFmatToArray (read_to));
     132  //del_fvec (read_to);
     133  PyList_Append( outputs, (PyObject *)PyInt_FromLong (read));
     134  return outputs;
     135}
     136
    105137AUBIO_MEMBERS_START(source)
    106138  {"uri", T_STRING, offsetof (Py_source, uri), READONLY, ""},
    107139  {"samplerate", T_INT, offsetof (Py_source, samplerate), READONLY, ""},
     140  {"channels", T_INT, offsetof (Py_source, channels), READONLY, ""},
    108141  {"hop_size", T_INT, offsetof (Py_source, hop_size), READONLY, ""},
    109142AUBIO_MEMBERS_STOP(source)
     
    136169  {"get_channels", (PyCFunction) Pyaubio_source_get_channels,
    137170    METH_NOARGS, ""},
     171  {"do_multi", (PyCFunction) Py_source_do_multi,
     172    METH_NOARGS, ""},
    138173  {"close", (PyCFunction) Pyaubio_source_close,
    139174    METH_NOARGS, ""},
Note: See TracChangeset for help on using the changeset viewer.