blob: 3ee29666cc3e3316f9dce031e8bd1363442961aa [file] [log] [blame]
Serhiy Storchaka8d00d732014-01-25 11:57:59 +02001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(audioop_getsample__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -08006"getsample($module, fragment, width, index, /)\n"
7"--\n"
8"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +02009"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
14static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -040015audioop_getsample_impl(PyModuleDef *module, Py_buffer *fragment, int width,
16 Py_ssize_t index);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020017
18static PyObject *
19audioop_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 Storchaka247789c2015-04-24 00:40:51 +030026 if (!PyArg_ParseTuple(args, "y*in:getsample",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020027 &fragment, &width, &index))
28 goto exit;
29 return_value = audioop_getsample_impl(module, &fragment, width, index);
30
31exit:
32 /* Cleanup for fragment */
33 if (fragment.obj)
34 PyBuffer_Release(&fragment);
35
36 return return_value;
37}
38
39PyDoc_STRVAR(audioop_max__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -080040"max($module, fragment, width, /)\n"
41"--\n"
42"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020043"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
48static PyObject *
49audioop_max_impl(PyModuleDef *module, Py_buffer *fragment, int width);
50
51static PyObject *
52audioop_max(PyModuleDef *module, PyObject *args)
53{
54 PyObject *return_value = NULL;
55 Py_buffer fragment = {NULL, NULL};
56 int width;
57
Serhiy Storchaka247789c2015-04-24 00:40:51 +030058 if (!PyArg_ParseTuple(args, "y*i:max",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020059 &fragment, &width))
60 goto exit;
61 return_value = audioop_max_impl(module, &fragment, width);
62
63exit:
64 /* Cleanup for fragment */
65 if (fragment.obj)
66 PyBuffer_Release(&fragment);
67
68 return return_value;
69}
70
71PyDoc_STRVAR(audioop_minmax__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -080072"minmax($module, fragment, width, /)\n"
73"--\n"
74"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020075"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
80static PyObject *
81audioop_minmax_impl(PyModuleDef *module, Py_buffer *fragment, int width);
82
83static PyObject *
84audioop_minmax(PyModuleDef *module, PyObject *args)
85{
86 PyObject *return_value = NULL;
87 Py_buffer fragment = {NULL, NULL};
88 int width;
89
Serhiy Storchaka247789c2015-04-24 00:40:51 +030090 if (!PyArg_ParseTuple(args, "y*i:minmax",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020091 &fragment, &width))
92 goto exit;
93 return_value = audioop_minmax_impl(module, &fragment, width);
94
95exit:
96 /* Cleanup for fragment */
97 if (fragment.obj)
98 PyBuffer_Release(&fragment);
99
100 return return_value;
101}
102
103PyDoc_STRVAR(audioop_avg__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800104"avg($module, fragment, width, /)\n"
105"--\n"
106"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200107"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
112static PyObject *
113audioop_avg_impl(PyModuleDef *module, Py_buffer *fragment, int width);
114
115static PyObject *
116audioop_avg(PyModuleDef *module, PyObject *args)
117{
118 PyObject *return_value = NULL;
119 Py_buffer fragment = {NULL, NULL};
120 int width;
121
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300122 if (!PyArg_ParseTuple(args, "y*i:avg",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200123 &fragment, &width))
124 goto exit;
125 return_value = audioop_avg_impl(module, &fragment, width);
126
127exit:
128 /* Cleanup for fragment */
129 if (fragment.obj)
130 PyBuffer_Release(&fragment);
131
132 return return_value;
133}
134
135PyDoc_STRVAR(audioop_rms__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800136"rms($module, fragment, width, /)\n"
137"--\n"
138"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200139"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
144static PyObject *
145audioop_rms_impl(PyModuleDef *module, Py_buffer *fragment, int width);
146
147static PyObject *
148audioop_rms(PyModuleDef *module, PyObject *args)
149{
150 PyObject *return_value = NULL;
151 Py_buffer fragment = {NULL, NULL};
152 int width;
153
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300154 if (!PyArg_ParseTuple(args, "y*i:rms",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200155 &fragment, &width))
156 goto exit;
157 return_value = audioop_rms_impl(module, &fragment, width);
158
159exit:
160 /* Cleanup for fragment */
161 if (fragment.obj)
162 PyBuffer_Release(&fragment);
163
164 return return_value;
165}
166
167PyDoc_STRVAR(audioop_findfit__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800168"findfit($module, fragment, reference, /)\n"
169"--\n"
170"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200171"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
176static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400177audioop_findfit_impl(PyModuleDef *module, Py_buffer *fragment,
178 Py_buffer *reference);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200179
180static PyObject *
181audioop_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 Storchaka247789c2015-04-24 00:40:51 +0300187 if (!PyArg_ParseTuple(args, "y*y*:findfit",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200188 &fragment, &reference))
189 goto exit;
190 return_value = audioop_findfit_impl(module, &fragment, &reference);
191
192exit:
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
203PyDoc_STRVAR(audioop_findfactor__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800204"findfactor($module, fragment, reference, /)\n"
205"--\n"
206"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200207"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
212static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400213audioop_findfactor_impl(PyModuleDef *module, Py_buffer *fragment,
214 Py_buffer *reference);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200215
216static PyObject *
217audioop_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 Storchaka247789c2015-04-24 00:40:51 +0300223 if (!PyArg_ParseTuple(args, "y*y*:findfactor",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200224 &fragment, &reference))
225 goto exit;
226 return_value = audioop_findfactor_impl(module, &fragment, &reference);
227
228exit:
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
239PyDoc_STRVAR(audioop_findmax__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800240"findmax($module, fragment, length, /)\n"
241"--\n"
242"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200243"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
248static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400249audioop_findmax_impl(PyModuleDef *module, Py_buffer *fragment,
250 Py_ssize_t length);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200251
252static PyObject *
253audioop_findmax(PyModuleDef *module, PyObject *args)
254{
255 PyObject *return_value = NULL;
256 Py_buffer fragment = {NULL, NULL};
257 Py_ssize_t length;
258
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300259 if (!PyArg_ParseTuple(args, "y*n:findmax",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200260 &fragment, &length))
261 goto exit;
262 return_value = audioop_findmax_impl(module, &fragment, length);
263
264exit:
265 /* Cleanup for fragment */
266 if (fragment.obj)
267 PyBuffer_Release(&fragment);
268
269 return return_value;
270}
271
272PyDoc_STRVAR(audioop_avgpp__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800273"avgpp($module, fragment, width, /)\n"
274"--\n"
275"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200276"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
281static PyObject *
282audioop_avgpp_impl(PyModuleDef *module, Py_buffer *fragment, int width);
283
284static PyObject *
285audioop_avgpp(PyModuleDef *module, PyObject *args)
286{
287 PyObject *return_value = NULL;
288 Py_buffer fragment = {NULL, NULL};
289 int width;
290
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300291 if (!PyArg_ParseTuple(args, "y*i:avgpp",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200292 &fragment, &width))
293 goto exit;
294 return_value = audioop_avgpp_impl(module, &fragment, width);
295
296exit:
297 /* Cleanup for fragment */
298 if (fragment.obj)
299 PyBuffer_Release(&fragment);
300
301 return return_value;
302}
303
304PyDoc_STRVAR(audioop_maxpp__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800305"maxpp($module, fragment, width, /)\n"
306"--\n"
307"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200308"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
313static PyObject *
314audioop_maxpp_impl(PyModuleDef *module, Py_buffer *fragment, int width);
315
316static PyObject *
317audioop_maxpp(PyModuleDef *module, PyObject *args)
318{
319 PyObject *return_value = NULL;
320 Py_buffer fragment = {NULL, NULL};
321 int width;
322
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300323 if (!PyArg_ParseTuple(args, "y*i:maxpp",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200324 &fragment, &width))
325 goto exit;
326 return_value = audioop_maxpp_impl(module, &fragment, width);
327
328exit:
329 /* Cleanup for fragment */
330 if (fragment.obj)
331 PyBuffer_Release(&fragment);
332
333 return return_value;
334}
335
336PyDoc_STRVAR(audioop_cross__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800337"cross($module, fragment, width, /)\n"
338"--\n"
339"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200340"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
345static PyObject *
346audioop_cross_impl(PyModuleDef *module, Py_buffer *fragment, int width);
347
348static PyObject *
349audioop_cross(PyModuleDef *module, PyObject *args)
350{
351 PyObject *return_value = NULL;
352 Py_buffer fragment = {NULL, NULL};
353 int width;
354
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300355 if (!PyArg_ParseTuple(args, "y*i:cross",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200356 &fragment, &width))
357 goto exit;
358 return_value = audioop_cross_impl(module, &fragment, width);
359
360exit:
361 /* Cleanup for fragment */
362 if (fragment.obj)
363 PyBuffer_Release(&fragment);
364
365 return return_value;
366}
367
368PyDoc_STRVAR(audioop_mul__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800369"mul($module, fragment, width, factor, /)\n"
370"--\n"
371"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200372"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
377static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400378audioop_mul_impl(PyModuleDef *module, Py_buffer *fragment, int width,
379 double factor);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200380
381static PyObject *
382audioop_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 Storchaka247789c2015-04-24 00:40:51 +0300389 if (!PyArg_ParseTuple(args, "y*id:mul",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200390 &fragment, &width, &factor))
391 goto exit;
392 return_value = audioop_mul_impl(module, &fragment, width, factor);
393
394exit:
395 /* Cleanup for fragment */
396 if (fragment.obj)
397 PyBuffer_Release(&fragment);
398
399 return return_value;
400}
401
402PyDoc_STRVAR(audioop_tomono__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800403"tomono($module, fragment, width, lfactor, rfactor, /)\n"
404"--\n"
405"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200406"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
411static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400412audioop_tomono_impl(PyModuleDef *module, Py_buffer *fragment, int width,
413 double lfactor, double rfactor);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200414
415static PyObject *
416audioop_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 Storchaka247789c2015-04-24 00:40:51 +0300424 if (!PyArg_ParseTuple(args, "y*idd:tomono",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200425 &fragment, &width, &lfactor, &rfactor))
426 goto exit;
427 return_value = audioop_tomono_impl(module, &fragment, width, lfactor, rfactor);
428
429exit:
430 /* Cleanup for fragment */
431 if (fragment.obj)
432 PyBuffer_Release(&fragment);
433
434 return return_value;
435}
436
437PyDoc_STRVAR(audioop_tostereo__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800438"tostereo($module, fragment, width, lfactor, rfactor, /)\n"
439"--\n"
440"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200441"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
446static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400447audioop_tostereo_impl(PyModuleDef *module, Py_buffer *fragment, int width,
448 double lfactor, double rfactor);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200449
450static PyObject *
451audioop_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 Storchaka247789c2015-04-24 00:40:51 +0300459 if (!PyArg_ParseTuple(args, "y*idd:tostereo",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200460 &fragment, &width, &lfactor, &rfactor))
461 goto exit;
462 return_value = audioop_tostereo_impl(module, &fragment, width, lfactor, rfactor);
463
464exit:
465 /* Cleanup for fragment */
466 if (fragment.obj)
467 PyBuffer_Release(&fragment);
468
469 return return_value;
470}
471
472PyDoc_STRVAR(audioop_add__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800473"add($module, fragment1, fragment2, width, /)\n"
474"--\n"
475"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200476"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
481static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400482audioop_add_impl(PyModuleDef *module, Py_buffer *fragment1,
483 Py_buffer *fragment2, int width);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200484
485static PyObject *
486audioop_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 Storchaka247789c2015-04-24 00:40:51 +0300493 if (!PyArg_ParseTuple(args, "y*y*i:add",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200494 &fragment1, &fragment2, &width))
495 goto exit;
496 return_value = audioop_add_impl(module, &fragment1, &fragment2, width);
497
498exit:
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
509PyDoc_STRVAR(audioop_bias__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800510"bias($module, fragment, width, bias, /)\n"
511"--\n"
512"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200513"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
518static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400519audioop_bias_impl(PyModuleDef *module, Py_buffer *fragment, int width,
520 int bias);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200521
522static PyObject *
523audioop_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 Storchaka247789c2015-04-24 00:40:51 +0300530 if (!PyArg_ParseTuple(args, "y*ii:bias",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200531 &fragment, &width, &bias))
532 goto exit;
533 return_value = audioop_bias_impl(module, &fragment, width, bias);
534
535exit:
536 /* Cleanup for fragment */
537 if (fragment.obj)
538 PyBuffer_Release(&fragment);
539
540 return return_value;
541}
542
543PyDoc_STRVAR(audioop_reverse__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800544"reverse($module, fragment, width, /)\n"
545"--\n"
546"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200547"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
552static PyObject *
553audioop_reverse_impl(PyModuleDef *module, Py_buffer *fragment, int width);
554
555static PyObject *
556audioop_reverse(PyModuleDef *module, PyObject *args)
557{
558 PyObject *return_value = NULL;
559 Py_buffer fragment = {NULL, NULL};
560 int width;
561
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300562 if (!PyArg_ParseTuple(args, "y*i:reverse",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200563 &fragment, &width))
564 goto exit;
565 return_value = audioop_reverse_impl(module, &fragment, width);
566
567exit:
568 /* Cleanup for fragment */
569 if (fragment.obj)
570 PyBuffer_Release(&fragment);
571
572 return return_value;
573}
574
575PyDoc_STRVAR(audioop_byteswap__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800576"byteswap($module, fragment, width, /)\n"
577"--\n"
578"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200579"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
584static PyObject *
585audioop_byteswap_impl(PyModuleDef *module, Py_buffer *fragment, int width);
586
587static PyObject *
588audioop_byteswap(PyModuleDef *module, PyObject *args)
589{
590 PyObject *return_value = NULL;
591 Py_buffer fragment = {NULL, NULL};
592 int width;
593
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300594 if (!PyArg_ParseTuple(args, "y*i:byteswap",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200595 &fragment, &width))
596 goto exit;
597 return_value = audioop_byteswap_impl(module, &fragment, width);
598
599exit:
600 /* Cleanup for fragment */
601 if (fragment.obj)
602 PyBuffer_Release(&fragment);
603
604 return return_value;
605}
606
607PyDoc_STRVAR(audioop_lin2lin__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800608"lin2lin($module, fragment, width, newwidth, /)\n"
609"--\n"
610"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200611"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
616static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400617audioop_lin2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width,
618 int newwidth);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200619
620static PyObject *
621audioop_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 Storchaka247789c2015-04-24 00:40:51 +0300628 if (!PyArg_ParseTuple(args, "y*ii:lin2lin",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200629 &fragment, &width, &newwidth))
630 goto exit;
631 return_value = audioop_lin2lin_impl(module, &fragment, width, newwidth);
632
633exit:
634 /* Cleanup for fragment */
635 if (fragment.obj)
636 PyBuffer_Release(&fragment);
637
638 return return_value;
639}
640
641PyDoc_STRVAR(audioop_ratecv__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800642"ratecv($module, fragment, width, nchannels, inrate, outrate, state,\n"
643" weightA=1, weightB=0, /)\n"
644"--\n"
645"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200646"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
651static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400652audioop_ratecv_impl(PyModuleDef *module, Py_buffer *fragment, int width,
653 int nchannels, int inrate, int outrate, PyObject *state,
654 int weightA, int weightB);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200655
656static PyObject *
657audioop_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 Storchaka247789c2015-04-24 00:40:51 +0300669 if (!PyArg_ParseTuple(args, "y*iiiiO|ii:ratecv",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200670 &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
674exit:
675 /* Cleanup for fragment */
676 if (fragment.obj)
677 PyBuffer_Release(&fragment);
678
679 return return_value;
680}
681
682PyDoc_STRVAR(audioop_lin2ulaw__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800683"lin2ulaw($module, fragment, width, /)\n"
684"--\n"
685"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200686"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
691static PyObject *
692audioop_lin2ulaw_impl(PyModuleDef *module, Py_buffer *fragment, int width);
693
694static PyObject *
695audioop_lin2ulaw(PyModuleDef *module, PyObject *args)
696{
697 PyObject *return_value = NULL;
698 Py_buffer fragment = {NULL, NULL};
699 int width;
700
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300701 if (!PyArg_ParseTuple(args, "y*i:lin2ulaw",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200702 &fragment, &width))
703 goto exit;
704 return_value = audioop_lin2ulaw_impl(module, &fragment, width);
705
706exit:
707 /* Cleanup for fragment */
708 if (fragment.obj)
709 PyBuffer_Release(&fragment);
710
711 return return_value;
712}
713
714PyDoc_STRVAR(audioop_ulaw2lin__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800715"ulaw2lin($module, fragment, width, /)\n"
716"--\n"
717"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200718"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
723static PyObject *
724audioop_ulaw2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width);
725
726static PyObject *
727audioop_ulaw2lin(PyModuleDef *module, PyObject *args)
728{
729 PyObject *return_value = NULL;
730 Py_buffer fragment = {NULL, NULL};
731 int width;
732
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300733 if (!PyArg_ParseTuple(args, "y*i:ulaw2lin",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200734 &fragment, &width))
735 goto exit;
736 return_value = audioop_ulaw2lin_impl(module, &fragment, width);
737
738exit:
739 /* Cleanup for fragment */
740 if (fragment.obj)
741 PyBuffer_Release(&fragment);
742
743 return return_value;
744}
745
746PyDoc_STRVAR(audioop_lin2alaw__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800747"lin2alaw($module, fragment, width, /)\n"
748"--\n"
749"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200750"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
755static PyObject *
756audioop_lin2alaw_impl(PyModuleDef *module, Py_buffer *fragment, int width);
757
758static PyObject *
759audioop_lin2alaw(PyModuleDef *module, PyObject *args)
760{
761 PyObject *return_value = NULL;
762 Py_buffer fragment = {NULL, NULL};
763 int width;
764
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300765 if (!PyArg_ParseTuple(args, "y*i:lin2alaw",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200766 &fragment, &width))
767 goto exit;
768 return_value = audioop_lin2alaw_impl(module, &fragment, width);
769
770exit:
771 /* Cleanup for fragment */
772 if (fragment.obj)
773 PyBuffer_Release(&fragment);
774
775 return return_value;
776}
777
778PyDoc_STRVAR(audioop_alaw2lin__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800779"alaw2lin($module, fragment, width, /)\n"
780"--\n"
781"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200782"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
787static PyObject *
788audioop_alaw2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width);
789
790static PyObject *
791audioop_alaw2lin(PyModuleDef *module, PyObject *args)
792{
793 PyObject *return_value = NULL;
794 Py_buffer fragment = {NULL, NULL};
795 int width;
796
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300797 if (!PyArg_ParseTuple(args, "y*i:alaw2lin",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200798 &fragment, &width))
799 goto exit;
800 return_value = audioop_alaw2lin_impl(module, &fragment, width);
801
802exit:
803 /* Cleanup for fragment */
804 if (fragment.obj)
805 PyBuffer_Release(&fragment);
806
807 return return_value;
808}
809
810PyDoc_STRVAR(audioop_lin2adpcm__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800811"lin2adpcm($module, fragment, width, state, /)\n"
812"--\n"
813"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200814"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
819static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400820audioop_lin2adpcm_impl(PyModuleDef *module, Py_buffer *fragment, int width,
821 PyObject *state);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200822
823static PyObject *
824audioop_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 Storchaka247789c2015-04-24 00:40:51 +0300831 if (!PyArg_ParseTuple(args, "y*iO:lin2adpcm",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200832 &fragment, &width, &state))
833 goto exit;
834 return_value = audioop_lin2adpcm_impl(module, &fragment, width, state);
835
836exit:
837 /* Cleanup for fragment */
838 if (fragment.obj)
839 PyBuffer_Release(&fragment);
840
841 return return_value;
842}
843
844PyDoc_STRVAR(audioop_adpcm2lin__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800845"adpcm2lin($module, fragment, width, state, /)\n"
846"--\n"
847"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200848"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
853static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400854audioop_adpcm2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width,
855 PyObject *state);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200856
857static PyObject *
858audioop_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 Storchaka247789c2015-04-24 00:40:51 +0300865 if (!PyArg_ParseTuple(args, "y*iO:adpcm2lin",
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200866 &fragment, &width, &state))
867 goto exit;
868 return_value = audioop_adpcm2lin_impl(module, &fragment, width, state);
869
870exit:
871 /* Cleanup for fragment */
872 if (fragment.obj)
873 PyBuffer_Release(&fragment);
874
875 return return_value;
876}
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300877/*[clinic end generated code: output=a076e1b213a8727b input=a9049054013a1b77]*/