shithub: aubio

Download patch

ref: 965b3023a875aec9ec21765aa7bf71ffd2e9fb17
parent: 0178c655c9f1f49407c54de577c35dff7e1b828a
author: Paul Brossier <piem@piem.org>
date: Thu Dec 24 23:40:41 EST 2009

py-fft.c: use new proxy functions

--- a/interfaces/python/py-fft.c
+++ b/interfaces/python/py-fft.c
@@ -49,28 +49,24 @@
 Py_fft_do(PyObject * self, PyObject * args)
 {
   PyObject *input;
-  Py_fvec *vec;
-  Py_cvec *output;
+  fvec_t *vec;
+  cvec_t *output;
 
   if (!PyArg_ParseTuple (args, "O", &input)) {
     return NULL;
   }
 
-  vec = PyAubio_ArrayToFvec (input);
+  vec = PyAubio_ArrayToCFvec (input);
 
   if (vec == NULL) {
     return NULL;
   }
 
-  output = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
-  output->length = ((Py_fft *) self)->win_s;
-  output->o = new_cvec(((Py_fft *) self)->win_s);
+  output = new_cvec(((Py_fft *) self)->win_s);
 
   // compute the function
-  aubio_fft_do (((Py_fft *)self)->o, vec->o, output->o);
-  Py_INCREF(output);
-  return (PyObject *)output;
-  //return (PyObject *)PyAubio_CvecToArray(output);
+  aubio_fft_do (((Py_fft *)self)->o, vec, output);
+  return (PyObject *)PyAubio_CCvecToPyCvec(output);
 }
 
 AUBIO_MEMBERS_START(fft) 
@@ -79,29 +75,27 @@
 AUBIO_MEMBERS_STOP(fft)
 
 static PyObject * 
-Py_fft_rdo(PyObject * self, PyObject * args)
+Py_fft_rdo(Py_fft * self, PyObject * args)
 {
   PyObject *input;
-  Py_cvec *vec;
-  Py_fvec *output;
+  cvec_t *vec;
+  fvec_t *output;
 
   if (!PyArg_ParseTuple (args, "O", &input)) {
     return NULL;
   }
 
-  vec = PyAubio_ArrayToCvec (input);
+  vec = PyAubio_ArrayToCCvec (input);
 
   if (vec == NULL) {
     return NULL;
   }
 
-  output = (Py_fvec*) PyObject_New (Py_fvec, &Py_fvecType);
-  output->length = ((Py_fft *) self)->win_s;
-  output->o = new_fvec(output->length);
+  output = new_fvec(self->win_s);
 
   // compute the function
-  aubio_fft_rdo (((Py_fft *)self)->o, vec->o, output->o);
-  return (PyObject *)PyAubio_FvecToArray(output);
+  aubio_fft_rdo (((Py_fft *)self)->o, vec, output);
+  return (PyObject *)PyAubio_CFvecToArray(output);
 }
 
 static PyMethodDef Py_fft_methods[] = {