Ignore:
Timestamp:
Apr 21, 2016, 9:31:10 PM (8 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:
a7f398d
Parents:
bfe8256
Message:

ext/: use new proxy functions

File:
1 edited

Legend:

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

    rbfe8256 rb5bef11  
    99  uint_t win_s;
    1010  uint_t hop_s;
     11  fvec_t *vecin;
    1112  cvec_t *output;
     13  Py_cvec *py_out;
     14  cvec_t *cvecin;
    1215  fvec_t *routput;
    1316} Py_pvoc;
     
    6972  }
    7073
     74  self->cvecin = (cvec_t *)malloc(sizeof(cvec_t));
     75  self->vecin = (fvec_t *)malloc(sizeof(fvec_t));
     76
    7177  self->output = new_cvec(self->win_s);
     78  self->py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
    7279  self->routput = new_fvec(self->hop_s);
    7380
     
    8289  del_cvec(self->output);
    8390  del_fvec(self->routput);
     91  free(self->cvecin);
     92  free(self->vecin);
    8493  Py_TYPE(self)->tp_free((PyObject *) self);
    8594}
    8695
    8796
    88 static PyObject * 
     97static PyObject *
    8998Py_pvoc_do(Py_pvoc * self, PyObject * args)
    9099{
    91100  PyObject *input;
    92   fvec_t *vec;
    93101
    94102  if (!PyArg_ParseTuple (args, "O", &input)) {
     
    96104  }
    97105
    98   vec = PyAubio_ArrayToCFvec (input);
    99 
    100   if (vec == NULL) {
     106  if (!PyAubio_ArrayToCFvec (input, self->vecin)) {
    101107    return NULL;
    102108  }
    103109
    104110  // compute the function
    105   aubio_pvoc_do (self->o, vec, self->output);
    106   return (PyObject *)PyAubio_CCvecToPyCvec(self->output);
     111  aubio_pvoc_do (self->o, self->vecin, self->output);
     112#if 0
     113  Py_cvec * py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
     114  PyObject* output = PyAubio_CCvecToPyCvec(self->output, py_out);
     115  return output;
     116#else
     117  // convert cvec to py_cvec, incrementing refcount to keep a copy
     118  return PyAubio_CCvecToPyCvec(self->output, self->py_out);
     119#endif
    107120}
    108121
     
    119132{
    120133  PyObject *input;
    121   cvec_t *vec;
    122134  if (!PyArg_ParseTuple (args, "O", &input)) {
    123135    return NULL;
    124136  }
    125137
    126   vec = PyAubio_ArrayToCCvec (input);
    127 
    128   if (vec == NULL) {
     138  if (!PyAubio_ArrayToCCvec (input, self->cvecin)) {
    129139    return NULL;
    130140  }
    131141
    132142  // compute the function
    133   aubio_pvoc_rdo (self->o, vec, self->routput);
    134   return (PyObject *)PyAubio_CFvecToArray(self->routput);
     143  aubio_pvoc_rdo (self->o, self->cvecin, self->routput);
     144  return PyAubio_CFvecToArray(self->routput);
    135145}
    136146
Note: See TracChangeset for help on using the changeset viewer.