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