Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_STRVAR(audioop_getsample__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 6 | "getsample($module, fragment, width, index, /)\n" |
| 7 | "--\n" |
| 8 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 9 | "Return the value of sample index from the fragment."); |
| 10 | |
| 11 | #define AUDIOOP_GETSAMPLE_METHODDEF \ |
| 12 | {"getsample", (PyCFunction)audioop_getsample, METH_VARARGS, audioop_getsample__doc__}, |
| 13 | |
| 14 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 15 | audioop_getsample_impl(PyModuleDef *module, Py_buffer *fragment, int width, |
| 16 | Py_ssize_t index); |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 17 | |
| 18 | static PyObject * |
| 19 | audioop_getsample(PyModuleDef *module, PyObject *args) |
| 20 | { |
| 21 | PyObject *return_value = NULL; |
| 22 | Py_buffer fragment = {NULL, NULL}; |
| 23 | int width; |
| 24 | Py_ssize_t index; |
| 25 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 26 | if (!PyArg_ParseTuple(args, "y*in:getsample", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 27 | &fragment, &width, &index)) |
| 28 | goto exit; |
| 29 | return_value = audioop_getsample_impl(module, &fragment, width, index); |
| 30 | |
| 31 | exit: |
| 32 | /* Cleanup for fragment */ |
| 33 | if (fragment.obj) |
| 34 | PyBuffer_Release(&fragment); |
| 35 | |
| 36 | return return_value; |
| 37 | } |
| 38 | |
| 39 | PyDoc_STRVAR(audioop_max__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 40 | "max($module, fragment, width, /)\n" |
| 41 | "--\n" |
| 42 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 43 | "Return the maximum of the absolute value of all samples in a fragment."); |
| 44 | |
| 45 | #define AUDIOOP_MAX_METHODDEF \ |
| 46 | {"max", (PyCFunction)audioop_max, METH_VARARGS, audioop_max__doc__}, |
| 47 | |
| 48 | static PyObject * |
| 49 | audioop_max_impl(PyModuleDef *module, Py_buffer *fragment, int width); |
| 50 | |
| 51 | static PyObject * |
| 52 | audioop_max(PyModuleDef *module, PyObject *args) |
| 53 | { |
| 54 | PyObject *return_value = NULL; |
| 55 | Py_buffer fragment = {NULL, NULL}; |
| 56 | int width; |
| 57 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 58 | if (!PyArg_ParseTuple(args, "y*i:max", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 59 | &fragment, &width)) |
| 60 | goto exit; |
| 61 | return_value = audioop_max_impl(module, &fragment, width); |
| 62 | |
| 63 | exit: |
| 64 | /* Cleanup for fragment */ |
| 65 | if (fragment.obj) |
| 66 | PyBuffer_Release(&fragment); |
| 67 | |
| 68 | return return_value; |
| 69 | } |
| 70 | |
| 71 | PyDoc_STRVAR(audioop_minmax__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 72 | "minmax($module, fragment, width, /)\n" |
| 73 | "--\n" |
| 74 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 75 | "Return the minimum and maximum values of all samples in the sound fragment."); |
| 76 | |
| 77 | #define AUDIOOP_MINMAX_METHODDEF \ |
| 78 | {"minmax", (PyCFunction)audioop_minmax, METH_VARARGS, audioop_minmax__doc__}, |
| 79 | |
| 80 | static PyObject * |
| 81 | audioop_minmax_impl(PyModuleDef *module, Py_buffer *fragment, int width); |
| 82 | |
| 83 | static PyObject * |
| 84 | audioop_minmax(PyModuleDef *module, PyObject *args) |
| 85 | { |
| 86 | PyObject *return_value = NULL; |
| 87 | Py_buffer fragment = {NULL, NULL}; |
| 88 | int width; |
| 89 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 90 | if (!PyArg_ParseTuple(args, "y*i:minmax", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 91 | &fragment, &width)) |
| 92 | goto exit; |
| 93 | return_value = audioop_minmax_impl(module, &fragment, width); |
| 94 | |
| 95 | exit: |
| 96 | /* Cleanup for fragment */ |
| 97 | if (fragment.obj) |
| 98 | PyBuffer_Release(&fragment); |
| 99 | |
| 100 | return return_value; |
| 101 | } |
| 102 | |
| 103 | PyDoc_STRVAR(audioop_avg__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 104 | "avg($module, fragment, width, /)\n" |
| 105 | "--\n" |
| 106 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 107 | "Return the average over all samples in the fragment."); |
| 108 | |
| 109 | #define AUDIOOP_AVG_METHODDEF \ |
| 110 | {"avg", (PyCFunction)audioop_avg, METH_VARARGS, audioop_avg__doc__}, |
| 111 | |
| 112 | static PyObject * |
| 113 | audioop_avg_impl(PyModuleDef *module, Py_buffer *fragment, int width); |
| 114 | |
| 115 | static PyObject * |
| 116 | audioop_avg(PyModuleDef *module, PyObject *args) |
| 117 | { |
| 118 | PyObject *return_value = NULL; |
| 119 | Py_buffer fragment = {NULL, NULL}; |
| 120 | int width; |
| 121 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 122 | if (!PyArg_ParseTuple(args, "y*i:avg", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 123 | &fragment, &width)) |
| 124 | goto exit; |
| 125 | return_value = audioop_avg_impl(module, &fragment, width); |
| 126 | |
| 127 | exit: |
| 128 | /* Cleanup for fragment */ |
| 129 | if (fragment.obj) |
| 130 | PyBuffer_Release(&fragment); |
| 131 | |
| 132 | return return_value; |
| 133 | } |
| 134 | |
| 135 | PyDoc_STRVAR(audioop_rms__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 136 | "rms($module, fragment, width, /)\n" |
| 137 | "--\n" |
| 138 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 139 | "Return the root-mean-square of the fragment, i.e. sqrt(sum(S_i^2)/n)."); |
| 140 | |
| 141 | #define AUDIOOP_RMS_METHODDEF \ |
| 142 | {"rms", (PyCFunction)audioop_rms, METH_VARARGS, audioop_rms__doc__}, |
| 143 | |
| 144 | static PyObject * |
| 145 | audioop_rms_impl(PyModuleDef *module, Py_buffer *fragment, int width); |
| 146 | |
| 147 | static PyObject * |
| 148 | audioop_rms(PyModuleDef *module, PyObject *args) |
| 149 | { |
| 150 | PyObject *return_value = NULL; |
| 151 | Py_buffer fragment = {NULL, NULL}; |
| 152 | int width; |
| 153 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 154 | if (!PyArg_ParseTuple(args, "y*i:rms", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 155 | &fragment, &width)) |
| 156 | goto exit; |
| 157 | return_value = audioop_rms_impl(module, &fragment, width); |
| 158 | |
| 159 | exit: |
| 160 | /* Cleanup for fragment */ |
| 161 | if (fragment.obj) |
| 162 | PyBuffer_Release(&fragment); |
| 163 | |
| 164 | return return_value; |
| 165 | } |
| 166 | |
| 167 | PyDoc_STRVAR(audioop_findfit__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 168 | "findfit($module, fragment, reference, /)\n" |
| 169 | "--\n" |
| 170 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 171 | "Try to match reference as well as possible to a portion of fragment."); |
| 172 | |
| 173 | #define AUDIOOP_FINDFIT_METHODDEF \ |
| 174 | {"findfit", (PyCFunction)audioop_findfit, METH_VARARGS, audioop_findfit__doc__}, |
| 175 | |
| 176 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 177 | audioop_findfit_impl(PyModuleDef *module, Py_buffer *fragment, |
| 178 | Py_buffer *reference); |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 179 | |
| 180 | static PyObject * |
| 181 | audioop_findfit(PyModuleDef *module, PyObject *args) |
| 182 | { |
| 183 | PyObject *return_value = NULL; |
| 184 | Py_buffer fragment = {NULL, NULL}; |
| 185 | Py_buffer reference = {NULL, NULL}; |
| 186 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 187 | if (!PyArg_ParseTuple(args, "y*y*:findfit", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 188 | &fragment, &reference)) |
| 189 | goto exit; |
| 190 | return_value = audioop_findfit_impl(module, &fragment, &reference); |
| 191 | |
| 192 | exit: |
| 193 | /* Cleanup for fragment */ |
| 194 | if (fragment.obj) |
| 195 | PyBuffer_Release(&fragment); |
| 196 | /* Cleanup for reference */ |
| 197 | if (reference.obj) |
| 198 | PyBuffer_Release(&reference); |
| 199 | |
| 200 | return return_value; |
| 201 | } |
| 202 | |
| 203 | PyDoc_STRVAR(audioop_findfactor__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 204 | "findfactor($module, fragment, reference, /)\n" |
| 205 | "--\n" |
| 206 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 207 | "Return a factor F such that rms(add(fragment, mul(reference, -F))) is minimal."); |
| 208 | |
| 209 | #define AUDIOOP_FINDFACTOR_METHODDEF \ |
| 210 | {"findfactor", (PyCFunction)audioop_findfactor, METH_VARARGS, audioop_findfactor__doc__}, |
| 211 | |
| 212 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 213 | audioop_findfactor_impl(PyModuleDef *module, Py_buffer *fragment, |
| 214 | Py_buffer *reference); |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 215 | |
| 216 | static PyObject * |
| 217 | audioop_findfactor(PyModuleDef *module, PyObject *args) |
| 218 | { |
| 219 | PyObject *return_value = NULL; |
| 220 | Py_buffer fragment = {NULL, NULL}; |
| 221 | Py_buffer reference = {NULL, NULL}; |
| 222 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 223 | if (!PyArg_ParseTuple(args, "y*y*:findfactor", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 224 | &fragment, &reference)) |
| 225 | goto exit; |
| 226 | return_value = audioop_findfactor_impl(module, &fragment, &reference); |
| 227 | |
| 228 | exit: |
| 229 | /* Cleanup for fragment */ |
| 230 | if (fragment.obj) |
| 231 | PyBuffer_Release(&fragment); |
| 232 | /* Cleanup for reference */ |
| 233 | if (reference.obj) |
| 234 | PyBuffer_Release(&reference); |
| 235 | |
| 236 | return return_value; |
| 237 | } |
| 238 | |
| 239 | PyDoc_STRVAR(audioop_findmax__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 240 | "findmax($module, fragment, length, /)\n" |
| 241 | "--\n" |
| 242 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 243 | "Search fragment for a slice of specified number of samples with maximum energy."); |
| 244 | |
| 245 | #define AUDIOOP_FINDMAX_METHODDEF \ |
| 246 | {"findmax", (PyCFunction)audioop_findmax, METH_VARARGS, audioop_findmax__doc__}, |
| 247 | |
| 248 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 249 | audioop_findmax_impl(PyModuleDef *module, Py_buffer *fragment, |
| 250 | Py_ssize_t length); |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 251 | |
| 252 | static PyObject * |
| 253 | audioop_findmax(PyModuleDef *module, PyObject *args) |
| 254 | { |
| 255 | PyObject *return_value = NULL; |
| 256 | Py_buffer fragment = {NULL, NULL}; |
| 257 | Py_ssize_t length; |
| 258 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 259 | if (!PyArg_ParseTuple(args, "y*n:findmax", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 260 | &fragment, &length)) |
| 261 | goto exit; |
| 262 | return_value = audioop_findmax_impl(module, &fragment, length); |
| 263 | |
| 264 | exit: |
| 265 | /* Cleanup for fragment */ |
| 266 | if (fragment.obj) |
| 267 | PyBuffer_Release(&fragment); |
| 268 | |
| 269 | return return_value; |
| 270 | } |
| 271 | |
| 272 | PyDoc_STRVAR(audioop_avgpp__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 273 | "avgpp($module, fragment, width, /)\n" |
| 274 | "--\n" |
| 275 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 276 | "Return the average peak-peak value over all samples in the fragment."); |
| 277 | |
| 278 | #define AUDIOOP_AVGPP_METHODDEF \ |
| 279 | {"avgpp", (PyCFunction)audioop_avgpp, METH_VARARGS, audioop_avgpp__doc__}, |
| 280 | |
| 281 | static PyObject * |
| 282 | audioop_avgpp_impl(PyModuleDef *module, Py_buffer *fragment, int width); |
| 283 | |
| 284 | static PyObject * |
| 285 | audioop_avgpp(PyModuleDef *module, PyObject *args) |
| 286 | { |
| 287 | PyObject *return_value = NULL; |
| 288 | Py_buffer fragment = {NULL, NULL}; |
| 289 | int width; |
| 290 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 291 | if (!PyArg_ParseTuple(args, "y*i:avgpp", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 292 | &fragment, &width)) |
| 293 | goto exit; |
| 294 | return_value = audioop_avgpp_impl(module, &fragment, width); |
| 295 | |
| 296 | exit: |
| 297 | /* Cleanup for fragment */ |
| 298 | if (fragment.obj) |
| 299 | PyBuffer_Release(&fragment); |
| 300 | |
| 301 | return return_value; |
| 302 | } |
| 303 | |
| 304 | PyDoc_STRVAR(audioop_maxpp__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 305 | "maxpp($module, fragment, width, /)\n" |
| 306 | "--\n" |
| 307 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 308 | "Return the maximum peak-peak value in the sound fragment."); |
| 309 | |
| 310 | #define AUDIOOP_MAXPP_METHODDEF \ |
| 311 | {"maxpp", (PyCFunction)audioop_maxpp, METH_VARARGS, audioop_maxpp__doc__}, |
| 312 | |
| 313 | static PyObject * |
| 314 | audioop_maxpp_impl(PyModuleDef *module, Py_buffer *fragment, int width); |
| 315 | |
| 316 | static PyObject * |
| 317 | audioop_maxpp(PyModuleDef *module, PyObject *args) |
| 318 | { |
| 319 | PyObject *return_value = NULL; |
| 320 | Py_buffer fragment = {NULL, NULL}; |
| 321 | int width; |
| 322 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 323 | if (!PyArg_ParseTuple(args, "y*i:maxpp", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 324 | &fragment, &width)) |
| 325 | goto exit; |
| 326 | return_value = audioop_maxpp_impl(module, &fragment, width); |
| 327 | |
| 328 | exit: |
| 329 | /* Cleanup for fragment */ |
| 330 | if (fragment.obj) |
| 331 | PyBuffer_Release(&fragment); |
| 332 | |
| 333 | return return_value; |
| 334 | } |
| 335 | |
| 336 | PyDoc_STRVAR(audioop_cross__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 337 | "cross($module, fragment, width, /)\n" |
| 338 | "--\n" |
| 339 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 340 | "Return the number of zero crossings in the fragment passed as an argument."); |
| 341 | |
| 342 | #define AUDIOOP_CROSS_METHODDEF \ |
| 343 | {"cross", (PyCFunction)audioop_cross, METH_VARARGS, audioop_cross__doc__}, |
| 344 | |
| 345 | static PyObject * |
| 346 | audioop_cross_impl(PyModuleDef *module, Py_buffer *fragment, int width); |
| 347 | |
| 348 | static PyObject * |
| 349 | audioop_cross(PyModuleDef *module, PyObject *args) |
| 350 | { |
| 351 | PyObject *return_value = NULL; |
| 352 | Py_buffer fragment = {NULL, NULL}; |
| 353 | int width; |
| 354 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 355 | if (!PyArg_ParseTuple(args, "y*i:cross", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 356 | &fragment, &width)) |
| 357 | goto exit; |
| 358 | return_value = audioop_cross_impl(module, &fragment, width); |
| 359 | |
| 360 | exit: |
| 361 | /* Cleanup for fragment */ |
| 362 | if (fragment.obj) |
| 363 | PyBuffer_Release(&fragment); |
| 364 | |
| 365 | return return_value; |
| 366 | } |
| 367 | |
| 368 | PyDoc_STRVAR(audioop_mul__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 369 | "mul($module, fragment, width, factor, /)\n" |
| 370 | "--\n" |
| 371 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 372 | "Return a fragment that has all samples in the original fragment multiplied by the floating-point value factor."); |
| 373 | |
| 374 | #define AUDIOOP_MUL_METHODDEF \ |
| 375 | {"mul", (PyCFunction)audioop_mul, METH_VARARGS, audioop_mul__doc__}, |
| 376 | |
| 377 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 378 | audioop_mul_impl(PyModuleDef *module, Py_buffer *fragment, int width, |
| 379 | double factor); |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 380 | |
| 381 | static PyObject * |
| 382 | audioop_mul(PyModuleDef *module, PyObject *args) |
| 383 | { |
| 384 | PyObject *return_value = NULL; |
| 385 | Py_buffer fragment = {NULL, NULL}; |
| 386 | int width; |
| 387 | double factor; |
| 388 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 389 | if (!PyArg_ParseTuple(args, "y*id:mul", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 390 | &fragment, &width, &factor)) |
| 391 | goto exit; |
| 392 | return_value = audioop_mul_impl(module, &fragment, width, factor); |
| 393 | |
| 394 | exit: |
| 395 | /* Cleanup for fragment */ |
| 396 | if (fragment.obj) |
| 397 | PyBuffer_Release(&fragment); |
| 398 | |
| 399 | return return_value; |
| 400 | } |
| 401 | |
| 402 | PyDoc_STRVAR(audioop_tomono__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 403 | "tomono($module, fragment, width, lfactor, rfactor, /)\n" |
| 404 | "--\n" |
| 405 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 406 | "Convert a stereo fragment to a mono fragment."); |
| 407 | |
| 408 | #define AUDIOOP_TOMONO_METHODDEF \ |
| 409 | {"tomono", (PyCFunction)audioop_tomono, METH_VARARGS, audioop_tomono__doc__}, |
| 410 | |
| 411 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 412 | audioop_tomono_impl(PyModuleDef *module, Py_buffer *fragment, int width, |
| 413 | double lfactor, double rfactor); |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 414 | |
| 415 | static PyObject * |
| 416 | audioop_tomono(PyModuleDef *module, PyObject *args) |
| 417 | { |
| 418 | PyObject *return_value = NULL; |
| 419 | Py_buffer fragment = {NULL, NULL}; |
| 420 | int width; |
| 421 | double lfactor; |
| 422 | double rfactor; |
| 423 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 424 | if (!PyArg_ParseTuple(args, "y*idd:tomono", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 425 | &fragment, &width, &lfactor, &rfactor)) |
| 426 | goto exit; |
| 427 | return_value = audioop_tomono_impl(module, &fragment, width, lfactor, rfactor); |
| 428 | |
| 429 | exit: |
| 430 | /* Cleanup for fragment */ |
| 431 | if (fragment.obj) |
| 432 | PyBuffer_Release(&fragment); |
| 433 | |
| 434 | return return_value; |
| 435 | } |
| 436 | |
| 437 | PyDoc_STRVAR(audioop_tostereo__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 438 | "tostereo($module, fragment, width, lfactor, rfactor, /)\n" |
| 439 | "--\n" |
| 440 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 441 | "Generate a stereo fragment from a mono fragment."); |
| 442 | |
| 443 | #define AUDIOOP_TOSTEREO_METHODDEF \ |
| 444 | {"tostereo", (PyCFunction)audioop_tostereo, METH_VARARGS, audioop_tostereo__doc__}, |
| 445 | |
| 446 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 447 | audioop_tostereo_impl(PyModuleDef *module, Py_buffer *fragment, int width, |
| 448 | double lfactor, double rfactor); |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 449 | |
| 450 | static PyObject * |
| 451 | audioop_tostereo(PyModuleDef *module, PyObject *args) |
| 452 | { |
| 453 | PyObject *return_value = NULL; |
| 454 | Py_buffer fragment = {NULL, NULL}; |
| 455 | int width; |
| 456 | double lfactor; |
| 457 | double rfactor; |
| 458 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 459 | if (!PyArg_ParseTuple(args, "y*idd:tostereo", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 460 | &fragment, &width, &lfactor, &rfactor)) |
| 461 | goto exit; |
| 462 | return_value = audioop_tostereo_impl(module, &fragment, width, lfactor, rfactor); |
| 463 | |
| 464 | exit: |
| 465 | /* Cleanup for fragment */ |
| 466 | if (fragment.obj) |
| 467 | PyBuffer_Release(&fragment); |
| 468 | |
| 469 | return return_value; |
| 470 | } |
| 471 | |
| 472 | PyDoc_STRVAR(audioop_add__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 473 | "add($module, fragment1, fragment2, width, /)\n" |
| 474 | "--\n" |
| 475 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 476 | "Return a fragment which is the addition of the two samples passed as parameters."); |
| 477 | |
| 478 | #define AUDIOOP_ADD_METHODDEF \ |
| 479 | {"add", (PyCFunction)audioop_add, METH_VARARGS, audioop_add__doc__}, |
| 480 | |
| 481 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 482 | audioop_add_impl(PyModuleDef *module, Py_buffer *fragment1, |
| 483 | Py_buffer *fragment2, int width); |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 484 | |
| 485 | static PyObject * |
| 486 | audioop_add(PyModuleDef *module, PyObject *args) |
| 487 | { |
| 488 | PyObject *return_value = NULL; |
| 489 | Py_buffer fragment1 = {NULL, NULL}; |
| 490 | Py_buffer fragment2 = {NULL, NULL}; |
| 491 | int width; |
| 492 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 493 | if (!PyArg_ParseTuple(args, "y*y*i:add", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 494 | &fragment1, &fragment2, &width)) |
| 495 | goto exit; |
| 496 | return_value = audioop_add_impl(module, &fragment1, &fragment2, width); |
| 497 | |
| 498 | exit: |
| 499 | /* Cleanup for fragment1 */ |
| 500 | if (fragment1.obj) |
| 501 | PyBuffer_Release(&fragment1); |
| 502 | /* Cleanup for fragment2 */ |
| 503 | if (fragment2.obj) |
| 504 | PyBuffer_Release(&fragment2); |
| 505 | |
| 506 | return return_value; |
| 507 | } |
| 508 | |
| 509 | PyDoc_STRVAR(audioop_bias__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 510 | "bias($module, fragment, width, bias, /)\n" |
| 511 | "--\n" |
| 512 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 513 | "Return a fragment that is the original fragment with a bias added to each sample."); |
| 514 | |
| 515 | #define AUDIOOP_BIAS_METHODDEF \ |
| 516 | {"bias", (PyCFunction)audioop_bias, METH_VARARGS, audioop_bias__doc__}, |
| 517 | |
| 518 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 519 | audioop_bias_impl(PyModuleDef *module, Py_buffer *fragment, int width, |
| 520 | int bias); |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 521 | |
| 522 | static PyObject * |
| 523 | audioop_bias(PyModuleDef *module, PyObject *args) |
| 524 | { |
| 525 | PyObject *return_value = NULL; |
| 526 | Py_buffer fragment = {NULL, NULL}; |
| 527 | int width; |
| 528 | int bias; |
| 529 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 530 | if (!PyArg_ParseTuple(args, "y*ii:bias", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 531 | &fragment, &width, &bias)) |
| 532 | goto exit; |
| 533 | return_value = audioop_bias_impl(module, &fragment, width, bias); |
| 534 | |
| 535 | exit: |
| 536 | /* Cleanup for fragment */ |
| 537 | if (fragment.obj) |
| 538 | PyBuffer_Release(&fragment); |
| 539 | |
| 540 | return return_value; |
| 541 | } |
| 542 | |
| 543 | PyDoc_STRVAR(audioop_reverse__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 544 | "reverse($module, fragment, width, /)\n" |
| 545 | "--\n" |
| 546 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 547 | "Reverse the samples in a fragment and returns the modified fragment."); |
| 548 | |
| 549 | #define AUDIOOP_REVERSE_METHODDEF \ |
| 550 | {"reverse", (PyCFunction)audioop_reverse, METH_VARARGS, audioop_reverse__doc__}, |
| 551 | |
| 552 | static PyObject * |
| 553 | audioop_reverse_impl(PyModuleDef *module, Py_buffer *fragment, int width); |
| 554 | |
| 555 | static PyObject * |
| 556 | audioop_reverse(PyModuleDef *module, PyObject *args) |
| 557 | { |
| 558 | PyObject *return_value = NULL; |
| 559 | Py_buffer fragment = {NULL, NULL}; |
| 560 | int width; |
| 561 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 562 | if (!PyArg_ParseTuple(args, "y*i:reverse", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 563 | &fragment, &width)) |
| 564 | goto exit; |
| 565 | return_value = audioop_reverse_impl(module, &fragment, width); |
| 566 | |
| 567 | exit: |
| 568 | /* Cleanup for fragment */ |
| 569 | if (fragment.obj) |
| 570 | PyBuffer_Release(&fragment); |
| 571 | |
| 572 | return return_value; |
| 573 | } |
| 574 | |
| 575 | PyDoc_STRVAR(audioop_byteswap__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 576 | "byteswap($module, fragment, width, /)\n" |
| 577 | "--\n" |
| 578 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 579 | "Convert big-endian samples to little-endian and vice versa."); |
| 580 | |
| 581 | #define AUDIOOP_BYTESWAP_METHODDEF \ |
| 582 | {"byteswap", (PyCFunction)audioop_byteswap, METH_VARARGS, audioop_byteswap__doc__}, |
| 583 | |
| 584 | static PyObject * |
| 585 | audioop_byteswap_impl(PyModuleDef *module, Py_buffer *fragment, int width); |
| 586 | |
| 587 | static PyObject * |
| 588 | audioop_byteswap(PyModuleDef *module, PyObject *args) |
| 589 | { |
| 590 | PyObject *return_value = NULL; |
| 591 | Py_buffer fragment = {NULL, NULL}; |
| 592 | int width; |
| 593 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 594 | if (!PyArg_ParseTuple(args, "y*i:byteswap", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 595 | &fragment, &width)) |
| 596 | goto exit; |
| 597 | return_value = audioop_byteswap_impl(module, &fragment, width); |
| 598 | |
| 599 | exit: |
| 600 | /* Cleanup for fragment */ |
| 601 | if (fragment.obj) |
| 602 | PyBuffer_Release(&fragment); |
| 603 | |
| 604 | return return_value; |
| 605 | } |
| 606 | |
| 607 | PyDoc_STRVAR(audioop_lin2lin__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 608 | "lin2lin($module, fragment, width, newwidth, /)\n" |
| 609 | "--\n" |
| 610 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 611 | "Convert samples between 1-, 2-, 3- and 4-byte formats."); |
| 612 | |
| 613 | #define AUDIOOP_LIN2LIN_METHODDEF \ |
| 614 | {"lin2lin", (PyCFunction)audioop_lin2lin, METH_VARARGS, audioop_lin2lin__doc__}, |
| 615 | |
| 616 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 617 | audioop_lin2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width, |
| 618 | int newwidth); |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 619 | |
| 620 | static PyObject * |
| 621 | audioop_lin2lin(PyModuleDef *module, PyObject *args) |
| 622 | { |
| 623 | PyObject *return_value = NULL; |
| 624 | Py_buffer fragment = {NULL, NULL}; |
| 625 | int width; |
| 626 | int newwidth; |
| 627 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 628 | if (!PyArg_ParseTuple(args, "y*ii:lin2lin", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 629 | &fragment, &width, &newwidth)) |
| 630 | goto exit; |
| 631 | return_value = audioop_lin2lin_impl(module, &fragment, width, newwidth); |
| 632 | |
| 633 | exit: |
| 634 | /* Cleanup for fragment */ |
| 635 | if (fragment.obj) |
| 636 | PyBuffer_Release(&fragment); |
| 637 | |
| 638 | return return_value; |
| 639 | } |
| 640 | |
| 641 | PyDoc_STRVAR(audioop_ratecv__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 642 | "ratecv($module, fragment, width, nchannels, inrate, outrate, state,\n" |
| 643 | " weightA=1, weightB=0, /)\n" |
| 644 | "--\n" |
| 645 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 646 | "Convert the frame rate of the input fragment."); |
| 647 | |
| 648 | #define AUDIOOP_RATECV_METHODDEF \ |
| 649 | {"ratecv", (PyCFunction)audioop_ratecv, METH_VARARGS, audioop_ratecv__doc__}, |
| 650 | |
| 651 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 652 | audioop_ratecv_impl(PyModuleDef *module, Py_buffer *fragment, int width, |
| 653 | int nchannels, int inrate, int outrate, PyObject *state, |
| 654 | int weightA, int weightB); |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 655 | |
| 656 | static PyObject * |
| 657 | audioop_ratecv(PyModuleDef *module, PyObject *args) |
| 658 | { |
| 659 | PyObject *return_value = NULL; |
| 660 | Py_buffer fragment = {NULL, NULL}; |
| 661 | int width; |
| 662 | int nchannels; |
| 663 | int inrate; |
| 664 | int outrate; |
| 665 | PyObject *state; |
| 666 | int weightA = 1; |
| 667 | int weightB = 0; |
| 668 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 669 | if (!PyArg_ParseTuple(args, "y*iiiiO|ii:ratecv", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 670 | &fragment, &width, &nchannels, &inrate, &outrate, &state, &weightA, &weightB)) |
| 671 | goto exit; |
| 672 | return_value = audioop_ratecv_impl(module, &fragment, width, nchannels, inrate, outrate, state, weightA, weightB); |
| 673 | |
| 674 | exit: |
| 675 | /* Cleanup for fragment */ |
| 676 | if (fragment.obj) |
| 677 | PyBuffer_Release(&fragment); |
| 678 | |
| 679 | return return_value; |
| 680 | } |
| 681 | |
| 682 | PyDoc_STRVAR(audioop_lin2ulaw__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 683 | "lin2ulaw($module, fragment, width, /)\n" |
| 684 | "--\n" |
| 685 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 686 | "Convert samples in the audio fragment to u-LAW encoding."); |
| 687 | |
| 688 | #define AUDIOOP_LIN2ULAW_METHODDEF \ |
| 689 | {"lin2ulaw", (PyCFunction)audioop_lin2ulaw, METH_VARARGS, audioop_lin2ulaw__doc__}, |
| 690 | |
| 691 | static PyObject * |
| 692 | audioop_lin2ulaw_impl(PyModuleDef *module, Py_buffer *fragment, int width); |
| 693 | |
| 694 | static PyObject * |
| 695 | audioop_lin2ulaw(PyModuleDef *module, PyObject *args) |
| 696 | { |
| 697 | PyObject *return_value = NULL; |
| 698 | Py_buffer fragment = {NULL, NULL}; |
| 699 | int width; |
| 700 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 701 | if (!PyArg_ParseTuple(args, "y*i:lin2ulaw", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 702 | &fragment, &width)) |
| 703 | goto exit; |
| 704 | return_value = audioop_lin2ulaw_impl(module, &fragment, width); |
| 705 | |
| 706 | exit: |
| 707 | /* Cleanup for fragment */ |
| 708 | if (fragment.obj) |
| 709 | PyBuffer_Release(&fragment); |
| 710 | |
| 711 | return return_value; |
| 712 | } |
| 713 | |
| 714 | PyDoc_STRVAR(audioop_ulaw2lin__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 715 | "ulaw2lin($module, fragment, width, /)\n" |
| 716 | "--\n" |
| 717 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 718 | "Convert sound fragments in u-LAW encoding to linearly encoded sound fragments."); |
| 719 | |
| 720 | #define AUDIOOP_ULAW2LIN_METHODDEF \ |
| 721 | {"ulaw2lin", (PyCFunction)audioop_ulaw2lin, METH_VARARGS, audioop_ulaw2lin__doc__}, |
| 722 | |
| 723 | static PyObject * |
| 724 | audioop_ulaw2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width); |
| 725 | |
| 726 | static PyObject * |
| 727 | audioop_ulaw2lin(PyModuleDef *module, PyObject *args) |
| 728 | { |
| 729 | PyObject *return_value = NULL; |
| 730 | Py_buffer fragment = {NULL, NULL}; |
| 731 | int width; |
| 732 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 733 | if (!PyArg_ParseTuple(args, "y*i:ulaw2lin", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 734 | &fragment, &width)) |
| 735 | goto exit; |
| 736 | return_value = audioop_ulaw2lin_impl(module, &fragment, width); |
| 737 | |
| 738 | exit: |
| 739 | /* Cleanup for fragment */ |
| 740 | if (fragment.obj) |
| 741 | PyBuffer_Release(&fragment); |
| 742 | |
| 743 | return return_value; |
| 744 | } |
| 745 | |
| 746 | PyDoc_STRVAR(audioop_lin2alaw__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 747 | "lin2alaw($module, fragment, width, /)\n" |
| 748 | "--\n" |
| 749 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 750 | "Convert samples in the audio fragment to a-LAW encoding."); |
| 751 | |
| 752 | #define AUDIOOP_LIN2ALAW_METHODDEF \ |
| 753 | {"lin2alaw", (PyCFunction)audioop_lin2alaw, METH_VARARGS, audioop_lin2alaw__doc__}, |
| 754 | |
| 755 | static PyObject * |
| 756 | audioop_lin2alaw_impl(PyModuleDef *module, Py_buffer *fragment, int width); |
| 757 | |
| 758 | static PyObject * |
| 759 | audioop_lin2alaw(PyModuleDef *module, PyObject *args) |
| 760 | { |
| 761 | PyObject *return_value = NULL; |
| 762 | Py_buffer fragment = {NULL, NULL}; |
| 763 | int width; |
| 764 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 765 | if (!PyArg_ParseTuple(args, "y*i:lin2alaw", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 766 | &fragment, &width)) |
| 767 | goto exit; |
| 768 | return_value = audioop_lin2alaw_impl(module, &fragment, width); |
| 769 | |
| 770 | exit: |
| 771 | /* Cleanup for fragment */ |
| 772 | if (fragment.obj) |
| 773 | PyBuffer_Release(&fragment); |
| 774 | |
| 775 | return return_value; |
| 776 | } |
| 777 | |
| 778 | PyDoc_STRVAR(audioop_alaw2lin__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 779 | "alaw2lin($module, fragment, width, /)\n" |
| 780 | "--\n" |
| 781 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 782 | "Convert sound fragments in a-LAW encoding to linearly encoded sound fragments."); |
| 783 | |
| 784 | #define AUDIOOP_ALAW2LIN_METHODDEF \ |
| 785 | {"alaw2lin", (PyCFunction)audioop_alaw2lin, METH_VARARGS, audioop_alaw2lin__doc__}, |
| 786 | |
| 787 | static PyObject * |
| 788 | audioop_alaw2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width); |
| 789 | |
| 790 | static PyObject * |
| 791 | audioop_alaw2lin(PyModuleDef *module, PyObject *args) |
| 792 | { |
| 793 | PyObject *return_value = NULL; |
| 794 | Py_buffer fragment = {NULL, NULL}; |
| 795 | int width; |
| 796 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 797 | if (!PyArg_ParseTuple(args, "y*i:alaw2lin", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 798 | &fragment, &width)) |
| 799 | goto exit; |
| 800 | return_value = audioop_alaw2lin_impl(module, &fragment, width); |
| 801 | |
| 802 | exit: |
| 803 | /* Cleanup for fragment */ |
| 804 | if (fragment.obj) |
| 805 | PyBuffer_Release(&fragment); |
| 806 | |
| 807 | return return_value; |
| 808 | } |
| 809 | |
| 810 | PyDoc_STRVAR(audioop_lin2adpcm__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 811 | "lin2adpcm($module, fragment, width, state, /)\n" |
| 812 | "--\n" |
| 813 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 814 | "Convert samples to 4 bit Intel/DVI ADPCM encoding."); |
| 815 | |
| 816 | #define AUDIOOP_LIN2ADPCM_METHODDEF \ |
| 817 | {"lin2adpcm", (PyCFunction)audioop_lin2adpcm, METH_VARARGS, audioop_lin2adpcm__doc__}, |
| 818 | |
| 819 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 820 | audioop_lin2adpcm_impl(PyModuleDef *module, Py_buffer *fragment, int width, |
| 821 | PyObject *state); |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 822 | |
| 823 | static PyObject * |
| 824 | audioop_lin2adpcm(PyModuleDef *module, PyObject *args) |
| 825 | { |
| 826 | PyObject *return_value = NULL; |
| 827 | Py_buffer fragment = {NULL, NULL}; |
| 828 | int width; |
| 829 | PyObject *state; |
| 830 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 831 | if (!PyArg_ParseTuple(args, "y*iO:lin2adpcm", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 832 | &fragment, &width, &state)) |
| 833 | goto exit; |
| 834 | return_value = audioop_lin2adpcm_impl(module, &fragment, width, state); |
| 835 | |
| 836 | exit: |
| 837 | /* Cleanup for fragment */ |
| 838 | if (fragment.obj) |
| 839 | PyBuffer_Release(&fragment); |
| 840 | |
| 841 | return return_value; |
| 842 | } |
| 843 | |
| 844 | PyDoc_STRVAR(audioop_adpcm2lin__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 845 | "adpcm2lin($module, fragment, width, state, /)\n" |
| 846 | "--\n" |
| 847 | "\n" |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 848 | "Decode an Intel/DVI ADPCM coded fragment to a linear fragment."); |
| 849 | |
| 850 | #define AUDIOOP_ADPCM2LIN_METHODDEF \ |
| 851 | {"adpcm2lin", (PyCFunction)audioop_adpcm2lin, METH_VARARGS, audioop_adpcm2lin__doc__}, |
| 852 | |
| 853 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 854 | audioop_adpcm2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width, |
| 855 | PyObject *state); |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 856 | |
| 857 | static PyObject * |
| 858 | audioop_adpcm2lin(PyModuleDef *module, PyObject *args) |
| 859 | { |
| 860 | PyObject *return_value = NULL; |
| 861 | Py_buffer fragment = {NULL, NULL}; |
| 862 | int width; |
| 863 | PyObject *state; |
| 864 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 865 | if (!PyArg_ParseTuple(args, "y*iO:adpcm2lin", |
Serhiy Storchaka | 8d00d73 | 2014-01-25 11:57:59 +0200 | [diff] [blame] | 866 | &fragment, &width, &state)) |
| 867 | goto exit; |
| 868 | return_value = audioop_adpcm2lin_impl(module, &fragment, width, state); |
| 869 | |
| 870 | exit: |
| 871 | /* Cleanup for fragment */ |
| 872 | if (fragment.obj) |
| 873 | PyBuffer_Release(&fragment); |
| 874 | |
| 875 | return return_value; |
| 876 | } |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 877 | /*[clinic end generated code: output=a076e1b213a8727b input=a9049054013a1b77]*/ |