shithub: aubio

Download patch

ref: 1164bcdf2dccde23ef4484a0ea276edcf14f5fce
parent: 4a1378c12ffe7fd518448f6a1ab00f99f0557286
author: Paul Brossier <[email protected]>
date: Sun Feb 23 11:13:43 EST 2014

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

--- a/python/ext/py-source.c
+++ b/python/ext/py-source.c
@@ -6,6 +6,7 @@
   aubio_source_t * o;
   char_t* uri;
   uint_t samplerate;
+  uint_t channels;
   uint_t hop_size;
 } Py_source;
 
@@ -66,6 +67,7 @@
     return -1;
   }
   self->samplerate = aubio_source_get_samplerate ( self->o );
+  self->channels = aubio_source_get_channels ( self->o );
 
   return 0;
 }
@@ -73,7 +75,7 @@
 AUBIO_DEL(source)
 
 /* function Py_source_do */
-static PyObject * 
+static PyObject *
 Py_source_do(Py_source * self, PyObject * args)
 {
 
@@ -86,7 +88,7 @@
 
 
 
-  
+
   /* creating output read_to as a new_fvec of length self->hop_size */
   read_to = new_fvec (self->hop_size);
   read = 0;
@@ -102,9 +104,40 @@
   return outputs;
 }
 
+/* function Py_source_do_multi */
+static PyObject *
+Py_source_do_multi(Py_source * self, PyObject * args)
+{
+
+
+  /* output vectors prototypes */
+  fmat_t* read_to;
+  uint_t read;
+
+
+
+
+
+
+  /* creating output read_to as a new_fvec of length self->hop_size */
+  read_to = new_fmat (self->channels, self->hop_size);
+  read = 0;
+
+
+  /* compute _do function */
+  aubio_source_do_multi (self->o, read_to, &read);
+
+  PyObject *outputs = PyList_New(0);
+  PyList_Append( outputs, (PyObject *)PyAubio_CFmatToArray (read_to));
+  //del_fvec (read_to);
+  PyList_Append( outputs, (PyObject *)PyInt_FromLong (read));
+  return outputs;
+}
+
 AUBIO_MEMBERS_START(source)
   {"uri", T_STRING, offsetof (Py_source, uri), READONLY, ""},
   {"samplerate", T_INT, offsetof (Py_source, samplerate), READONLY, ""},
+  {"channels", T_INT, offsetof (Py_source, channels), READONLY, ""},
   {"hop_size", T_INT, offsetof (Py_source, hop_size), READONLY, ""},
 AUBIO_MEMBERS_STOP(source)
 
@@ -134,6 +167,8 @@
   {"get_samplerate", (PyCFunction) Pyaubio_source_get_samplerate,
     METH_NOARGS, ""},
   {"get_channels", (PyCFunction) Pyaubio_source_get_channels,
+    METH_NOARGS, ""},
+  {"do_multi", (PyCFunction) Py_source_do_multi,
     METH_NOARGS, ""},
   {"close", (PyCFunction) Pyaubio_source_close,
     METH_NOARGS, ""},