shithub: aubio

Download patch

ref: b055b4ec0a94cd0cf9ffa051ef46acd6588df831
parent: 307fdfc8dd8116eb6da152691da818fe350bfa8e
author: Paul Brossier <piem@piem.org>
date: Fri Apr 29 17:57:35 EDT 2016

python/ext/py-filterbank.c: use new_py_fvec

--- a/python/ext/py-filterbank.c
+++ b/python/ext/py-filterbank.c
@@ -11,7 +11,8 @@
   cvec_t vec;
   fvec_t freqs;
   fmat_t coeffs;
-  fvec_t *out;
+  PyObject *out;
+  fvec_t c_out;
 } Py_filterbank;
 
 static PyObject *
@@ -64,7 +65,7 @@
     PyErr_SetString (PyExc_RuntimeError, errstr);
     return -1;
   }
-  self->out = new_fvec(self->n_filters);
+  self->out = new_py_fvec(self->n_filters);
 
   return 0;
 }
@@ -73,7 +74,7 @@
 Py_filterbank_del (Py_filterbank *self, PyObject *unused)
 {
   del_aubio_filterbank(self->o);
-  del_fvec(self->out);
+  Py_DECREF(self->out);
   free(self->coeffs.data);
   Py_TYPE(self)->tp_free((PyObject *) self);
 }
@@ -91,9 +92,13 @@
     return NULL;
   }
 
+  Py_INCREF(self->out);
+  if (!PyAubio_ArrayToCFvec(self->out, &(self->c_out))) {
+    return NULL;
+  }
   // compute the function
-  aubio_filterbank_do (self->o, &(self->vec), self->out);
-  return (PyObject *)PyAubio_CFvecToArray(self->out);
+  aubio_filterbank_do (self->o, &(self->vec), &(self->c_out));
+  return self->out;
 }
 
 static PyMemberDef Py_filterbank_members[] = {