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