Showing the changes to python (6 of 6 files). Show all
Unified · Split
| @@ -1,89 +0,0 @@ | ||
| 1 | −#include "aubio-types.h" | |
| 2 | − | |
| 3 | −#define AUBIO_DECLARE(NAME, PARAMS...) \ | |
| 4 | −typedef struct { \ | |
| 5 | − PyObject_HEAD \ | |
| 6 | − aubio_ ## NAME ## _t * o; \ | |
| 7 | − PARAMS; \ | |
| 8 | −} Py_## NAME; | |
| 9 | − | |
| 10 | −#define AUBIO_INIT(NAME, PARAMS... ) \ | |
| 11 | −static int \ | |
| 12 | −Py_ ## NAME ## _init (Py_ ## NAME * self, PyObject * args, PyObject * kwds) \ | |
| 13 | −{ \ | |
| 14 | − self->o = new_aubio_## NAME ( PARAMS ); \ | |
| 15 | − if (self->o == NULL) { \ | |
| 16 | − PyErr_SetString (PyExc_RuntimeError, "error creating object"); \ | |
| 17 | − return -1; \ | |
| 18 | − } \ | |
| 19 | −\ | |
| 20 | − return 0; \ | |
| 21 | −} | |
| 22 | − | |
| 23 | −#define AUBIO_DEL(NAME) \ | |
| 24 | −static void \ | |
| 25 | −Py_ ## NAME ## _del ( Py_ ## NAME * self) \ | |
| 26 | −{ \ | |
| 27 | − del_aubio_ ## NAME (self->o); \ | |
| 28 | − Py_TYPE(self)->tp_free ((PyObject *) self); \ | |
| 29 | −} | |
| 30 | − | |
| 31 | −#define AUBIO_MEMBERS_START(NAME) \ | |
| 32 | −static PyMemberDef Py_ ## NAME ## _members[] = { | |
| 33 | − | |
| 34 | −#define AUBIO_MEMBERS_STOP(NAME) \ | |
| 35 | − {NULL} \ | |
| 36 | −}; | |
| 37 | − | |
| 38 | −#define AUBIO_METHODS(NAME) \ | |
| 39 | −static PyMethodDef Py_ ## NAME ## _methods[] = { \ | |
| 40 | − {NULL} \ | |
| 41 | −}; | |
| 42 | − | |
| 43 | − | |
| 44 | −#define AUBIO_TYPEOBJECT(NAME, PYNAME) \ | |
| 45 | −PyTypeObject Py_ ## NAME ## Type = { \ | |
| 46 | − PyVarObject_HEAD_INIT (NULL, 0) \ | |
| 47 | − PYNAME, \ | |
| 48 | − sizeof (Py_ ## NAME), \ | |
| 49 | − 0, \ | |
| 50 | − (destructor) Py_ ## NAME ## _del, \ | |
| 51 | − 0, \ | |
| 52 | − 0, \ | |
| 53 | − 0, \ | |
| 54 | − 0, \ | |
| 55 | − 0, \ | |
| 56 | − 0, \ | |
| 57 | − 0, \ | |
| 58 | − 0, \ | |
| 59 | − 0, \ | |
| 60 | − (ternaryfunc)Py_ ## NAME ## _do, \ | |
| 61 | − 0, \ | |
| 62 | − 0, \ | |
| 63 | − 0, \ | |
| 64 | − 0, \ | |
| 65 | − Py_TPFLAGS_DEFAULT, \ | |
| 66 | − Py_ ## NAME ## _doc, \ | |
| 67 | − 0, \ | |
| 68 | − 0, \ | |
| 69 | − 0, \ | |
| 70 | − 0, \ | |
| 71 | − 0, \ | |
| 72 | − 0, \ | |
| 73 | − Py_ ## NAME ## _methods, \ | |
| 74 | − Py_ ## NAME ## _members, \ | |
| 75 | − 0, \ | |
| 76 | − 0, \ | |
| 77 | − 0, \ | |
| 78 | − 0, \ | |
| 79 | − 0, \ | |
| 80 | − 0, \ | |
| 81 | − (initproc) Py_ ## NAME ## _init, \ | |
| 82 | − 0, \ | |
| 83 | − Py_ ## NAME ## _new, \ | |
| 84 | −}; | |
| 85 | − | |
| 86 | −// some more helpers | |
| 87 | −#define AUBIO_NEW_VEC(name, type, lengthval) \ | |
| 88 | − name = (type *) PyObject_New (type, & type ## Type); \ | |
| 89 | − name->length = lengthval; | |
| @@ -1,4 +1,4 @@ | ||
| 1 | −#include "aubiowraphell.h" | |
| 1 | +#include "aubio-types.h" | |
| 2 | 2 | |
| 3 | 3 | static char Py_fft_doc[] = "fft object"; |
| 4 | 4 | |
| @@ -11,7 +11,6 @@ typedef struct · 6 unmodified lines | ||
| 11 | 11 | fvec_t *rout; |
| 12 | 12 | } Py_fft; |
| 13 | 13 | |
| 14 | −//AUBIO_NEW(fft) | |
| 15 | 14 | static PyObject * |
| 16 | 15 | Py_fft_new (PyTypeObject * type, PyObject * args, PyObject * kwds) |
| 17 | 16 | { |
| @@ -89,10 +88,11 @@ Py_fft_do(Py_fft * self, PyObject * args) · 71 unmodified lines | ||
| 89 | 88 | return (PyObject *)PyAubio_CCvecToPyCvec(self->out); |
| 90 | 89 | } |
| 91 | 90 | |
| 92 | −AUBIO_MEMBERS_START(fft) | |
| 91 | +static PyMemberDef Py_fft_members[] = { | |
| 93 | 92 | {"win_s", T_INT, offsetof (Py_fft, win_s), READONLY, |
| 94 | 93 | "size of the window"}, |
| 95 | −AUBIO_MEMBERS_STOP(fft) | |
| 94 | + {NULL} | |
| 95 | +}; | |
| 96 | 96 | |
| 97 | 97 | static PyObject * |
| 98 | 98 | Py_fft_rdo(Py_fft * self, PyObject * args) |
| @@ -121,4 +121,43 @@ static PyMethodDef Py_fft_methods[] = { · 22 unmodified lines | ||
| 121 | 121 | {NULL} |
| 122 | 122 | }; |
| 123 | 123 | |
| 124 | −AUBIO_TYPEOBJECT(fft, "aubio.fft") | |
| 124 | +PyTypeObject Py_fftType = { | |
| 125 | + PyVarObject_HEAD_INIT (NULL, 0) | |
| 126 | + "aubio.fft", | |
| 127 | + sizeof (Py_fft), | |
| 128 | + 0, | |
| 129 | + (destructor) Py_fft_del, | |
| 130 | + 0, | |
| 131 | + 0, | |
| 132 | + 0, | |
| 133 | + 0, | |
| 134 | + 0, | |
| 135 | + 0, | |
| 136 | + 0, | |
| 137 | + 0, | |
| 138 | + 0, | |
| 139 | + (ternaryfunc)Py_fft_do, | |
| 140 | + 0, | |
| 141 | + 0, | |
| 142 | + 0, | |
| 143 | + 0, | |
| 144 | + Py_TPFLAGS_DEFAULT, | |
| 145 | + Py_fft_doc, | |
| 146 | + 0, | |
| 147 | + 0, | |
| 148 | + 0, | |
| 149 | + 0, | |
| 150 | + 0, | |
| 151 | + 0, | |
| 152 | + Py_fft_methods, | |
| 153 | + Py_fft_members, | |
| 154 | + 0, | |
| 155 | + 0, | |
| 156 | + 0, | |
| 157 | + 0, | |
| 158 | + 0, | |
| 159 | + 0, | |
| 160 | + (initproc) Py_fft_init, | |
| 161 | + 0, | |
| 162 | + Py_fft_new, | |
| 163 | +}; | |
| @@ -1,4 +1,4 @@ | ||
| 1 | −#include "aubiowraphell.h" | |
| 1 | +#include "aubio-types.h" | |
| 2 | 2 | |
| 3 | 3 | static char Py_filterbank_doc[] = "filterbank object"; |
| 4 | 4 | |
| @@ -11,7 +11,6 @@ typedef struct · 6 unmodified lines | ||
| 11 | 11 | fvec_t *out; |
| 12 | 12 | } Py_filterbank; |
| 13 | 13 | |
| 14 | −//AUBIO_NEW(filterbank) | |
| 15 | 14 | static PyObject * |
| 16 | 15 | Py_filterbank_new (PyTypeObject * type, PyObject * args, PyObject * kwds) |
| 17 | 16 | { |
| @@ -96,12 +95,13 @@ Py_filterbank_do(Py_filterbank * self, PyObject * args) · 78 unmodified lines | ||
| 96 | 95 | return (PyObject *)PyAubio_CFvecToArray(self->out); |
| 97 | 96 | } |
| 98 | 97 | |
| 99 | −AUBIO_MEMBERS_START(filterbank) | |
| 98 | +static PyMemberDef Py_filterbank_members[] = { | |
| 100 | 99 | {"win_s", T_INT, offsetof (Py_filterbank, win_s), READONLY, |
| 101 | 100 | "size of the window"}, |
| 102 | 101 | {"n_filters", T_INT, offsetof (Py_filterbank, n_filters), READONLY, |
| 103 | 102 | "number of filters"}, |
| 104 | −AUBIO_MEMBERS_STOP(filterbank) | |
| 103 | + {NULL} /* sentinel */ | |
| 104 | +}; | |
| 105 | 105 | |
| 106 | 106 | static PyObject * |
| 107 | 107 | Py_filterbank_set_triangle_bands (Py_filterbank * self, PyObject *args) |
| @@ -203,4 +203,43 @@ static PyMethodDef Py_filterbank_methods[] = { · 95 unmodified lines | ||
| 203 | 203 | {NULL} |
| 204 | 204 | }; |
| 205 | 205 | |
| 206 | −AUBIO_TYPEOBJECT(filterbank, "aubio.filterbank") | |
| 206 | +PyTypeObject Py_filterbankType = { | |
| 207 | + PyVarObject_HEAD_INIT (NULL, 0) | |
| 208 | + "aubio.filterbank", | |
| 209 | + sizeof (Py_filterbank), | |
| 210 | + 0, | |
| 211 | + (destructor) Py_filterbank_del, | |
| 212 | + 0, | |
| 213 | + 0, | |
| 214 | + 0, | |
| 215 | + 0, | |
| 216 | + 0, | |
| 217 | + 0, | |
| 218 | + 0, | |
| 219 | + 0, | |
| 220 | + 0, | |
| 221 | + (ternaryfunc)Py_filterbank_do, | |
| 222 | + 0, | |
| 223 | + 0, | |
| 224 | + 0, | |
| 225 | + 0, | |
| 226 | + Py_TPFLAGS_DEFAULT, | |
| 227 | + Py_filterbank_doc, | |
| 228 | + 0, | |
| 229 | + 0, | |
| 230 | + 0, | |
| 231 | + 0, | |
| 232 | + 0, | |
| 233 | + 0, | |
| 234 | + Py_filterbank_methods, | |
| 235 | + Py_filterbank_members, | |
| 236 | + 0, | |
| 237 | + 0, | |
| 238 | + 0, | |
| 239 | + 0, | |
| 240 | + 0, | |
| 241 | + 0, | |
| 242 | + (initproc) Py_filterbank_init, | |
| 243 | + 0, | |
| 244 | + Py_filterbank_new, | |
| 245 | +}; | |
| @@ -1,4 +1,4 @@ | ||
| 1 | −#include "aubiowraphell.h" | |
| 1 | +#include "aubio-types.h" | |
| 2 | 2 | |
| 3 | 3 | static char Py_pvoc_doc[] = "pvoc object"; |
| 4 | 4 | |
| @@ -13,7 +13,6 @@ typedef struct · 8 unmodified lines | ||
| 13 | 13 | } Py_pvoc; |
| 14 | 14 | |
| 15 | 15 | |
| 16 | −//AUBIO_NEW(pvoc) | |
| 17 | 16 | static PyObject * |
| 18 | 17 | Py_pvoc_new (PyTypeObject * type, PyObject * args, PyObject * kwds) |
| 19 | 18 | { |
| @@ -55,15 +54,27 @@ Py_pvoc_new (PyTypeObject * type, PyObject * args, PyObject * kwds) · 35 unmodified lines | ||
| 55 | 54 | return NULL; |
| 56 | 55 | } |
| 57 | 56 | |
| 57 | + return (PyObject *) self; | |
| 58 | +} | |
| 59 | + | |
| 60 | +static int | |
| 61 | +Py_pvoc_init (Py_pvoc * self, PyObject * args, PyObject * kwds) | |
| 62 | +{ | |
| 63 | + self->o = new_aubio_pvoc ( self->win_s, self->hop_s); | |
| 64 | + if (self->o == NULL) { | |
| 65 | + char_t errstr[30]; | |
| 66 | + sprintf(errstr, "error creating pvoc with %d, %d", self->win_s, self->hop_s); | |
| 67 | + PyErr_SetString (PyExc_RuntimeError, errstr); | |
| 68 | + return -1; | |
| 69 | + } | |
| 70 | + | |
| 58 | 71 | self->output = new_cvec(self->win_s); |
| 59 | 72 | self->routput = new_fvec(self->hop_s); |
| 60 | 73 | |
| 61 | − return (PyObject *) self; | |
| 74 | + return 0; | |
| 62 | 75 | } |
| 63 | 76 | |
| 64 | 77 | |
| 65 | −AUBIO_INIT(pvoc, self->win_s, self->hop_s) | |
| 66 | − | |
| 67 | 78 | static void |
| 68 | 79 | Py_pvoc_del (Py_pvoc *self, PyObject *unused) |
| 69 | 80 | { |
| @@ -95,12 +106,13 @@ Py_pvoc_do(Py_pvoc * self, PyObject * args) · 25 unmodified lines | ||
| 95 | 106 | return (PyObject *)PyAubio_CCvecToPyCvec(self->output); |
| 96 | 107 | } |
| 97 | 108 | |
| 98 | −AUBIO_MEMBERS_START(pvoc) | |
| 109 | +static PyMemberDef Py_pvoc_members[] = { | |
| 99 | 110 | {"win_s", T_INT, offsetof (Py_pvoc, win_s), READONLY, |
| 100 | 111 | "size of the window"}, |
| 101 | 112 | {"hop_s", T_INT, offsetof (Py_pvoc, hop_s), READONLY, |
| 102 | 113 | "size of the hop"}, |
| 103 | −AUBIO_MEMBERS_STOP(pvoc) | |
| 114 | + { NULL } // sentinel | |
| 115 | +}; | |
| 104 | 116 | |
| 105 | 117 | static PyObject * |
| 106 | 118 | Py_pvoc_rdo(Py_pvoc * self, PyObject * args) |
| @@ -128,4 +140,43 @@ static PyMethodDef Py_pvoc_methods[] = { · 21 unmodified lines | ||
| 128 | 140 | {NULL} |
| 129 | 141 | }; |
| 130 | 142 | |
| 131 | −AUBIO_TYPEOBJECT(pvoc, "aubio.pvoc") | |
| 143 | +PyTypeObject Py_pvocType = { | |
| 144 | + PyVarObject_HEAD_INIT (NULL, 0) | |
| 145 | + "aubio.pvoc", | |
| 146 | + sizeof (Py_pvoc), | |
| 147 | + 0, | |
| 148 | + (destructor) Py_pvoc_del, | |
| 149 | + 0, | |
| 150 | + 0, | |
| 151 | + 0, | |
| 152 | + 0, | |
| 153 | + 0, | |
| 154 | + 0, | |
| 155 | + 0, | |
| 156 | + 0, | |
| 157 | + 0, | |
| 158 | + (ternaryfunc)Py_pvoc_do, | |
| 159 | + 0, | |
| 160 | + 0, | |
| 161 | + 0, | |
| 162 | + 0, | |
| 163 | + Py_TPFLAGS_DEFAULT, | |
| 164 | + Py_pvoc_doc, | |
| 165 | + 0, | |
| 166 | + 0, | |
| 167 | + 0, | |
| 168 | + 0, | |
| 169 | + 0, | |
| 170 | + 0, | |
| 171 | + Py_pvoc_methods, | |
| 172 | + Py_pvoc_members, | |
| 173 | + 0, | |
| 174 | + 0, | |
| 175 | + 0, | |
| 176 | + 0, | |
| 177 | + 0, | |
| 178 | + 0, | |
| 179 | + (initproc) Py_pvoc_init, | |
| 180 | + 0, | |
| 181 | + Py_pvoc_new, | |
| 182 | +}; | |
| @@ -1,4 +1,4 @@ | ||
| 1 | −#include "aubiowraphell.h" | |
| 1 | +#include "aubio-types.h" | |
| 2 | 2 | |
| 3 | 3 | typedef struct |
| 4 | 4 | { |
| @@ -124,7 +124,12 @@ Py_sink_init (Py_sink * self, PyObject * args, PyObject * kwds) · 119 unmodified lines | ||
| 124 | 124 | return 0; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | −AUBIO_DEL(sink) | |
| 127 | +static void | |
| 128 | +Py_sink_del (Py_sink *self, PyObject *unused) | |
| 129 | +{ | |
| 130 | + del_aubio_sink(self->o); | |
| 131 | + Py_TYPE(self)->tp_free((PyObject *) self); | |
| 132 | +} | |
| 128 | 133 | |
| 129 | 134 | /* function Py_sink_do */ |
| 130 | 135 | static PyObject * |
| @@ -193,14 +198,15 @@ Py_sink_do_multi(Py_sink * self, PyObject * args) · 62 unmodified lines | ||
| 193 | 198 | Py_RETURN_NONE; |
| 194 | 199 | } |
| 195 | 200 | |
| 196 | −AUBIO_MEMBERS_START(sink) | |
| 201 | +static PyMemberDef Py_sink_members[] = { | |
| 197 | 202 | {"uri", T_STRING, offsetof (Py_sink, uri), READONLY, |
| 198 | 203 | "path at which the sink was created"}, |
| 199 | 204 | {"samplerate", T_INT, offsetof (Py_sink, samplerate), READONLY, |
| 200 | 205 | "samplerate at which the sink was created"}, |
| 201 | 206 | {"channels", T_INT, offsetof (Py_sink, channels), READONLY, |
| 202 | 207 | "number of channels with which the sink was created"}, |
| 203 | −AUBIO_MEMBERS_STOP(sink) | |
| 208 | + { NULL } // sentinel | |
| 209 | +}; | |
| 204 | 210 | |
| 205 | 211 | static PyObject * |
| 206 | 212 | Pyaubio_sink_close (Py_sink *self, PyObject *unused) |
| @@ -216,4 +222,43 @@ static PyMethodDef Py_sink_methods[] = { · 9 unmodified lines | ||
| 216 | 222 | {NULL} /* sentinel */ |
| 217 | 223 | }; |
| 218 | 224 | |
| 219 | −AUBIO_TYPEOBJECT(sink, "aubio.sink") | |
| 225 | +PyTypeObject Py_sinkType = { | |
| 226 | + PyVarObject_HEAD_INIT (NULL, 0) | |
| 227 | + "aubio.sink", | |
| 228 | + sizeof (Py_sink), | |
| 229 | + 0, | |
| 230 | + (destructor) Py_sink_del, | |
| 231 | + 0, | |
| 232 | + 0, | |
| 233 | + 0, | |
| 234 | + 0, | |
| 235 | + 0, | |
| 236 | + 0, | |
| 237 | + 0, | |
| 238 | + 0, | |
| 239 | + 0, | |
| 240 | + (ternaryfunc)Py_sink_do, | |
| 241 | + 0, | |
| 242 | + 0, | |
| 243 | + 0, | |
| 244 | + 0, | |
| 245 | + Py_TPFLAGS_DEFAULT, | |
| 246 | + Py_sink_doc, | |
| 247 | + 0, | |
| 248 | + 0, | |
| 249 | + 0, | |
| 250 | + 0, | |
| 251 | + 0, | |
| 252 | + 0, | |
| 253 | + Py_sink_methods, | |
| 254 | + Py_sink_members, | |
| 255 | + 0, | |
| 256 | + 0, | |
| 257 | + 0, | |
| 258 | + 0, | |
| 259 | + 0, | |
| 260 | + 0, | |
| 261 | + (initproc) Py_sink_init, | |
| 262 | + 0, | |
| 263 | + Py_sink_new, | |
| 264 | +}; | |
| @@ -1,4 +1,4 @@ | ||
| 1 | −#include "aubiowraphell.h" | |
| 1 | +#include "aubio-types.h" | |
| 2 | 2 | |
| 3 | 3 | typedef struct |
| 4 | 4 | { |
| @@ -217,7 +217,7 @@ Py_source_do_multi(Py_source * self, PyObject * args) · 212 unmodified lines | ||
| 217 | 217 | return outputs; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | −AUBIO_MEMBERS_START(source) | |
| 220 | +static PyMemberDef Py_source_members[] = { | |
| 221 | 221 | {"uri", T_STRING, offsetof (Py_source, uri), READONLY, |
| 222 | 222 | "path at which the source was created"}, |
| 223 | 223 | {"samplerate", T_INT, offsetof (Py_source, samplerate), READONLY, |
| @@ -226,8 +226,8 @@ AUBIO_MEMBERS_START(source) · 2 unmodified lines | ||
| 226 | 226 | "number of channels found in the source"}, |
| 227 | 227 | {"hop_size", T_INT, offsetof (Py_source, hop_size), READONLY, |
| 228 | 228 | "number of consecutive frames that will be read at each do or do_multi call"}, |
| 229 | −AUBIO_MEMBERS_STOP(source) | |
| 230 | − | |
| 229 | + { NULL } // sentinel | |
| 230 | +}; | |
| 231 | 231 | |
| 232 | 232 | static PyObject * |
| 233 | 233 | Pyaubio_source_get_samplerate (Py_source *self, PyObject *unused) |
| @@ -285,4 +285,43 @@ static PyMethodDef Py_source_methods[] = { · 51 unmodified lines | ||
| 285 | 285 | {NULL} /* sentinel */ |
| 286 | 286 | }; |
| 287 | 287 | |
| 288 | −AUBIO_TYPEOBJECT(source, "aubio.source") | |
| 288 | +PyTypeObject Py_sourceType = { | |
| 289 | + PyVarObject_HEAD_INIT (NULL, 0) | |
| 290 | + "aubio.source", | |
| 291 | + sizeof (Py_source), | |
| 292 | + 0, | |
| 293 | + (destructor) Py_source_del, | |
| 294 | + 0, | |
| 295 | + 0, | |
| 296 | + 0, | |
| 297 | + 0, | |
| 298 | + 0, | |
| 299 | + 0, | |
| 300 | + 0, | |
| 301 | + 0, | |
| 302 | + 0, | |
| 303 | + (ternaryfunc)Py_source_do, | |
| 304 | + 0, | |
| 305 | + 0, | |
| 306 | + 0, | |
| 307 | + 0, | |
| 308 | + Py_TPFLAGS_DEFAULT, | |
| 309 | + Py_source_doc, | |
| 310 | + 0, | |
| 311 | + 0, | |
| 312 | + 0, | |
| 313 | + 0, | |
| 314 | + 0, | |
| 315 | + 0, | |
| 316 | + Py_source_methods, | |
| 317 | + Py_source_members, | |
| 318 | + 0, | |
| 319 | + 0, | |
| 320 | + 0, | |
| 321 | + 0, | |
| 322 | + 0, | |
| 323 | + 0, | |
| 324 | + (initproc) Py_source_init, | |
| 325 | + 0, | |
| 326 | + Py_source_new, | |
| 327 | +}; | |