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

Unified · Split

python/ext/py-source.c+37−2
@@ -6,6 +6,7 @@ typedef struct · 5 unmodified lines
6 aubio_source_t * o;6 aubio_source_t * o;
7 char_t* uri;7 char_t* uri;
8 uint_t samplerate;8 uint_t samplerate;
9 uint_t channels;
9 uint_t hop_size;10 uint_t hop_size;
10} Py_source;11} Py_source;
11 12
@@ -66,6 +67,7 @@ Py_source_init (Py_source * self, PyObject * args, PyObject * kwds) · 54 unmodified lines
66 return -1;67 return -1;
67 }68 }
68 self->samplerate = aubio_source_get_samplerate ( self->o );69 self->samplerate = aubio_source_get_samplerate ( self->o );
70 self->channels = aubio_source_get_channels ( self->o );
69 71
70 return 0;72 return 0;
71}73}
@@ -73,7 +75,7 @@ Py_source_init (Py_source * self, PyObject * args, PyObject * kwds) · 1 unmodified line
73AUBIO_DEL(source)75AUBIO_DEL(source)
74 76
75/* function Py_source_do */77/* function Py_source_do */
76static PyObject * 78static PyObject *
77Py_source_do(Py_source * self, PyObject * args)79Py_source_do(Py_source * self, PyObject * args)
78{80{
79 81
@@ -86,7 +88,7 @@ Py_source_do(Py_source * self, PyObject * args) · 6 unmodified lines
86 88
87 89
88 90
89 91
90 /* creating output read_to as a new_fvec of length self->hop_size */92 /* creating output read_to as a new_fvec of length self->hop_size */
91 read_to = new_fvec (self->hop_size);93 read_to = new_fvec (self->hop_size);
92 read = 0;94 read = 0;
@@ -102,9 +104,40 @@ Py_source_do(Py_source * self, PyObject * args) · 9 unmodified lines
102 return outputs;104 return outputs;
103}105}
104 106
107/* function Py_source_do_multi */
108static PyObject *
109Py_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
105AUBIO_MEMBERS_START(source)137AUBIO_MEMBERS_START(source)
106 {"uri", T_STRING, offsetof (Py_source, uri), READONLY, ""},138 {"uri", T_STRING, offsetof (Py_source, uri), READONLY, ""},
107 {"samplerate", T_INT, offsetof (Py_source, samplerate), READONLY, ""},139 {"samplerate", T_INT, offsetof (Py_source, samplerate), READONLY, ""},
140 {"channels", T_INT, offsetof (Py_source, channels), READONLY, ""},
108 {"hop_size", T_INT, offsetof (Py_source, hop_size), READONLY, ""},141 {"hop_size", T_INT, offsetof (Py_source, hop_size), READONLY, ""},
109AUBIO_MEMBERS_STOP(source)142AUBIO_MEMBERS_STOP(source)
110 143
@@ -135,6 +168,8 @@ static PyMethodDef Py_source_methods[] = { · 24 unmodified lines
135 METH_NOARGS, ""},168 METH_NOARGS, ""},
136 {"get_channels", (PyCFunction) Pyaubio_source_get_channels,169 {"get_channels", (PyCFunction) Pyaubio_source_get_channels,
137 METH_NOARGS, ""},170 METH_NOARGS, ""},
171 {"do_multi", (PyCFunction) Py_source_do_multi,
172 METH_NOARGS, ""},
138 {"close", (PyCFunction) Pyaubio_source_close,173 {"close", (PyCFunction) Pyaubio_source_close,
139 METH_NOARGS, ""},174 METH_NOARGS, ""},
140 {NULL} /* sentinel */175 {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