Changeset 1ee5e21


Ignore:
Timestamp:
Apr 29, 2016, 9:37:46 PM (3 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
307fdfc
Parents:
ede5d38
Message:

python/ext/py-source.c: use new_py_foo here too

File:
1 edited

Legend:

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

    rede5d38 r1ee5e21  
    1010  uint_t hop_size;
    1111  uint_t duration;
    12   fvec_t *read_to;
    13   fmat_t *mread_to;
     12  PyObject *read_to;
     13  fvec_t c_read_to;
     14  PyObject *mread_to;
     15  fmat_t c_mread_to;
    1416} Py_source;
    1517
     
    150152  self->duration = aubio_source_get_duration ( self->o );
    151153
    152   self->read_to = new_fvec(self->hop_size);
    153   self->mread_to = new_fmat (self->channels, self->hop_size);
     154  self->read_to = new_py_fvec(self->hop_size);
     155  self->mread_to = new_py_fmat(self->channels, self->hop_size);
    154156
    155157  return 0;
     
    160162{
    161163  del_aubio_source(self->o);
    162   del_fvec(self->read_to);
    163   del_fmat(self->mread_to);
     164  //del_fvec(self->read_to);
     165  Py_XDECREF(self->read_to);
     166  Py_XDECREF(self->mread_to);
    164167  Py_TYPE(self)->tp_free((PyObject *) self);
    165168}
     
    170173Py_source_do(Py_source * self, PyObject * args)
    171174{
    172 
    173 
    174   /* output vectors prototypes */
    175175  uint_t read;
    176 
    177 
    178 
    179 
    180 
    181 
    182   /* creating output read_to as a new_fvec of length self->hop_size */
    183176  read = 0;
    184177
    185 
     178  Py_INCREF(self->read_to);
     179  if (!PyAubio_ArrayToCFvec(self->read_to, &(self->c_read_to))) {
     180    return NULL;
     181  }
    186182  /* compute _do function */
    187   aubio_source_do (self->o, self->read_to, &read);
     183  aubio_source_do (self->o, &(self->c_read_to), &read);
    188184
    189185  PyObject *outputs = PyTuple_New(2);
    190   PyTuple_SetItem( outputs, 0, (PyObject *)PyAubio_CFvecToArray (self->read_to) );
     186  PyTuple_SetItem( outputs, 0, self->read_to );
    191187  PyTuple_SetItem( outputs, 1, (PyObject *)PyLong_FromLong(read));
    192188  return outputs;
     
    197193Py_source_do_multi(Py_source * self, PyObject * args)
    198194{
    199 
    200 
    201   /* output vectors prototypes */
    202195  uint_t read;
    203 
    204 
    205 
    206 
    207 
    208 
    209   /* creating output mread_to as a new_fvec of length self->hop_size */
    210196  read = 0;
    211197
    212 
     198  Py_INCREF(self->mread_to);
     199  if (!PyAubio_ArrayToCFmat(self->mread_to,  &(self->c_mread_to))) {
     200    return NULL;
     201  }
    213202  /* compute _do function */
    214   aubio_source_do_multi (self->o, self->mread_to, &read);
     203  aubio_source_do_multi (self->o, &(self->c_mread_to), &read);
    215204
    216205  PyObject *outputs = PyTuple_New(2);
    217   PyTuple_SetItem( outputs, 0, (PyObject *)PyAubio_CFmatToArray (self->mread_to));
     206  PyTuple_SetItem( outputs, 0, self->mread_to);
    218207  PyTuple_SetItem( outputs, 1, (PyObject *)PyLong_FromLong(read));
    219208  return outputs;
Note: See TracChangeset for help on using the changeset viewer.