History

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

Paul Brossier committed 12 years ago

Commit 1164bcd1 parent 4a1378c1 file · +37 −2Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/ext/py-source.c+37−2
@@ -6,6 +6,7 @@ typedef struct · 5 unmodified lines
66 aubio_source_t * o;
77 char_t* uri;
88 uint_t samplerate;
9+ uint_t channels;
910 uint_t hop_size;
1011 } Py_source;
1112
@@ -66,6 +67,7 @@ Py_source_init (Py_source * self, PyObject * args, PyObject * kwds) · 54 unmodified lines
6667 return -1;
6768 }
6869 self->samplerate = aubio_source_get_samplerate ( self->o );
70+ self->channels = aubio_source_get_channels ( self->o );
6971
7072 return 0;
7173 }
@@ -73,7 +75,7 @@ Py_source_init (Py_source * self, PyObject * args, PyObject * kwds) · 1 unmodified line
7375 AUBIO_DEL(source)
7476
7577 /* function Py_source_do */
76−static PyObject *
78+static PyObject *
7779 Py_source_do(Py_source * self, PyObject * args)
7880 {
7981
@@ -86,7 +88,7 @@ Py_source_do(Py_source * self, PyObject * args) · 6 unmodified lines
8688
8789
8890
89−
91+
9092 /* creating output read_to as a new_fvec of length self->hop_size */
9193 read_to = new_fvec (self->hop_size);
9294 read = 0;
@@ -102,9 +104,40 @@ Py_source_do(Py_source * self, PyObject * args) · 9 unmodified lines
102104 return outputs;
103105 }
104106
107+/* function Py_source_do_multi */
108+static PyObject *
109+Py_source_do_multi(Py_source * self, PyObject * args)
110+{
111+
112+
113+ /* output vectors prototypes */
114+ fmat_t* read_to;
115+ uint_t read;
116+
117+
118+
119+
120+
121+
122+ /* creating output read_to as a new_fvec of length self->hop_size */
123+ read_to = new_fmat (self->channels, self->hop_size);
124+ read = 0;
125+
126+
127+ /* compute _do function */
128+ aubio_source_do_multi (self->o, read_to, &read);
129+
130+ PyObject *outputs = PyList_New(0);
131+ PyList_Append( outputs, (PyObject *)PyAubio_CFmatToArray (read_to));
132+ //del_fvec (read_to);
133+ PyList_Append( outputs, (PyObject *)PyInt_FromLong (read));
134+ return outputs;
135+}
136+
105137 AUBIO_MEMBERS_START(source)
106138 {"uri", T_STRING, offsetof (Py_source, uri), READONLY, ""},
107139 {"samplerate", T_INT, offsetof (Py_source, samplerate), READONLY, ""},
140+ {"channels", T_INT, offsetof (Py_source, channels), READONLY, ""},
108141 {"hop_size", T_INT, offsetof (Py_source, hop_size), READONLY, ""},
109142 AUBIO_MEMBERS_STOP(source)
110143
@@ -135,6 +168,8 @@ static PyMethodDef Py_source_methods[] = { · 24 unmodified lines
135168 METH_NOARGS, ""},
136169 {"get_channels", (PyCFunction) Pyaubio_source_get_channels,
137170 METH_NOARGS, ""},
171+ {"do_multi", (PyCFunction) Py_source_do_multi,
172+ METH_NOARGS, ""},
138173 {"close", (PyCFunction) Pyaubio_source_close,
139174 METH_NOARGS, ""},
140175 {NULL} /* sentinel */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t