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