blob: 4baba27cfdde1bd93173fb1f597b49ccf64fccf3 [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 Storchaka5dee6552016-06-09 16:16:06 +030027 &fragment, &width, &index)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020028 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030029 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020030 return_value = audioop_getsample_impl(module, &fragment, width, index);
31
32exit:
33 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030034 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020035 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030036 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020037
38 return return_value;
39}
40
41PyDoc_STRVAR(audioop_max__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -080042"max($module, fragment, width, /)\n"
43"--\n"
44"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020045"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_VARARGS, audioop_max__doc__},
49
50static PyObject *
51audioop_max_impl(PyModuleDef *module, Py_buffer *fragment, int width);
52
53static PyObject *
54audioop_max(PyModuleDef *module, PyObject *args)
55{
56 PyObject *return_value = NULL;
57 Py_buffer fragment = {NULL, NULL};
58 int width;
59
Serhiy Storchaka247789c2015-04-24 00:40:51 +030060 if (!PyArg_ParseTuple(args, "y*i:max",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030061 &fragment, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020062 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030063 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020064 return_value = audioop_max_impl(module, &fragment, width);
65
66exit:
67 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030068 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020069 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030070 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020071
72 return return_value;
73}
74
75PyDoc_STRVAR(audioop_minmax__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -080076"minmax($module, fragment, width, /)\n"
77"--\n"
78"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020079"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_VARARGS, audioop_minmax__doc__},
83
84static PyObject *
85audioop_minmax_impl(PyModuleDef *module, Py_buffer *fragment, int width);
86
87static PyObject *
88audioop_minmax(PyModuleDef *module, PyObject *args)
89{
90 PyObject *return_value = NULL;
91 Py_buffer fragment = {NULL, NULL};
92 int width;
93
Serhiy Storchaka247789c2015-04-24 00:40:51 +030094 if (!PyArg_ParseTuple(args, "y*i:minmax",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030095 &fragment, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020096 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030097 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +020098 return_value = audioop_minmax_impl(module, &fragment, width);
99
100exit:
101 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300102 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200103 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300104 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200105
106 return return_value;
107}
108
109PyDoc_STRVAR(audioop_avg__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800110"avg($module, fragment, width, /)\n"
111"--\n"
112"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200113"Return the average over all samples in the fragment.");
114
115#define AUDIOOP_AVG_METHODDEF \
116 {"avg", (PyCFunction)audioop_avg, METH_VARARGS, audioop_avg__doc__},
117
118static PyObject *
119audioop_avg_impl(PyModuleDef *module, Py_buffer *fragment, int width);
120
121static PyObject *
122audioop_avg(PyModuleDef *module, PyObject *args)
123{
124 PyObject *return_value = NULL;
125 Py_buffer fragment = {NULL, NULL};
126 int width;
127
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300128 if (!PyArg_ParseTuple(args, "y*i:avg",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300129 &fragment, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200130 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300131 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200132 return_value = audioop_avg_impl(module, &fragment, width);
133
134exit:
135 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300136 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200137 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300138 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200139
140 return return_value;
141}
142
143PyDoc_STRVAR(audioop_rms__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800144"rms($module, fragment, width, /)\n"
145"--\n"
146"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200147"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_VARARGS, audioop_rms__doc__},
151
152static PyObject *
153audioop_rms_impl(PyModuleDef *module, Py_buffer *fragment, int width);
154
155static PyObject *
156audioop_rms(PyModuleDef *module, PyObject *args)
157{
158 PyObject *return_value = NULL;
159 Py_buffer fragment = {NULL, NULL};
160 int width;
161
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300162 if (!PyArg_ParseTuple(args, "y*i:rms",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300163 &fragment, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200164 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300165 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200166 return_value = audioop_rms_impl(module, &fragment, width);
167
168exit:
169 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300170 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200171 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300172 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200173
174 return return_value;
175}
176
177PyDoc_STRVAR(audioop_findfit__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800178"findfit($module, fragment, reference, /)\n"
179"--\n"
180"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200181"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_VARARGS, audioop_findfit__doc__},
185
186static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400187audioop_findfit_impl(PyModuleDef *module, Py_buffer *fragment,
188 Py_buffer *reference);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200189
190static PyObject *
191audioop_findfit(PyModuleDef *module, PyObject *args)
192{
193 PyObject *return_value = NULL;
194 Py_buffer fragment = {NULL, NULL};
195 Py_buffer reference = {NULL, NULL};
196
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300197 if (!PyArg_ParseTuple(args, "y*y*:findfit",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300198 &fragment, &reference)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200199 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300200 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200201 return_value = audioop_findfit_impl(module, &fragment, &reference);
202
203exit:
204 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300205 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200206 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300207 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200208 /* Cleanup for reference */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300209 if (reference.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200210 PyBuffer_Release(&reference);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300211 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200212
213 return return_value;
214}
215
216PyDoc_STRVAR(audioop_findfactor__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800217"findfactor($module, fragment, reference, /)\n"
218"--\n"
219"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200220"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_VARARGS, audioop_findfactor__doc__},
224
225static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400226audioop_findfactor_impl(PyModuleDef *module, Py_buffer *fragment,
227 Py_buffer *reference);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200228
229static PyObject *
230audioop_findfactor(PyModuleDef *module, PyObject *args)
231{
232 PyObject *return_value = NULL;
233 Py_buffer fragment = {NULL, NULL};
234 Py_buffer reference = {NULL, NULL};
235
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300236 if (!PyArg_ParseTuple(args, "y*y*:findfactor",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300237 &fragment, &reference)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200238 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300239 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200240 return_value = audioop_findfactor_impl(module, &fragment, &reference);
241
242exit:
243 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300244 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200245 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300246 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200247 /* Cleanup for reference */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300248 if (reference.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200249 PyBuffer_Release(&reference);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300250 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200251
252 return return_value;
253}
254
255PyDoc_STRVAR(audioop_findmax__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800256"findmax($module, fragment, length, /)\n"
257"--\n"
258"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200259"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_VARARGS, audioop_findmax__doc__},
263
264static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400265audioop_findmax_impl(PyModuleDef *module, Py_buffer *fragment,
266 Py_ssize_t length);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200267
268static PyObject *
269audioop_findmax(PyModuleDef *module, PyObject *args)
270{
271 PyObject *return_value = NULL;
272 Py_buffer fragment = {NULL, NULL};
273 Py_ssize_t length;
274
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300275 if (!PyArg_ParseTuple(args, "y*n:findmax",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300276 &fragment, &length)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200277 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300278 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200279 return_value = audioop_findmax_impl(module, &fragment, length);
280
281exit:
282 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300283 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200284 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300285 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200286
287 return return_value;
288}
289
290PyDoc_STRVAR(audioop_avgpp__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800291"avgpp($module, fragment, width, /)\n"
292"--\n"
293"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200294"Return the average peak-peak value over all samples in the fragment.");
295
296#define AUDIOOP_AVGPP_METHODDEF \
297 {"avgpp", (PyCFunction)audioop_avgpp, METH_VARARGS, audioop_avgpp__doc__},
298
299static PyObject *
300audioop_avgpp_impl(PyModuleDef *module, Py_buffer *fragment, int width);
301
302static PyObject *
303audioop_avgpp(PyModuleDef *module, PyObject *args)
304{
305 PyObject *return_value = NULL;
306 Py_buffer fragment = {NULL, NULL};
307 int width;
308
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300309 if (!PyArg_ParseTuple(args, "y*i:avgpp",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300310 &fragment, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200311 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300312 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200313 return_value = audioop_avgpp_impl(module, &fragment, width);
314
315exit:
316 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300317 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200318 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300319 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200320
321 return return_value;
322}
323
324PyDoc_STRVAR(audioop_maxpp__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800325"maxpp($module, fragment, width, /)\n"
326"--\n"
327"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200328"Return the maximum peak-peak value in the sound fragment.");
329
330#define AUDIOOP_MAXPP_METHODDEF \
331 {"maxpp", (PyCFunction)audioop_maxpp, METH_VARARGS, audioop_maxpp__doc__},
332
333static PyObject *
334audioop_maxpp_impl(PyModuleDef *module, Py_buffer *fragment, int width);
335
336static PyObject *
337audioop_maxpp(PyModuleDef *module, PyObject *args)
338{
339 PyObject *return_value = NULL;
340 Py_buffer fragment = {NULL, NULL};
341 int width;
342
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300343 if (!PyArg_ParseTuple(args, "y*i:maxpp",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300344 &fragment, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200345 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300346 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200347 return_value = audioop_maxpp_impl(module, &fragment, width);
348
349exit:
350 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300351 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200352 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300353 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200354
355 return return_value;
356}
357
358PyDoc_STRVAR(audioop_cross__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800359"cross($module, fragment, width, /)\n"
360"--\n"
361"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200362"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_VARARGS, audioop_cross__doc__},
366
367static PyObject *
368audioop_cross_impl(PyModuleDef *module, Py_buffer *fragment, int width);
369
370static PyObject *
371audioop_cross(PyModuleDef *module, PyObject *args)
372{
373 PyObject *return_value = NULL;
374 Py_buffer fragment = {NULL, NULL};
375 int width;
376
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300377 if (!PyArg_ParseTuple(args, "y*i:cross",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300378 &fragment, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200379 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300380 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200381 return_value = audioop_cross_impl(module, &fragment, width);
382
383exit:
384 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300385 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200386 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300387 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200388
389 return return_value;
390}
391
392PyDoc_STRVAR(audioop_mul__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800393"mul($module, fragment, width, factor, /)\n"
394"--\n"
395"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200396"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_VARARGS, audioop_mul__doc__},
400
401static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400402audioop_mul_impl(PyModuleDef *module, Py_buffer *fragment, int width,
403 double factor);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200404
405static PyObject *
406audioop_mul(PyModuleDef *module, PyObject *args)
407{
408 PyObject *return_value = NULL;
409 Py_buffer fragment = {NULL, NULL};
410 int width;
411 double factor;
412
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300413 if (!PyArg_ParseTuple(args, "y*id:mul",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300414 &fragment, &width, &factor)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200415 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300416 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200417 return_value = audioop_mul_impl(module, &fragment, width, factor);
418
419exit:
420 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300421 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200422 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300423 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200424
425 return return_value;
426}
427
428PyDoc_STRVAR(audioop_tomono__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800429"tomono($module, fragment, width, lfactor, rfactor, /)\n"
430"--\n"
431"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200432"Convert a stereo fragment to a mono fragment.");
433
434#define AUDIOOP_TOMONO_METHODDEF \
435 {"tomono", (PyCFunction)audioop_tomono, METH_VARARGS, audioop_tomono__doc__},
436
437static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400438audioop_tomono_impl(PyModuleDef *module, Py_buffer *fragment, int width,
439 double lfactor, double rfactor);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200440
441static PyObject *
442audioop_tomono(PyModuleDef *module, PyObject *args)
443{
444 PyObject *return_value = NULL;
445 Py_buffer fragment = {NULL, NULL};
446 int width;
447 double lfactor;
448 double rfactor;
449
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300450 if (!PyArg_ParseTuple(args, "y*idd:tomono",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300451 &fragment, &width, &lfactor, &rfactor)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200452 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300453 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200454 return_value = audioop_tomono_impl(module, &fragment, width, lfactor, rfactor);
455
456exit:
457 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300458 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200459 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300460 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200461
462 return return_value;
463}
464
465PyDoc_STRVAR(audioop_tostereo__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800466"tostereo($module, fragment, width, lfactor, rfactor, /)\n"
467"--\n"
468"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200469"Generate a stereo fragment from a mono fragment.");
470
471#define AUDIOOP_TOSTEREO_METHODDEF \
472 {"tostereo", (PyCFunction)audioop_tostereo, METH_VARARGS, audioop_tostereo__doc__},
473
474static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400475audioop_tostereo_impl(PyModuleDef *module, Py_buffer *fragment, int width,
476 double lfactor, double rfactor);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200477
478static PyObject *
479audioop_tostereo(PyModuleDef *module, PyObject *args)
480{
481 PyObject *return_value = NULL;
482 Py_buffer fragment = {NULL, NULL};
483 int width;
484 double lfactor;
485 double rfactor;
486
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300487 if (!PyArg_ParseTuple(args, "y*idd:tostereo",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300488 &fragment, &width, &lfactor, &rfactor)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200489 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300490 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200491 return_value = audioop_tostereo_impl(module, &fragment, width, lfactor, rfactor);
492
493exit:
494 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300495 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200496 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300497 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200498
499 return return_value;
500}
501
502PyDoc_STRVAR(audioop_add__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800503"add($module, fragment1, fragment2, width, /)\n"
504"--\n"
505"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200506"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_VARARGS, audioop_add__doc__},
510
511static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400512audioop_add_impl(PyModuleDef *module, Py_buffer *fragment1,
513 Py_buffer *fragment2, int width);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200514
515static PyObject *
516audioop_add(PyModuleDef *module, PyObject *args)
517{
518 PyObject *return_value = NULL;
519 Py_buffer fragment1 = {NULL, NULL};
520 Py_buffer fragment2 = {NULL, NULL};
521 int width;
522
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300523 if (!PyArg_ParseTuple(args, "y*y*i:add",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300524 &fragment1, &fragment2, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200525 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300526 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200527 return_value = audioop_add_impl(module, &fragment1, &fragment2, width);
528
529exit:
530 /* Cleanup for fragment1 */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300531 if (fragment1.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200532 PyBuffer_Release(&fragment1);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300533 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200534 /* Cleanup for fragment2 */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300535 if (fragment2.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200536 PyBuffer_Release(&fragment2);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300537 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200538
539 return return_value;
540}
541
542PyDoc_STRVAR(audioop_bias__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800543"bias($module, fragment, width, bias, /)\n"
544"--\n"
545"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200546"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_VARARGS, audioop_bias__doc__},
550
551static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400552audioop_bias_impl(PyModuleDef *module, Py_buffer *fragment, int width,
553 int bias);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200554
555static PyObject *
556audioop_bias(PyModuleDef *module, PyObject *args)
557{
558 PyObject *return_value = NULL;
559 Py_buffer fragment = {NULL, NULL};
560 int width;
561 int bias;
562
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300563 if (!PyArg_ParseTuple(args, "y*ii:bias",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300564 &fragment, &width, &bias)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200565 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300566 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200567 return_value = audioop_bias_impl(module, &fragment, width, bias);
568
569exit:
570 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300571 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200572 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300573 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200574
575 return return_value;
576}
577
578PyDoc_STRVAR(audioop_reverse__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800579"reverse($module, fragment, width, /)\n"
580"--\n"
581"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200582"Reverse the samples in a fragment and returns the modified fragment.");
583
584#define AUDIOOP_REVERSE_METHODDEF \
585 {"reverse", (PyCFunction)audioop_reverse, METH_VARARGS, audioop_reverse__doc__},
586
587static PyObject *
588audioop_reverse_impl(PyModuleDef *module, Py_buffer *fragment, int width);
589
590static PyObject *
591audioop_reverse(PyModuleDef *module, PyObject *args)
592{
593 PyObject *return_value = NULL;
594 Py_buffer fragment = {NULL, NULL};
595 int width;
596
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300597 if (!PyArg_ParseTuple(args, "y*i:reverse",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300598 &fragment, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200599 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300600 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200601 return_value = audioop_reverse_impl(module, &fragment, width);
602
603exit:
604 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300605 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200606 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300607 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200608
609 return return_value;
610}
611
612PyDoc_STRVAR(audioop_byteswap__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800613"byteswap($module, fragment, width, /)\n"
614"--\n"
615"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200616"Convert big-endian samples to little-endian and vice versa.");
617
618#define AUDIOOP_BYTESWAP_METHODDEF \
619 {"byteswap", (PyCFunction)audioop_byteswap, METH_VARARGS, audioop_byteswap__doc__},
620
621static PyObject *
622audioop_byteswap_impl(PyModuleDef *module, Py_buffer *fragment, int width);
623
624static PyObject *
625audioop_byteswap(PyModuleDef *module, PyObject *args)
626{
627 PyObject *return_value = NULL;
628 Py_buffer fragment = {NULL, NULL};
629 int width;
630
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300631 if (!PyArg_ParseTuple(args, "y*i:byteswap",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300632 &fragment, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200633 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300634 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200635 return_value = audioop_byteswap_impl(module, &fragment, width);
636
637exit:
638 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300639 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200640 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300641 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200642
643 return return_value;
644}
645
646PyDoc_STRVAR(audioop_lin2lin__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800647"lin2lin($module, fragment, width, newwidth, /)\n"
648"--\n"
649"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200650"Convert samples between 1-, 2-, 3- and 4-byte formats.");
651
652#define AUDIOOP_LIN2LIN_METHODDEF \
653 {"lin2lin", (PyCFunction)audioop_lin2lin, METH_VARARGS, audioop_lin2lin__doc__},
654
655static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400656audioop_lin2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width,
657 int newwidth);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200658
659static PyObject *
660audioop_lin2lin(PyModuleDef *module, PyObject *args)
661{
662 PyObject *return_value = NULL;
663 Py_buffer fragment = {NULL, NULL};
664 int width;
665 int newwidth;
666
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300667 if (!PyArg_ParseTuple(args, "y*ii:lin2lin",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300668 &fragment, &width, &newwidth)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200669 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300670 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200671 return_value = audioop_lin2lin_impl(module, &fragment, width, newwidth);
672
673exit:
674 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300675 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200676 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300677 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200678
679 return return_value;
680}
681
682PyDoc_STRVAR(audioop_ratecv__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800683"ratecv($module, fragment, width, nchannels, inrate, outrate, state,\n"
684" weightA=1, weightB=0, /)\n"
685"--\n"
686"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200687"Convert the frame rate of the input fragment.");
688
689#define AUDIOOP_RATECV_METHODDEF \
690 {"ratecv", (PyCFunction)audioop_ratecv, METH_VARARGS, audioop_ratecv__doc__},
691
692static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400693audioop_ratecv_impl(PyModuleDef *module, Py_buffer *fragment, int width,
694 int nchannels, int inrate, int outrate, PyObject *state,
695 int weightA, int weightB);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200696
697static PyObject *
698audioop_ratecv(PyModuleDef *module, PyObject *args)
699{
700 PyObject *return_value = NULL;
701 Py_buffer fragment = {NULL, NULL};
702 int width;
703 int nchannels;
704 int inrate;
705 int outrate;
706 PyObject *state;
707 int weightA = 1;
708 int weightB = 0;
709
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300710 if (!PyArg_ParseTuple(args, "y*iiiiO|ii:ratecv",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300711 &fragment, &width, &nchannels, &inrate, &outrate, &state, &weightA, &weightB)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200712 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300713 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200714 return_value = audioop_ratecv_impl(module, &fragment, width, nchannels, inrate, outrate, state, weightA, weightB);
715
716exit:
717 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300718 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200719 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300720 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200721
722 return return_value;
723}
724
725PyDoc_STRVAR(audioop_lin2ulaw__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800726"lin2ulaw($module, fragment, width, /)\n"
727"--\n"
728"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200729"Convert samples in the audio fragment to u-LAW encoding.");
730
731#define AUDIOOP_LIN2ULAW_METHODDEF \
732 {"lin2ulaw", (PyCFunction)audioop_lin2ulaw, METH_VARARGS, audioop_lin2ulaw__doc__},
733
734static PyObject *
735audioop_lin2ulaw_impl(PyModuleDef *module, Py_buffer *fragment, int width);
736
737static PyObject *
738audioop_lin2ulaw(PyModuleDef *module, PyObject *args)
739{
740 PyObject *return_value = NULL;
741 Py_buffer fragment = {NULL, NULL};
742 int width;
743
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300744 if (!PyArg_ParseTuple(args, "y*i:lin2ulaw",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300745 &fragment, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200746 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300747 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200748 return_value = audioop_lin2ulaw_impl(module, &fragment, width);
749
750exit:
751 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300752 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200753 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300754 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200755
756 return return_value;
757}
758
759PyDoc_STRVAR(audioop_ulaw2lin__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800760"ulaw2lin($module, fragment, width, /)\n"
761"--\n"
762"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200763"Convert sound fragments in u-LAW encoding to linearly encoded sound fragments.");
764
765#define AUDIOOP_ULAW2LIN_METHODDEF \
766 {"ulaw2lin", (PyCFunction)audioop_ulaw2lin, METH_VARARGS, audioop_ulaw2lin__doc__},
767
768static PyObject *
769audioop_ulaw2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width);
770
771static PyObject *
772audioop_ulaw2lin(PyModuleDef *module, PyObject *args)
773{
774 PyObject *return_value = NULL;
775 Py_buffer fragment = {NULL, NULL};
776 int width;
777
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300778 if (!PyArg_ParseTuple(args, "y*i:ulaw2lin",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300779 &fragment, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200780 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300781 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200782 return_value = audioop_ulaw2lin_impl(module, &fragment, width);
783
784exit:
785 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300786 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200787 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300788 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200789
790 return return_value;
791}
792
793PyDoc_STRVAR(audioop_lin2alaw__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800794"lin2alaw($module, fragment, width, /)\n"
795"--\n"
796"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200797"Convert samples in the audio fragment to a-LAW encoding.");
798
799#define AUDIOOP_LIN2ALAW_METHODDEF \
800 {"lin2alaw", (PyCFunction)audioop_lin2alaw, METH_VARARGS, audioop_lin2alaw__doc__},
801
802static PyObject *
803audioop_lin2alaw_impl(PyModuleDef *module, Py_buffer *fragment, int width);
804
805static PyObject *
806audioop_lin2alaw(PyModuleDef *module, PyObject *args)
807{
808 PyObject *return_value = NULL;
809 Py_buffer fragment = {NULL, NULL};
810 int width;
811
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300812 if (!PyArg_ParseTuple(args, "y*i:lin2alaw",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300813 &fragment, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200814 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300815 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200816 return_value = audioop_lin2alaw_impl(module, &fragment, width);
817
818exit:
819 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300820 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200821 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300822 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200823
824 return return_value;
825}
826
827PyDoc_STRVAR(audioop_alaw2lin__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800828"alaw2lin($module, fragment, width, /)\n"
829"--\n"
830"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200831"Convert sound fragments in a-LAW encoding to linearly encoded sound fragments.");
832
833#define AUDIOOP_ALAW2LIN_METHODDEF \
834 {"alaw2lin", (PyCFunction)audioop_alaw2lin, METH_VARARGS, audioop_alaw2lin__doc__},
835
836static PyObject *
837audioop_alaw2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width);
838
839static PyObject *
840audioop_alaw2lin(PyModuleDef *module, PyObject *args)
841{
842 PyObject *return_value = NULL;
843 Py_buffer fragment = {NULL, NULL};
844 int width;
845
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300846 if (!PyArg_ParseTuple(args, "y*i:alaw2lin",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300847 &fragment, &width)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200848 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300849 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200850 return_value = audioop_alaw2lin_impl(module, &fragment, width);
851
852exit:
853 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300854 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200855 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300856 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200857
858 return return_value;
859}
860
861PyDoc_STRVAR(audioop_lin2adpcm__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800862"lin2adpcm($module, fragment, width, state, /)\n"
863"--\n"
864"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200865"Convert samples to 4 bit Intel/DVI ADPCM encoding.");
866
867#define AUDIOOP_LIN2ADPCM_METHODDEF \
868 {"lin2adpcm", (PyCFunction)audioop_lin2adpcm, METH_VARARGS, audioop_lin2adpcm__doc__},
869
870static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400871audioop_lin2adpcm_impl(PyModuleDef *module, Py_buffer *fragment, int width,
872 PyObject *state);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200873
874static PyObject *
875audioop_lin2adpcm(PyModuleDef *module, PyObject *args)
876{
877 PyObject *return_value = NULL;
878 Py_buffer fragment = {NULL, NULL};
879 int width;
880 PyObject *state;
881
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300882 if (!PyArg_ParseTuple(args, "y*iO:lin2adpcm",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300883 &fragment, &width, &state)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200884 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300885 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200886 return_value = audioop_lin2adpcm_impl(module, &fragment, width, state);
887
888exit:
889 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300890 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200891 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300892 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200893
894 return return_value;
895}
896
897PyDoc_STRVAR(audioop_adpcm2lin__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800898"adpcm2lin($module, fragment, width, state, /)\n"
899"--\n"
900"\n"
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200901"Decode an Intel/DVI ADPCM coded fragment to a linear fragment.");
902
903#define AUDIOOP_ADPCM2LIN_METHODDEF \
904 {"adpcm2lin", (PyCFunction)audioop_adpcm2lin, METH_VARARGS, audioop_adpcm2lin__doc__},
905
906static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400907audioop_adpcm2lin_impl(PyModuleDef *module, Py_buffer *fragment, int width,
908 PyObject *state);
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200909
910static PyObject *
911audioop_adpcm2lin(PyModuleDef *module, PyObject *args)
912{
913 PyObject *return_value = NULL;
914 Py_buffer fragment = {NULL, NULL};
915 int width;
916 PyObject *state;
917
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300918 if (!PyArg_ParseTuple(args, "y*iO:adpcm2lin",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300919 &fragment, &width, &state)) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200920 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300921 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200922 return_value = audioop_adpcm2lin_impl(module, &fragment, width, state);
923
924exit:
925 /* Cleanup for fragment */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300926 if (fragment.obj) {
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200927 PyBuffer_Release(&fragment);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300928 }
Serhiy Storchaka8d00d732014-01-25 11:57:59 +0200929
930 return return_value;
931}
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300932/*[clinic end generated code: output=af5b025f0241fee2 input=a9049054013a1b77]*/