LCOV - code coverage report
Current view: top level - Modules/clinic - audioop.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 0 555 0.0 %
Date: 2023-03-20 08:15:36 Functions: 0 26 0.0 %
Branches: 0 496 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*[clinic input]
       2                 :            : preserve
       3                 :            : [clinic start generated code]*/
       4                 :            : 
       5                 :            : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
       6                 :            : #  include "pycore_gc.h"            // PyGC_Head
       7                 :            : #  include "pycore_runtime.h"       // _Py_ID()
       8                 :            : #endif
       9                 :            : 
      10                 :            : 
      11                 :            : PyDoc_STRVAR(audioop_getsample__doc__,
      12                 :            : "getsample($module, fragment, width, index, /)\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Return the value of sample index from the fragment.");
      16                 :            : 
      17                 :            : #define AUDIOOP_GETSAMPLE_METHODDEF    \
      18                 :            :     {"getsample", _PyCFunction_CAST(audioop_getsample), METH_FASTCALL, audioop_getsample__doc__},
      19                 :            : 
      20                 :            : static PyObject *
      21                 :            : audioop_getsample_impl(PyObject *module, Py_buffer *fragment, int width,
      22                 :            :                        Py_ssize_t index);
      23                 :            : 
      24                 :            : static PyObject *
      25                 :          0 : audioop_getsample(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
      26                 :            : {
      27                 :          0 :     PyObject *return_value = NULL;
      28                 :          0 :     Py_buffer fragment = {NULL, NULL};
      29                 :            :     int width;
      30                 :            :     Py_ssize_t index;
      31                 :            : 
      32   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("getsample", nargs, 3, 3)) {
                   #  # ]
      33                 :          0 :         goto exit;
      34                 :            :     }
      35         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
      36                 :          0 :         goto exit;
      37                 :            :     }
      38         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
      39                 :          0 :         _PyArg_BadArgument("getsample", "argument 1", "contiguous buffer", args[0]);
      40                 :          0 :         goto exit;
      41                 :            :     }
      42                 :          0 :     width = _PyLong_AsInt(args[1]);
      43   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
      44                 :          0 :         goto exit;
      45                 :            :     }
      46                 :            :     {
      47                 :          0 :         Py_ssize_t ival = -1;
      48                 :          0 :         PyObject *iobj = _PyNumber_Index(args[2]);
      49         [ #  # ]:          0 :         if (iobj != NULL) {
      50                 :          0 :             ival = PyLong_AsSsize_t(iobj);
      51                 :          0 :             Py_DECREF(iobj);
      52                 :            :         }
      53   [ #  #  #  # ]:          0 :         if (ival == -1 && PyErr_Occurred()) {
      54                 :          0 :             goto exit;
      55                 :            :         }
      56                 :          0 :         index = ival;
      57                 :            :     }
      58                 :          0 :     return_value = audioop_getsample_impl(module, &fragment, width, index);
      59                 :            : 
      60                 :          0 : exit:
      61                 :            :     /* Cleanup for fragment */
      62         [ #  # ]:          0 :     if (fragment.obj) {
      63                 :          0 :        PyBuffer_Release(&fragment);
      64                 :            :     }
      65                 :            : 
      66                 :          0 :     return return_value;
      67                 :            : }
      68                 :            : 
      69                 :            : PyDoc_STRVAR(audioop_max__doc__,
      70                 :            : "max($module, fragment, width, /)\n"
      71                 :            : "--\n"
      72                 :            : "\n"
      73                 :            : "Return the maximum of the absolute value of all samples in a fragment.");
      74                 :            : 
      75                 :            : #define AUDIOOP_MAX_METHODDEF    \
      76                 :            :     {"max", _PyCFunction_CAST(audioop_max), METH_FASTCALL, audioop_max__doc__},
      77                 :            : 
      78                 :            : static PyObject *
      79                 :            : audioop_max_impl(PyObject *module, Py_buffer *fragment, int width);
      80                 :            : 
      81                 :            : static PyObject *
      82                 :          0 : audioop_max(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
      83                 :            : {
      84                 :          0 :     PyObject *return_value = NULL;
      85                 :          0 :     Py_buffer fragment = {NULL, NULL};
      86                 :            :     int width;
      87                 :            : 
      88   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("max", nargs, 2, 2)) {
                   #  # ]
      89                 :          0 :         goto exit;
      90                 :            :     }
      91         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
      92                 :          0 :         goto exit;
      93                 :            :     }
      94         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
      95                 :          0 :         _PyArg_BadArgument("max", "argument 1", "contiguous buffer", args[0]);
      96                 :          0 :         goto exit;
      97                 :            :     }
      98                 :          0 :     width = _PyLong_AsInt(args[1]);
      99   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     100                 :          0 :         goto exit;
     101                 :            :     }
     102                 :          0 :     return_value = audioop_max_impl(module, &fragment, width);
     103                 :            : 
     104                 :          0 : exit:
     105                 :            :     /* Cleanup for fragment */
     106         [ #  # ]:          0 :     if (fragment.obj) {
     107                 :          0 :        PyBuffer_Release(&fragment);
     108                 :            :     }
     109                 :            : 
     110                 :          0 :     return return_value;
     111                 :            : }
     112                 :            : 
     113                 :            : PyDoc_STRVAR(audioop_minmax__doc__,
     114                 :            : "minmax($module, fragment, width, /)\n"
     115                 :            : "--\n"
     116                 :            : "\n"
     117                 :            : "Return the minimum and maximum values of all samples in the sound fragment.");
     118                 :            : 
     119                 :            : #define AUDIOOP_MINMAX_METHODDEF    \
     120                 :            :     {"minmax", _PyCFunction_CAST(audioop_minmax), METH_FASTCALL, audioop_minmax__doc__},
     121                 :            : 
     122                 :            : static PyObject *
     123                 :            : audioop_minmax_impl(PyObject *module, Py_buffer *fragment, int width);
     124                 :            : 
     125                 :            : static PyObject *
     126                 :          0 : audioop_minmax(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     127                 :            : {
     128                 :          0 :     PyObject *return_value = NULL;
     129                 :          0 :     Py_buffer fragment = {NULL, NULL};
     130                 :            :     int width;
     131                 :            : 
     132   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("minmax", nargs, 2, 2)) {
                   #  # ]
     133                 :          0 :         goto exit;
     134                 :            :     }
     135         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     136                 :          0 :         goto exit;
     137                 :            :     }
     138         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     139                 :          0 :         _PyArg_BadArgument("minmax", "argument 1", "contiguous buffer", args[0]);
     140                 :          0 :         goto exit;
     141                 :            :     }
     142                 :          0 :     width = _PyLong_AsInt(args[1]);
     143   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     144                 :          0 :         goto exit;
     145                 :            :     }
     146                 :          0 :     return_value = audioop_minmax_impl(module, &fragment, width);
     147                 :            : 
     148                 :          0 : exit:
     149                 :            :     /* Cleanup for fragment */
     150         [ #  # ]:          0 :     if (fragment.obj) {
     151                 :          0 :        PyBuffer_Release(&fragment);
     152                 :            :     }
     153                 :            : 
     154                 :          0 :     return return_value;
     155                 :            : }
     156                 :            : 
     157                 :            : PyDoc_STRVAR(audioop_avg__doc__,
     158                 :            : "avg($module, fragment, width, /)\n"
     159                 :            : "--\n"
     160                 :            : "\n"
     161                 :            : "Return the average over all samples in the fragment.");
     162                 :            : 
     163                 :            : #define AUDIOOP_AVG_METHODDEF    \
     164                 :            :     {"avg", _PyCFunction_CAST(audioop_avg), METH_FASTCALL, audioop_avg__doc__},
     165                 :            : 
     166                 :            : static PyObject *
     167                 :            : audioop_avg_impl(PyObject *module, Py_buffer *fragment, int width);
     168                 :            : 
     169                 :            : static PyObject *
     170                 :          0 : audioop_avg(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     171                 :            : {
     172                 :          0 :     PyObject *return_value = NULL;
     173                 :          0 :     Py_buffer fragment = {NULL, NULL};
     174                 :            :     int width;
     175                 :            : 
     176   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("avg", nargs, 2, 2)) {
                   #  # ]
     177                 :          0 :         goto exit;
     178                 :            :     }
     179         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     180                 :          0 :         goto exit;
     181                 :            :     }
     182         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     183                 :          0 :         _PyArg_BadArgument("avg", "argument 1", "contiguous buffer", args[0]);
     184                 :          0 :         goto exit;
     185                 :            :     }
     186                 :          0 :     width = _PyLong_AsInt(args[1]);
     187   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     188                 :          0 :         goto exit;
     189                 :            :     }
     190                 :          0 :     return_value = audioop_avg_impl(module, &fragment, width);
     191                 :            : 
     192                 :          0 : exit:
     193                 :            :     /* Cleanup for fragment */
     194         [ #  # ]:          0 :     if (fragment.obj) {
     195                 :          0 :        PyBuffer_Release(&fragment);
     196                 :            :     }
     197                 :            : 
     198                 :          0 :     return return_value;
     199                 :            : }
     200                 :            : 
     201                 :            : PyDoc_STRVAR(audioop_rms__doc__,
     202                 :            : "rms($module, fragment, width, /)\n"
     203                 :            : "--\n"
     204                 :            : "\n"
     205                 :            : "Return the root-mean-square of the fragment, i.e. sqrt(sum(S_i^2)/n).");
     206                 :            : 
     207                 :            : #define AUDIOOP_RMS_METHODDEF    \
     208                 :            :     {"rms", _PyCFunction_CAST(audioop_rms), METH_FASTCALL, audioop_rms__doc__},
     209                 :            : 
     210                 :            : static PyObject *
     211                 :            : audioop_rms_impl(PyObject *module, Py_buffer *fragment, int width);
     212                 :            : 
     213                 :            : static PyObject *
     214                 :          0 : audioop_rms(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     215                 :            : {
     216                 :          0 :     PyObject *return_value = NULL;
     217                 :          0 :     Py_buffer fragment = {NULL, NULL};
     218                 :            :     int width;
     219                 :            : 
     220   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("rms", nargs, 2, 2)) {
                   #  # ]
     221                 :          0 :         goto exit;
     222                 :            :     }
     223         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     224                 :          0 :         goto exit;
     225                 :            :     }
     226         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     227                 :          0 :         _PyArg_BadArgument("rms", "argument 1", "contiguous buffer", args[0]);
     228                 :          0 :         goto exit;
     229                 :            :     }
     230                 :          0 :     width = _PyLong_AsInt(args[1]);
     231   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     232                 :          0 :         goto exit;
     233                 :            :     }
     234                 :          0 :     return_value = audioop_rms_impl(module, &fragment, width);
     235                 :            : 
     236                 :          0 : exit:
     237                 :            :     /* Cleanup for fragment */
     238         [ #  # ]:          0 :     if (fragment.obj) {
     239                 :          0 :        PyBuffer_Release(&fragment);
     240                 :            :     }
     241                 :            : 
     242                 :          0 :     return return_value;
     243                 :            : }
     244                 :            : 
     245                 :            : PyDoc_STRVAR(audioop_findfit__doc__,
     246                 :            : "findfit($module, fragment, reference, /)\n"
     247                 :            : "--\n"
     248                 :            : "\n"
     249                 :            : "Try to match reference as well as possible to a portion of fragment.");
     250                 :            : 
     251                 :            : #define AUDIOOP_FINDFIT_METHODDEF    \
     252                 :            :     {"findfit", _PyCFunction_CAST(audioop_findfit), METH_FASTCALL, audioop_findfit__doc__},
     253                 :            : 
     254                 :            : static PyObject *
     255                 :            : audioop_findfit_impl(PyObject *module, Py_buffer *fragment,
     256                 :            :                      Py_buffer *reference);
     257                 :            : 
     258                 :            : static PyObject *
     259                 :          0 : audioop_findfit(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     260                 :            : {
     261                 :          0 :     PyObject *return_value = NULL;
     262                 :          0 :     Py_buffer fragment = {NULL, NULL};
     263                 :          0 :     Py_buffer reference = {NULL, NULL};
     264                 :            : 
     265   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("findfit", nargs, 2, 2)) {
                   #  # ]
     266                 :          0 :         goto exit;
     267                 :            :     }
     268         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     269                 :          0 :         goto exit;
     270                 :            :     }
     271         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     272                 :          0 :         _PyArg_BadArgument("findfit", "argument 1", "contiguous buffer", args[0]);
     273                 :          0 :         goto exit;
     274                 :            :     }
     275         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[1], &reference, PyBUF_SIMPLE) != 0) {
     276                 :          0 :         goto exit;
     277                 :            :     }
     278         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&reference, 'C')) {
     279                 :          0 :         _PyArg_BadArgument("findfit", "argument 2", "contiguous buffer", args[1]);
     280                 :          0 :         goto exit;
     281                 :            :     }
     282                 :          0 :     return_value = audioop_findfit_impl(module, &fragment, &reference);
     283                 :            : 
     284                 :          0 : exit:
     285                 :            :     /* Cleanup for fragment */
     286         [ #  # ]:          0 :     if (fragment.obj) {
     287                 :          0 :        PyBuffer_Release(&fragment);
     288                 :            :     }
     289                 :            :     /* Cleanup for reference */
     290         [ #  # ]:          0 :     if (reference.obj) {
     291                 :          0 :        PyBuffer_Release(&reference);
     292                 :            :     }
     293                 :            : 
     294                 :          0 :     return return_value;
     295                 :            : }
     296                 :            : 
     297                 :            : PyDoc_STRVAR(audioop_findfactor__doc__,
     298                 :            : "findfactor($module, fragment, reference, /)\n"
     299                 :            : "--\n"
     300                 :            : "\n"
     301                 :            : "Return a factor F such that rms(add(fragment, mul(reference, -F))) is minimal.");
     302                 :            : 
     303                 :            : #define AUDIOOP_FINDFACTOR_METHODDEF    \
     304                 :            :     {"findfactor", _PyCFunction_CAST(audioop_findfactor), METH_FASTCALL, audioop_findfactor__doc__},
     305                 :            : 
     306                 :            : static PyObject *
     307                 :            : audioop_findfactor_impl(PyObject *module, Py_buffer *fragment,
     308                 :            :                         Py_buffer *reference);
     309                 :            : 
     310                 :            : static PyObject *
     311                 :          0 : audioop_findfactor(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     312                 :            : {
     313                 :          0 :     PyObject *return_value = NULL;
     314                 :          0 :     Py_buffer fragment = {NULL, NULL};
     315                 :          0 :     Py_buffer reference = {NULL, NULL};
     316                 :            : 
     317   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("findfactor", nargs, 2, 2)) {
                   #  # ]
     318                 :          0 :         goto exit;
     319                 :            :     }
     320         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     321                 :          0 :         goto exit;
     322                 :            :     }
     323         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     324                 :          0 :         _PyArg_BadArgument("findfactor", "argument 1", "contiguous buffer", args[0]);
     325                 :          0 :         goto exit;
     326                 :            :     }
     327         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[1], &reference, PyBUF_SIMPLE) != 0) {
     328                 :          0 :         goto exit;
     329                 :            :     }
     330         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&reference, 'C')) {
     331                 :          0 :         _PyArg_BadArgument("findfactor", "argument 2", "contiguous buffer", args[1]);
     332                 :          0 :         goto exit;
     333                 :            :     }
     334                 :          0 :     return_value = audioop_findfactor_impl(module, &fragment, &reference);
     335                 :            : 
     336                 :          0 : exit:
     337                 :            :     /* Cleanup for fragment */
     338         [ #  # ]:          0 :     if (fragment.obj) {
     339                 :          0 :        PyBuffer_Release(&fragment);
     340                 :            :     }
     341                 :            :     /* Cleanup for reference */
     342         [ #  # ]:          0 :     if (reference.obj) {
     343                 :          0 :        PyBuffer_Release(&reference);
     344                 :            :     }
     345                 :            : 
     346                 :          0 :     return return_value;
     347                 :            : }
     348                 :            : 
     349                 :            : PyDoc_STRVAR(audioop_findmax__doc__,
     350                 :            : "findmax($module, fragment, length, /)\n"
     351                 :            : "--\n"
     352                 :            : "\n"
     353                 :            : "Search fragment for a slice of specified number of samples with maximum energy.");
     354                 :            : 
     355                 :            : #define AUDIOOP_FINDMAX_METHODDEF    \
     356                 :            :     {"findmax", _PyCFunction_CAST(audioop_findmax), METH_FASTCALL, audioop_findmax__doc__},
     357                 :            : 
     358                 :            : static PyObject *
     359                 :            : audioop_findmax_impl(PyObject *module, Py_buffer *fragment,
     360                 :            :                      Py_ssize_t length);
     361                 :            : 
     362                 :            : static PyObject *
     363                 :          0 : audioop_findmax(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     364                 :            : {
     365                 :          0 :     PyObject *return_value = NULL;
     366                 :          0 :     Py_buffer fragment = {NULL, NULL};
     367                 :            :     Py_ssize_t length;
     368                 :            : 
     369   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("findmax", nargs, 2, 2)) {
                   #  # ]
     370                 :          0 :         goto exit;
     371                 :            :     }
     372         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     373                 :          0 :         goto exit;
     374                 :            :     }
     375         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     376                 :          0 :         _PyArg_BadArgument("findmax", "argument 1", "contiguous buffer", args[0]);
     377                 :          0 :         goto exit;
     378                 :            :     }
     379                 :            :     {
     380                 :          0 :         Py_ssize_t ival = -1;
     381                 :          0 :         PyObject *iobj = _PyNumber_Index(args[1]);
     382         [ #  # ]:          0 :         if (iobj != NULL) {
     383                 :          0 :             ival = PyLong_AsSsize_t(iobj);
     384                 :          0 :             Py_DECREF(iobj);
     385                 :            :         }
     386   [ #  #  #  # ]:          0 :         if (ival == -1 && PyErr_Occurred()) {
     387                 :          0 :             goto exit;
     388                 :            :         }
     389                 :          0 :         length = ival;
     390                 :            :     }
     391                 :          0 :     return_value = audioop_findmax_impl(module, &fragment, length);
     392                 :            : 
     393                 :          0 : exit:
     394                 :            :     /* Cleanup for fragment */
     395         [ #  # ]:          0 :     if (fragment.obj) {
     396                 :          0 :        PyBuffer_Release(&fragment);
     397                 :            :     }
     398                 :            : 
     399                 :          0 :     return return_value;
     400                 :            : }
     401                 :            : 
     402                 :            : PyDoc_STRVAR(audioop_avgpp__doc__,
     403                 :            : "avgpp($module, fragment, width, /)\n"
     404                 :            : "--\n"
     405                 :            : "\n"
     406                 :            : "Return the average peak-peak value over all samples in the fragment.");
     407                 :            : 
     408                 :            : #define AUDIOOP_AVGPP_METHODDEF    \
     409                 :            :     {"avgpp", _PyCFunction_CAST(audioop_avgpp), METH_FASTCALL, audioop_avgpp__doc__},
     410                 :            : 
     411                 :            : static PyObject *
     412                 :            : audioop_avgpp_impl(PyObject *module, Py_buffer *fragment, int width);
     413                 :            : 
     414                 :            : static PyObject *
     415                 :          0 : audioop_avgpp(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     416                 :            : {
     417                 :          0 :     PyObject *return_value = NULL;
     418                 :          0 :     Py_buffer fragment = {NULL, NULL};
     419                 :            :     int width;
     420                 :            : 
     421   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("avgpp", nargs, 2, 2)) {
                   #  # ]
     422                 :          0 :         goto exit;
     423                 :            :     }
     424         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     425                 :          0 :         goto exit;
     426                 :            :     }
     427         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     428                 :          0 :         _PyArg_BadArgument("avgpp", "argument 1", "contiguous buffer", args[0]);
     429                 :          0 :         goto exit;
     430                 :            :     }
     431                 :          0 :     width = _PyLong_AsInt(args[1]);
     432   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     433                 :          0 :         goto exit;
     434                 :            :     }
     435                 :          0 :     return_value = audioop_avgpp_impl(module, &fragment, width);
     436                 :            : 
     437                 :          0 : exit:
     438                 :            :     /* Cleanup for fragment */
     439         [ #  # ]:          0 :     if (fragment.obj) {
     440                 :          0 :        PyBuffer_Release(&fragment);
     441                 :            :     }
     442                 :            : 
     443                 :          0 :     return return_value;
     444                 :            : }
     445                 :            : 
     446                 :            : PyDoc_STRVAR(audioop_maxpp__doc__,
     447                 :            : "maxpp($module, fragment, width, /)\n"
     448                 :            : "--\n"
     449                 :            : "\n"
     450                 :            : "Return the maximum peak-peak value in the sound fragment.");
     451                 :            : 
     452                 :            : #define AUDIOOP_MAXPP_METHODDEF    \
     453                 :            :     {"maxpp", _PyCFunction_CAST(audioop_maxpp), METH_FASTCALL, audioop_maxpp__doc__},
     454                 :            : 
     455                 :            : static PyObject *
     456                 :            : audioop_maxpp_impl(PyObject *module, Py_buffer *fragment, int width);
     457                 :            : 
     458                 :            : static PyObject *
     459                 :          0 : audioop_maxpp(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     460                 :            : {
     461                 :          0 :     PyObject *return_value = NULL;
     462                 :          0 :     Py_buffer fragment = {NULL, NULL};
     463                 :            :     int width;
     464                 :            : 
     465   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("maxpp", nargs, 2, 2)) {
                   #  # ]
     466                 :          0 :         goto exit;
     467                 :            :     }
     468         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     469                 :          0 :         goto exit;
     470                 :            :     }
     471         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     472                 :          0 :         _PyArg_BadArgument("maxpp", "argument 1", "contiguous buffer", args[0]);
     473                 :          0 :         goto exit;
     474                 :            :     }
     475                 :          0 :     width = _PyLong_AsInt(args[1]);
     476   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     477                 :          0 :         goto exit;
     478                 :            :     }
     479                 :          0 :     return_value = audioop_maxpp_impl(module, &fragment, width);
     480                 :            : 
     481                 :          0 : exit:
     482                 :            :     /* Cleanup for fragment */
     483         [ #  # ]:          0 :     if (fragment.obj) {
     484                 :          0 :        PyBuffer_Release(&fragment);
     485                 :            :     }
     486                 :            : 
     487                 :          0 :     return return_value;
     488                 :            : }
     489                 :            : 
     490                 :            : PyDoc_STRVAR(audioop_cross__doc__,
     491                 :            : "cross($module, fragment, width, /)\n"
     492                 :            : "--\n"
     493                 :            : "\n"
     494                 :            : "Return the number of zero crossings in the fragment passed as an argument.");
     495                 :            : 
     496                 :            : #define AUDIOOP_CROSS_METHODDEF    \
     497                 :            :     {"cross", _PyCFunction_CAST(audioop_cross), METH_FASTCALL, audioop_cross__doc__},
     498                 :            : 
     499                 :            : static PyObject *
     500                 :            : audioop_cross_impl(PyObject *module, Py_buffer *fragment, int width);
     501                 :            : 
     502                 :            : static PyObject *
     503                 :          0 : audioop_cross(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     504                 :            : {
     505                 :          0 :     PyObject *return_value = NULL;
     506                 :          0 :     Py_buffer fragment = {NULL, NULL};
     507                 :            :     int width;
     508                 :            : 
     509   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("cross", nargs, 2, 2)) {
                   #  # ]
     510                 :          0 :         goto exit;
     511                 :            :     }
     512         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     513                 :          0 :         goto exit;
     514                 :            :     }
     515         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     516                 :          0 :         _PyArg_BadArgument("cross", "argument 1", "contiguous buffer", args[0]);
     517                 :          0 :         goto exit;
     518                 :            :     }
     519                 :          0 :     width = _PyLong_AsInt(args[1]);
     520   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     521                 :          0 :         goto exit;
     522                 :            :     }
     523                 :          0 :     return_value = audioop_cross_impl(module, &fragment, width);
     524                 :            : 
     525                 :          0 : exit:
     526                 :            :     /* Cleanup for fragment */
     527         [ #  # ]:          0 :     if (fragment.obj) {
     528                 :          0 :        PyBuffer_Release(&fragment);
     529                 :            :     }
     530                 :            : 
     531                 :          0 :     return return_value;
     532                 :            : }
     533                 :            : 
     534                 :            : PyDoc_STRVAR(audioop_mul__doc__,
     535                 :            : "mul($module, fragment, width, factor, /)\n"
     536                 :            : "--\n"
     537                 :            : "\n"
     538                 :            : "Return a fragment that has all samples in the original fragment multiplied by the floating-point value factor.");
     539                 :            : 
     540                 :            : #define AUDIOOP_MUL_METHODDEF    \
     541                 :            :     {"mul", _PyCFunction_CAST(audioop_mul), METH_FASTCALL, audioop_mul__doc__},
     542                 :            : 
     543                 :            : static PyObject *
     544                 :            : audioop_mul_impl(PyObject *module, Py_buffer *fragment, int width,
     545                 :            :                  double factor);
     546                 :            : 
     547                 :            : static PyObject *
     548                 :          0 : audioop_mul(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     549                 :            : {
     550                 :          0 :     PyObject *return_value = NULL;
     551                 :          0 :     Py_buffer fragment = {NULL, NULL};
     552                 :            :     int width;
     553                 :            :     double factor;
     554                 :            : 
     555   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("mul", nargs, 3, 3)) {
                   #  # ]
     556                 :          0 :         goto exit;
     557                 :            :     }
     558         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     559                 :          0 :         goto exit;
     560                 :            :     }
     561         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     562                 :          0 :         _PyArg_BadArgument("mul", "argument 1", "contiguous buffer", args[0]);
     563                 :          0 :         goto exit;
     564                 :            :     }
     565                 :          0 :     width = _PyLong_AsInt(args[1]);
     566   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     567                 :          0 :         goto exit;
     568                 :            :     }
     569         [ #  # ]:          0 :     if (PyFloat_CheckExact(args[2])) {
     570                 :          0 :         factor = PyFloat_AS_DOUBLE(args[2]);
     571                 :            :     }
     572                 :            :     else
     573                 :            :     {
     574                 :          0 :         factor = PyFloat_AsDouble(args[2]);
     575   [ #  #  #  # ]:          0 :         if (factor == -1.0 && PyErr_Occurred()) {
     576                 :          0 :             goto exit;
     577                 :            :         }
     578                 :            :     }
     579                 :          0 :     return_value = audioop_mul_impl(module, &fragment, width, factor);
     580                 :            : 
     581                 :          0 : exit:
     582                 :            :     /* Cleanup for fragment */
     583         [ #  # ]:          0 :     if (fragment.obj) {
     584                 :          0 :        PyBuffer_Release(&fragment);
     585                 :            :     }
     586                 :            : 
     587                 :          0 :     return return_value;
     588                 :            : }
     589                 :            : 
     590                 :            : PyDoc_STRVAR(audioop_tomono__doc__,
     591                 :            : "tomono($module, fragment, width, lfactor, rfactor, /)\n"
     592                 :            : "--\n"
     593                 :            : "\n"
     594                 :            : "Convert a stereo fragment to a mono fragment.");
     595                 :            : 
     596                 :            : #define AUDIOOP_TOMONO_METHODDEF    \
     597                 :            :     {"tomono", _PyCFunction_CAST(audioop_tomono), METH_FASTCALL, audioop_tomono__doc__},
     598                 :            : 
     599                 :            : static PyObject *
     600                 :            : audioop_tomono_impl(PyObject *module, Py_buffer *fragment, int width,
     601                 :            :                     double lfactor, double rfactor);
     602                 :            : 
     603                 :            : static PyObject *
     604                 :          0 : audioop_tomono(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     605                 :            : {
     606                 :          0 :     PyObject *return_value = NULL;
     607                 :          0 :     Py_buffer fragment = {NULL, NULL};
     608                 :            :     int width;
     609                 :            :     double lfactor;
     610                 :            :     double rfactor;
     611                 :            : 
     612   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("tomono", nargs, 4, 4)) {
                   #  # ]
     613                 :          0 :         goto exit;
     614                 :            :     }
     615         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     616                 :          0 :         goto exit;
     617                 :            :     }
     618         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     619                 :          0 :         _PyArg_BadArgument("tomono", "argument 1", "contiguous buffer", args[0]);
     620                 :          0 :         goto exit;
     621                 :            :     }
     622                 :          0 :     width = _PyLong_AsInt(args[1]);
     623   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     624                 :          0 :         goto exit;
     625                 :            :     }
     626         [ #  # ]:          0 :     if (PyFloat_CheckExact(args[2])) {
     627                 :          0 :         lfactor = PyFloat_AS_DOUBLE(args[2]);
     628                 :            :     }
     629                 :            :     else
     630                 :            :     {
     631                 :          0 :         lfactor = PyFloat_AsDouble(args[2]);
     632   [ #  #  #  # ]:          0 :         if (lfactor == -1.0 && PyErr_Occurred()) {
     633                 :          0 :             goto exit;
     634                 :            :         }
     635                 :            :     }
     636         [ #  # ]:          0 :     if (PyFloat_CheckExact(args[3])) {
     637                 :          0 :         rfactor = PyFloat_AS_DOUBLE(args[3]);
     638                 :            :     }
     639                 :            :     else
     640                 :            :     {
     641                 :          0 :         rfactor = PyFloat_AsDouble(args[3]);
     642   [ #  #  #  # ]:          0 :         if (rfactor == -1.0 && PyErr_Occurred()) {
     643                 :          0 :             goto exit;
     644                 :            :         }
     645                 :            :     }
     646                 :          0 :     return_value = audioop_tomono_impl(module, &fragment, width, lfactor, rfactor);
     647                 :            : 
     648                 :          0 : exit:
     649                 :            :     /* Cleanup for fragment */
     650         [ #  # ]:          0 :     if (fragment.obj) {
     651                 :          0 :        PyBuffer_Release(&fragment);
     652                 :            :     }
     653                 :            : 
     654                 :          0 :     return return_value;
     655                 :            : }
     656                 :            : 
     657                 :            : PyDoc_STRVAR(audioop_tostereo__doc__,
     658                 :            : "tostereo($module, fragment, width, lfactor, rfactor, /)\n"
     659                 :            : "--\n"
     660                 :            : "\n"
     661                 :            : "Generate a stereo fragment from a mono fragment.");
     662                 :            : 
     663                 :            : #define AUDIOOP_TOSTEREO_METHODDEF    \
     664                 :            :     {"tostereo", _PyCFunction_CAST(audioop_tostereo), METH_FASTCALL, audioop_tostereo__doc__},
     665                 :            : 
     666                 :            : static PyObject *
     667                 :            : audioop_tostereo_impl(PyObject *module, Py_buffer *fragment, int width,
     668                 :            :                       double lfactor, double rfactor);
     669                 :            : 
     670                 :            : static PyObject *
     671                 :          0 : audioop_tostereo(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     672                 :            : {
     673                 :          0 :     PyObject *return_value = NULL;
     674                 :          0 :     Py_buffer fragment = {NULL, NULL};
     675                 :            :     int width;
     676                 :            :     double lfactor;
     677                 :            :     double rfactor;
     678                 :            : 
     679   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("tostereo", nargs, 4, 4)) {
                   #  # ]
     680                 :          0 :         goto exit;
     681                 :            :     }
     682         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     683                 :          0 :         goto exit;
     684                 :            :     }
     685         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     686                 :          0 :         _PyArg_BadArgument("tostereo", "argument 1", "contiguous buffer", args[0]);
     687                 :          0 :         goto exit;
     688                 :            :     }
     689                 :          0 :     width = _PyLong_AsInt(args[1]);
     690   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     691                 :          0 :         goto exit;
     692                 :            :     }
     693         [ #  # ]:          0 :     if (PyFloat_CheckExact(args[2])) {
     694                 :          0 :         lfactor = PyFloat_AS_DOUBLE(args[2]);
     695                 :            :     }
     696                 :            :     else
     697                 :            :     {
     698                 :          0 :         lfactor = PyFloat_AsDouble(args[2]);
     699   [ #  #  #  # ]:          0 :         if (lfactor == -1.0 && PyErr_Occurred()) {
     700                 :          0 :             goto exit;
     701                 :            :         }
     702                 :            :     }
     703         [ #  # ]:          0 :     if (PyFloat_CheckExact(args[3])) {
     704                 :          0 :         rfactor = PyFloat_AS_DOUBLE(args[3]);
     705                 :            :     }
     706                 :            :     else
     707                 :            :     {
     708                 :          0 :         rfactor = PyFloat_AsDouble(args[3]);
     709   [ #  #  #  # ]:          0 :         if (rfactor == -1.0 && PyErr_Occurred()) {
     710                 :          0 :             goto exit;
     711                 :            :         }
     712                 :            :     }
     713                 :          0 :     return_value = audioop_tostereo_impl(module, &fragment, width, lfactor, rfactor);
     714                 :            : 
     715                 :          0 : exit:
     716                 :            :     /* Cleanup for fragment */
     717         [ #  # ]:          0 :     if (fragment.obj) {
     718                 :          0 :        PyBuffer_Release(&fragment);
     719                 :            :     }
     720                 :            : 
     721                 :          0 :     return return_value;
     722                 :            : }
     723                 :            : 
     724                 :            : PyDoc_STRVAR(audioop_add__doc__,
     725                 :            : "add($module, fragment1, fragment2, width, /)\n"
     726                 :            : "--\n"
     727                 :            : "\n"
     728                 :            : "Return a fragment which is the addition of the two samples passed as parameters.");
     729                 :            : 
     730                 :            : #define AUDIOOP_ADD_METHODDEF    \
     731                 :            :     {"add", _PyCFunction_CAST(audioop_add), METH_FASTCALL, audioop_add__doc__},
     732                 :            : 
     733                 :            : static PyObject *
     734                 :            : audioop_add_impl(PyObject *module, Py_buffer *fragment1,
     735                 :            :                  Py_buffer *fragment2, int width);
     736                 :            : 
     737                 :            : static PyObject *
     738                 :          0 : audioop_add(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     739                 :            : {
     740                 :          0 :     PyObject *return_value = NULL;
     741                 :          0 :     Py_buffer fragment1 = {NULL, NULL};
     742                 :          0 :     Py_buffer fragment2 = {NULL, NULL};
     743                 :            :     int width;
     744                 :            : 
     745   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("add", nargs, 3, 3)) {
                   #  # ]
     746                 :          0 :         goto exit;
     747                 :            :     }
     748         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment1, PyBUF_SIMPLE) != 0) {
     749                 :          0 :         goto exit;
     750                 :            :     }
     751         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment1, 'C')) {
     752                 :          0 :         _PyArg_BadArgument("add", "argument 1", "contiguous buffer", args[0]);
     753                 :          0 :         goto exit;
     754                 :            :     }
     755         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[1], &fragment2, PyBUF_SIMPLE) != 0) {
     756                 :          0 :         goto exit;
     757                 :            :     }
     758         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment2, 'C')) {
     759                 :          0 :         _PyArg_BadArgument("add", "argument 2", "contiguous buffer", args[1]);
     760                 :          0 :         goto exit;
     761                 :            :     }
     762                 :          0 :     width = _PyLong_AsInt(args[2]);
     763   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     764                 :          0 :         goto exit;
     765                 :            :     }
     766                 :          0 :     return_value = audioop_add_impl(module, &fragment1, &fragment2, width);
     767                 :            : 
     768                 :          0 : exit:
     769                 :            :     /* Cleanup for fragment1 */
     770         [ #  # ]:          0 :     if (fragment1.obj) {
     771                 :          0 :        PyBuffer_Release(&fragment1);
     772                 :            :     }
     773                 :            :     /* Cleanup for fragment2 */
     774         [ #  # ]:          0 :     if (fragment2.obj) {
     775                 :          0 :        PyBuffer_Release(&fragment2);
     776                 :            :     }
     777                 :            : 
     778                 :          0 :     return return_value;
     779                 :            : }
     780                 :            : 
     781                 :            : PyDoc_STRVAR(audioop_bias__doc__,
     782                 :            : "bias($module, fragment, width, bias, /)\n"
     783                 :            : "--\n"
     784                 :            : "\n"
     785                 :            : "Return a fragment that is the original fragment with a bias added to each sample.");
     786                 :            : 
     787                 :            : #define AUDIOOP_BIAS_METHODDEF    \
     788                 :            :     {"bias", _PyCFunction_CAST(audioop_bias), METH_FASTCALL, audioop_bias__doc__},
     789                 :            : 
     790                 :            : static PyObject *
     791                 :            : audioop_bias_impl(PyObject *module, Py_buffer *fragment, int width, int bias);
     792                 :            : 
     793                 :            : static PyObject *
     794                 :          0 : audioop_bias(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     795                 :            : {
     796                 :          0 :     PyObject *return_value = NULL;
     797                 :          0 :     Py_buffer fragment = {NULL, NULL};
     798                 :            :     int width;
     799                 :            :     int bias;
     800                 :            : 
     801   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("bias", nargs, 3, 3)) {
                   #  # ]
     802                 :          0 :         goto exit;
     803                 :            :     }
     804         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     805                 :          0 :         goto exit;
     806                 :            :     }
     807         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     808                 :          0 :         _PyArg_BadArgument("bias", "argument 1", "contiguous buffer", args[0]);
     809                 :          0 :         goto exit;
     810                 :            :     }
     811                 :          0 :     width = _PyLong_AsInt(args[1]);
     812   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     813                 :          0 :         goto exit;
     814                 :            :     }
     815                 :          0 :     bias = _PyLong_AsInt(args[2]);
     816   [ #  #  #  # ]:          0 :     if (bias == -1 && PyErr_Occurred()) {
     817                 :          0 :         goto exit;
     818                 :            :     }
     819                 :          0 :     return_value = audioop_bias_impl(module, &fragment, width, bias);
     820                 :            : 
     821                 :          0 : exit:
     822                 :            :     /* Cleanup for fragment */
     823         [ #  # ]:          0 :     if (fragment.obj) {
     824                 :          0 :        PyBuffer_Release(&fragment);
     825                 :            :     }
     826                 :            : 
     827                 :          0 :     return return_value;
     828                 :            : }
     829                 :            : 
     830                 :            : PyDoc_STRVAR(audioop_reverse__doc__,
     831                 :            : "reverse($module, fragment, width, /)\n"
     832                 :            : "--\n"
     833                 :            : "\n"
     834                 :            : "Reverse the samples in a fragment and returns the modified fragment.");
     835                 :            : 
     836                 :            : #define AUDIOOP_REVERSE_METHODDEF    \
     837                 :            :     {"reverse", _PyCFunction_CAST(audioop_reverse), METH_FASTCALL, audioop_reverse__doc__},
     838                 :            : 
     839                 :            : static PyObject *
     840                 :            : audioop_reverse_impl(PyObject *module, Py_buffer *fragment, int width);
     841                 :            : 
     842                 :            : static PyObject *
     843                 :          0 : audioop_reverse(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     844                 :            : {
     845                 :          0 :     PyObject *return_value = NULL;
     846                 :          0 :     Py_buffer fragment = {NULL, NULL};
     847                 :            :     int width;
     848                 :            : 
     849   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("reverse", nargs, 2, 2)) {
                   #  # ]
     850                 :          0 :         goto exit;
     851                 :            :     }
     852         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     853                 :          0 :         goto exit;
     854                 :            :     }
     855         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     856                 :          0 :         _PyArg_BadArgument("reverse", "argument 1", "contiguous buffer", args[0]);
     857                 :          0 :         goto exit;
     858                 :            :     }
     859                 :          0 :     width = _PyLong_AsInt(args[1]);
     860   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     861                 :          0 :         goto exit;
     862                 :            :     }
     863                 :          0 :     return_value = audioop_reverse_impl(module, &fragment, width);
     864                 :            : 
     865                 :          0 : exit:
     866                 :            :     /* Cleanup for fragment */
     867         [ #  # ]:          0 :     if (fragment.obj) {
     868                 :          0 :        PyBuffer_Release(&fragment);
     869                 :            :     }
     870                 :            : 
     871                 :          0 :     return return_value;
     872                 :            : }
     873                 :            : 
     874                 :            : PyDoc_STRVAR(audioop_byteswap__doc__,
     875                 :            : "byteswap($module, fragment, width, /)\n"
     876                 :            : "--\n"
     877                 :            : "\n"
     878                 :            : "Convert big-endian samples to little-endian and vice versa.");
     879                 :            : 
     880                 :            : #define AUDIOOP_BYTESWAP_METHODDEF    \
     881                 :            :     {"byteswap", _PyCFunction_CAST(audioop_byteswap), METH_FASTCALL, audioop_byteswap__doc__},
     882                 :            : 
     883                 :            : static PyObject *
     884                 :            : audioop_byteswap_impl(PyObject *module, Py_buffer *fragment, int width);
     885                 :            : 
     886                 :            : static PyObject *
     887                 :          0 : audioop_byteswap(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     888                 :            : {
     889                 :          0 :     PyObject *return_value = NULL;
     890                 :          0 :     Py_buffer fragment = {NULL, NULL};
     891                 :            :     int width;
     892                 :            : 
     893   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("byteswap", nargs, 2, 2)) {
                   #  # ]
     894                 :          0 :         goto exit;
     895                 :            :     }
     896         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     897                 :          0 :         goto exit;
     898                 :            :     }
     899         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     900                 :          0 :         _PyArg_BadArgument("byteswap", "argument 1", "contiguous buffer", args[0]);
     901                 :          0 :         goto exit;
     902                 :            :     }
     903                 :          0 :     width = _PyLong_AsInt(args[1]);
     904   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     905                 :          0 :         goto exit;
     906                 :            :     }
     907                 :          0 :     return_value = audioop_byteswap_impl(module, &fragment, width);
     908                 :            : 
     909                 :          0 : exit:
     910                 :            :     /* Cleanup for fragment */
     911         [ #  # ]:          0 :     if (fragment.obj) {
     912                 :          0 :        PyBuffer_Release(&fragment);
     913                 :            :     }
     914                 :            : 
     915                 :          0 :     return return_value;
     916                 :            : }
     917                 :            : 
     918                 :            : PyDoc_STRVAR(audioop_lin2lin__doc__,
     919                 :            : "lin2lin($module, fragment, width, newwidth, /)\n"
     920                 :            : "--\n"
     921                 :            : "\n"
     922                 :            : "Convert samples between 1-, 2-, 3- and 4-byte formats.");
     923                 :            : 
     924                 :            : #define AUDIOOP_LIN2LIN_METHODDEF    \
     925                 :            :     {"lin2lin", _PyCFunction_CAST(audioop_lin2lin), METH_FASTCALL, audioop_lin2lin__doc__},
     926                 :            : 
     927                 :            : static PyObject *
     928                 :            : audioop_lin2lin_impl(PyObject *module, Py_buffer *fragment, int width,
     929                 :            :                      int newwidth);
     930                 :            : 
     931                 :            : static PyObject *
     932                 :          0 : audioop_lin2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     933                 :            : {
     934                 :          0 :     PyObject *return_value = NULL;
     935                 :          0 :     Py_buffer fragment = {NULL, NULL};
     936                 :            :     int width;
     937                 :            :     int newwidth;
     938                 :            : 
     939   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("lin2lin", nargs, 3, 3)) {
                   #  # ]
     940                 :          0 :         goto exit;
     941                 :            :     }
     942         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
     943                 :          0 :         goto exit;
     944                 :            :     }
     945         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
     946                 :          0 :         _PyArg_BadArgument("lin2lin", "argument 1", "contiguous buffer", args[0]);
     947                 :          0 :         goto exit;
     948                 :            :     }
     949                 :          0 :     width = _PyLong_AsInt(args[1]);
     950   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
     951                 :          0 :         goto exit;
     952                 :            :     }
     953                 :          0 :     newwidth = _PyLong_AsInt(args[2]);
     954   [ #  #  #  # ]:          0 :     if (newwidth == -1 && PyErr_Occurred()) {
     955                 :          0 :         goto exit;
     956                 :            :     }
     957                 :          0 :     return_value = audioop_lin2lin_impl(module, &fragment, width, newwidth);
     958                 :            : 
     959                 :          0 : exit:
     960                 :            :     /* Cleanup for fragment */
     961         [ #  # ]:          0 :     if (fragment.obj) {
     962                 :          0 :        PyBuffer_Release(&fragment);
     963                 :            :     }
     964                 :            : 
     965                 :          0 :     return return_value;
     966                 :            : }
     967                 :            : 
     968                 :            : PyDoc_STRVAR(audioop_ratecv__doc__,
     969                 :            : "ratecv($module, fragment, width, nchannels, inrate, outrate, state,\n"
     970                 :            : "       weightA=1, weightB=0, /)\n"
     971                 :            : "--\n"
     972                 :            : "\n"
     973                 :            : "Convert the frame rate of the input fragment.");
     974                 :            : 
     975                 :            : #define AUDIOOP_RATECV_METHODDEF    \
     976                 :            :     {"ratecv", _PyCFunction_CAST(audioop_ratecv), METH_FASTCALL, audioop_ratecv__doc__},
     977                 :            : 
     978                 :            : static PyObject *
     979                 :            : audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width,
     980                 :            :                     int nchannels, int inrate, int outrate, PyObject *state,
     981                 :            :                     int weightA, int weightB);
     982                 :            : 
     983                 :            : static PyObject *
     984                 :          0 : audioop_ratecv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     985                 :            : {
     986                 :          0 :     PyObject *return_value = NULL;
     987                 :          0 :     Py_buffer fragment = {NULL, NULL};
     988                 :            :     int width;
     989                 :            :     int nchannels;
     990                 :            :     int inrate;
     991                 :            :     int outrate;
     992                 :            :     PyObject *state;
     993                 :          0 :     int weightA = 1;
     994                 :          0 :     int weightB = 0;
     995                 :            : 
     996   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("ratecv", nargs, 6, 8)) {
                   #  # ]
     997                 :          0 :         goto exit;
     998                 :            :     }
     999         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
    1000                 :          0 :         goto exit;
    1001                 :            :     }
    1002         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
    1003                 :          0 :         _PyArg_BadArgument("ratecv", "argument 1", "contiguous buffer", args[0]);
    1004                 :          0 :         goto exit;
    1005                 :            :     }
    1006                 :          0 :     width = _PyLong_AsInt(args[1]);
    1007   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
    1008                 :          0 :         goto exit;
    1009                 :            :     }
    1010                 :          0 :     nchannels = _PyLong_AsInt(args[2]);
    1011   [ #  #  #  # ]:          0 :     if (nchannels == -1 && PyErr_Occurred()) {
    1012                 :          0 :         goto exit;
    1013                 :            :     }
    1014                 :          0 :     inrate = _PyLong_AsInt(args[3]);
    1015   [ #  #  #  # ]:          0 :     if (inrate == -1 && PyErr_Occurred()) {
    1016                 :          0 :         goto exit;
    1017                 :            :     }
    1018                 :          0 :     outrate = _PyLong_AsInt(args[4]);
    1019   [ #  #  #  # ]:          0 :     if (outrate == -1 && PyErr_Occurred()) {
    1020                 :          0 :         goto exit;
    1021                 :            :     }
    1022                 :          0 :     state = args[5];
    1023         [ #  # ]:          0 :     if (nargs < 7) {
    1024                 :          0 :         goto skip_optional;
    1025                 :            :     }
    1026                 :          0 :     weightA = _PyLong_AsInt(args[6]);
    1027   [ #  #  #  # ]:          0 :     if (weightA == -1 && PyErr_Occurred()) {
    1028                 :          0 :         goto exit;
    1029                 :            :     }
    1030         [ #  # ]:          0 :     if (nargs < 8) {
    1031                 :          0 :         goto skip_optional;
    1032                 :            :     }
    1033                 :          0 :     weightB = _PyLong_AsInt(args[7]);
    1034   [ #  #  #  # ]:          0 :     if (weightB == -1 && PyErr_Occurred()) {
    1035                 :          0 :         goto exit;
    1036                 :            :     }
    1037                 :          0 : skip_optional:
    1038                 :          0 :     return_value = audioop_ratecv_impl(module, &fragment, width, nchannels, inrate, outrate, state, weightA, weightB);
    1039                 :            : 
    1040                 :          0 : exit:
    1041                 :            :     /* Cleanup for fragment */
    1042         [ #  # ]:          0 :     if (fragment.obj) {
    1043                 :          0 :        PyBuffer_Release(&fragment);
    1044                 :            :     }
    1045                 :            : 
    1046                 :          0 :     return return_value;
    1047                 :            : }
    1048                 :            : 
    1049                 :            : PyDoc_STRVAR(audioop_lin2ulaw__doc__,
    1050                 :            : "lin2ulaw($module, fragment, width, /)\n"
    1051                 :            : "--\n"
    1052                 :            : "\n"
    1053                 :            : "Convert samples in the audio fragment to u-LAW encoding.");
    1054                 :            : 
    1055                 :            : #define AUDIOOP_LIN2ULAW_METHODDEF    \
    1056                 :            :     {"lin2ulaw", _PyCFunction_CAST(audioop_lin2ulaw), METH_FASTCALL, audioop_lin2ulaw__doc__},
    1057                 :            : 
    1058                 :            : static PyObject *
    1059                 :            : audioop_lin2ulaw_impl(PyObject *module, Py_buffer *fragment, int width);
    1060                 :            : 
    1061                 :            : static PyObject *
    1062                 :          0 : audioop_lin2ulaw(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
    1063                 :            : {
    1064                 :          0 :     PyObject *return_value = NULL;
    1065                 :          0 :     Py_buffer fragment = {NULL, NULL};
    1066                 :            :     int width;
    1067                 :            : 
    1068   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("lin2ulaw", nargs, 2, 2)) {
                   #  # ]
    1069                 :          0 :         goto exit;
    1070                 :            :     }
    1071         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
    1072                 :          0 :         goto exit;
    1073                 :            :     }
    1074         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
    1075                 :          0 :         _PyArg_BadArgument("lin2ulaw", "argument 1", "contiguous buffer", args[0]);
    1076                 :          0 :         goto exit;
    1077                 :            :     }
    1078                 :          0 :     width = _PyLong_AsInt(args[1]);
    1079   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
    1080                 :          0 :         goto exit;
    1081                 :            :     }
    1082                 :          0 :     return_value = audioop_lin2ulaw_impl(module, &fragment, width);
    1083                 :            : 
    1084                 :          0 : exit:
    1085                 :            :     /* Cleanup for fragment */
    1086         [ #  # ]:          0 :     if (fragment.obj) {
    1087                 :          0 :        PyBuffer_Release(&fragment);
    1088                 :            :     }
    1089                 :            : 
    1090                 :          0 :     return return_value;
    1091                 :            : }
    1092                 :            : 
    1093                 :            : PyDoc_STRVAR(audioop_ulaw2lin__doc__,
    1094                 :            : "ulaw2lin($module, fragment, width, /)\n"
    1095                 :            : "--\n"
    1096                 :            : "\n"
    1097                 :            : "Convert sound fragments in u-LAW encoding to linearly encoded sound fragments.");
    1098                 :            : 
    1099                 :            : #define AUDIOOP_ULAW2LIN_METHODDEF    \
    1100                 :            :     {"ulaw2lin", _PyCFunction_CAST(audioop_ulaw2lin), METH_FASTCALL, audioop_ulaw2lin__doc__},
    1101                 :            : 
    1102                 :            : static PyObject *
    1103                 :            : audioop_ulaw2lin_impl(PyObject *module, Py_buffer *fragment, int width);
    1104                 :            : 
    1105                 :            : static PyObject *
    1106                 :          0 : audioop_ulaw2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
    1107                 :            : {
    1108                 :          0 :     PyObject *return_value = NULL;
    1109                 :          0 :     Py_buffer fragment = {NULL, NULL};
    1110                 :            :     int width;
    1111                 :            : 
    1112   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("ulaw2lin", nargs, 2, 2)) {
                   #  # ]
    1113                 :          0 :         goto exit;
    1114                 :            :     }
    1115         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
    1116                 :          0 :         goto exit;
    1117                 :            :     }
    1118         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
    1119                 :          0 :         _PyArg_BadArgument("ulaw2lin", "argument 1", "contiguous buffer", args[0]);
    1120                 :          0 :         goto exit;
    1121                 :            :     }
    1122                 :          0 :     width = _PyLong_AsInt(args[1]);
    1123   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
    1124                 :          0 :         goto exit;
    1125                 :            :     }
    1126                 :          0 :     return_value = audioop_ulaw2lin_impl(module, &fragment, width);
    1127                 :            : 
    1128                 :          0 : exit:
    1129                 :            :     /* Cleanup for fragment */
    1130         [ #  # ]:          0 :     if (fragment.obj) {
    1131                 :          0 :        PyBuffer_Release(&fragment);
    1132                 :            :     }
    1133                 :            : 
    1134                 :          0 :     return return_value;
    1135                 :            : }
    1136                 :            : 
    1137                 :            : PyDoc_STRVAR(audioop_lin2alaw__doc__,
    1138                 :            : "lin2alaw($module, fragment, width, /)\n"
    1139                 :            : "--\n"
    1140                 :            : "\n"
    1141                 :            : "Convert samples in the audio fragment to a-LAW encoding.");
    1142                 :            : 
    1143                 :            : #define AUDIOOP_LIN2ALAW_METHODDEF    \
    1144                 :            :     {"lin2alaw", _PyCFunction_CAST(audioop_lin2alaw), METH_FASTCALL, audioop_lin2alaw__doc__},
    1145                 :            : 
    1146                 :            : static PyObject *
    1147                 :            : audioop_lin2alaw_impl(PyObject *module, Py_buffer *fragment, int width);
    1148                 :            : 
    1149                 :            : static PyObject *
    1150                 :          0 : audioop_lin2alaw(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
    1151                 :            : {
    1152                 :          0 :     PyObject *return_value = NULL;
    1153                 :          0 :     Py_buffer fragment = {NULL, NULL};
    1154                 :            :     int width;
    1155                 :            : 
    1156   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("lin2alaw", nargs, 2, 2)) {
                   #  # ]
    1157                 :          0 :         goto exit;
    1158                 :            :     }
    1159         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
    1160                 :          0 :         goto exit;
    1161                 :            :     }
    1162         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
    1163                 :          0 :         _PyArg_BadArgument("lin2alaw", "argument 1", "contiguous buffer", args[0]);
    1164                 :          0 :         goto exit;
    1165                 :            :     }
    1166                 :          0 :     width = _PyLong_AsInt(args[1]);
    1167   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
    1168                 :          0 :         goto exit;
    1169                 :            :     }
    1170                 :          0 :     return_value = audioop_lin2alaw_impl(module, &fragment, width);
    1171                 :            : 
    1172                 :          0 : exit:
    1173                 :            :     /* Cleanup for fragment */
    1174         [ #  # ]:          0 :     if (fragment.obj) {
    1175                 :          0 :        PyBuffer_Release(&fragment);
    1176                 :            :     }
    1177                 :            : 
    1178                 :          0 :     return return_value;
    1179                 :            : }
    1180                 :            : 
    1181                 :            : PyDoc_STRVAR(audioop_alaw2lin__doc__,
    1182                 :            : "alaw2lin($module, fragment, width, /)\n"
    1183                 :            : "--\n"
    1184                 :            : "\n"
    1185                 :            : "Convert sound fragments in a-LAW encoding to linearly encoded sound fragments.");
    1186                 :            : 
    1187                 :            : #define AUDIOOP_ALAW2LIN_METHODDEF    \
    1188                 :            :     {"alaw2lin", _PyCFunction_CAST(audioop_alaw2lin), METH_FASTCALL, audioop_alaw2lin__doc__},
    1189                 :            : 
    1190                 :            : static PyObject *
    1191                 :            : audioop_alaw2lin_impl(PyObject *module, Py_buffer *fragment, int width);
    1192                 :            : 
    1193                 :            : static PyObject *
    1194                 :          0 : audioop_alaw2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
    1195                 :            : {
    1196                 :          0 :     PyObject *return_value = NULL;
    1197                 :          0 :     Py_buffer fragment = {NULL, NULL};
    1198                 :            :     int width;
    1199                 :            : 
    1200   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("alaw2lin", nargs, 2, 2)) {
                   #  # ]
    1201                 :          0 :         goto exit;
    1202                 :            :     }
    1203         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
    1204                 :          0 :         goto exit;
    1205                 :            :     }
    1206         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
    1207                 :          0 :         _PyArg_BadArgument("alaw2lin", "argument 1", "contiguous buffer", args[0]);
    1208                 :          0 :         goto exit;
    1209                 :            :     }
    1210                 :          0 :     width = _PyLong_AsInt(args[1]);
    1211   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
    1212                 :          0 :         goto exit;
    1213                 :            :     }
    1214                 :          0 :     return_value = audioop_alaw2lin_impl(module, &fragment, width);
    1215                 :            : 
    1216                 :          0 : exit:
    1217                 :            :     /* Cleanup for fragment */
    1218         [ #  # ]:          0 :     if (fragment.obj) {
    1219                 :          0 :        PyBuffer_Release(&fragment);
    1220                 :            :     }
    1221                 :            : 
    1222                 :          0 :     return return_value;
    1223                 :            : }
    1224                 :            : 
    1225                 :            : PyDoc_STRVAR(audioop_lin2adpcm__doc__,
    1226                 :            : "lin2adpcm($module, fragment, width, state, /)\n"
    1227                 :            : "--\n"
    1228                 :            : "\n"
    1229                 :            : "Convert samples to 4 bit Intel/DVI ADPCM encoding.");
    1230                 :            : 
    1231                 :            : #define AUDIOOP_LIN2ADPCM_METHODDEF    \
    1232                 :            :     {"lin2adpcm", _PyCFunction_CAST(audioop_lin2adpcm), METH_FASTCALL, audioop_lin2adpcm__doc__},
    1233                 :            : 
    1234                 :            : static PyObject *
    1235                 :            : audioop_lin2adpcm_impl(PyObject *module, Py_buffer *fragment, int width,
    1236                 :            :                        PyObject *state);
    1237                 :            : 
    1238                 :            : static PyObject *
    1239                 :          0 : audioop_lin2adpcm(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
    1240                 :            : {
    1241                 :          0 :     PyObject *return_value = NULL;
    1242                 :          0 :     Py_buffer fragment = {NULL, NULL};
    1243                 :            :     int width;
    1244                 :            :     PyObject *state;
    1245                 :            : 
    1246   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("lin2adpcm", nargs, 3, 3)) {
                   #  # ]
    1247                 :          0 :         goto exit;
    1248                 :            :     }
    1249         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
    1250                 :          0 :         goto exit;
    1251                 :            :     }
    1252         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
    1253                 :          0 :         _PyArg_BadArgument("lin2adpcm", "argument 1", "contiguous buffer", args[0]);
    1254                 :          0 :         goto exit;
    1255                 :            :     }
    1256                 :          0 :     width = _PyLong_AsInt(args[1]);
    1257   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
    1258                 :          0 :         goto exit;
    1259                 :            :     }
    1260                 :          0 :     state = args[2];
    1261                 :          0 :     return_value = audioop_lin2adpcm_impl(module, &fragment, width, state);
    1262                 :            : 
    1263                 :          0 : exit:
    1264                 :            :     /* Cleanup for fragment */
    1265         [ #  # ]:          0 :     if (fragment.obj) {
    1266                 :          0 :        PyBuffer_Release(&fragment);
    1267                 :            :     }
    1268                 :            : 
    1269                 :          0 :     return return_value;
    1270                 :            : }
    1271                 :            : 
    1272                 :            : PyDoc_STRVAR(audioop_adpcm2lin__doc__,
    1273                 :            : "adpcm2lin($module, fragment, width, state, /)\n"
    1274                 :            : "--\n"
    1275                 :            : "\n"
    1276                 :            : "Decode an Intel/DVI ADPCM coded fragment to a linear fragment.");
    1277                 :            : 
    1278                 :            : #define AUDIOOP_ADPCM2LIN_METHODDEF    \
    1279                 :            :     {"adpcm2lin", _PyCFunction_CAST(audioop_adpcm2lin), METH_FASTCALL, audioop_adpcm2lin__doc__},
    1280                 :            : 
    1281                 :            : static PyObject *
    1282                 :            : audioop_adpcm2lin_impl(PyObject *module, Py_buffer *fragment, int width,
    1283                 :            :                        PyObject *state);
    1284                 :            : 
    1285                 :            : static PyObject *
    1286                 :          0 : audioop_adpcm2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
    1287                 :            : {
    1288                 :          0 :     PyObject *return_value = NULL;
    1289                 :          0 :     Py_buffer fragment = {NULL, NULL};
    1290                 :            :     int width;
    1291                 :            :     PyObject *state;
    1292                 :            : 
    1293   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("adpcm2lin", nargs, 3, 3)) {
                   #  # ]
    1294                 :          0 :         goto exit;
    1295                 :            :     }
    1296         [ #  # ]:          0 :     if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
    1297                 :          0 :         goto exit;
    1298                 :            :     }
    1299         [ #  # ]:          0 :     if (!PyBuffer_IsContiguous(&fragment, 'C')) {
    1300                 :          0 :         _PyArg_BadArgument("adpcm2lin", "argument 1", "contiguous buffer", args[0]);
    1301                 :          0 :         goto exit;
    1302                 :            :     }
    1303                 :          0 :     width = _PyLong_AsInt(args[1]);
    1304   [ #  #  #  # ]:          0 :     if (width == -1 && PyErr_Occurred()) {
    1305                 :          0 :         goto exit;
    1306                 :            :     }
    1307                 :          0 :     state = args[2];
    1308                 :          0 :     return_value = audioop_adpcm2lin_impl(module, &fragment, width, state);
    1309                 :            : 
    1310                 :          0 : exit:
    1311                 :            :     /* Cleanup for fragment */
    1312         [ #  # ]:          0 :     if (fragment.obj) {
    1313                 :          0 :        PyBuffer_Release(&fragment);
    1314                 :            :     }
    1315                 :            : 
    1316                 :          0 :     return return_value;
    1317                 :            : }
    1318                 :            : /*[clinic end generated code: output=9a7e36f1179f0223 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14