[6f42c16] | 1 | #ifndef PY_AUBIO_MUSICUTILS_H |
---|
| 2 | #define PY_AUBIO_MUSICUTILS_H |
---|
[913a7f1] | 3 | |
---|
| 4 | static char Py_aubio_window_doc[] = "" |
---|
| 5 | "window(string, integer) -> fvec\n" |
---|
| 6 | "\n" |
---|
| 7 | "Create a window\n" |
---|
| 8 | "\n" |
---|
| 9 | "Example\n" |
---|
| 10 | "-------\n" |
---|
| 11 | "\n" |
---|
[efa62ce] | 12 | ">>> window('hanningz', 1024)\n" |
---|
| 13 | "array([ 0.00000000e+00, 9.41753387e-06, 3.76403332e-05, ...,\n" |
---|
| 14 | " 8.46982002e-05, 3.76403332e-05, 9.41753387e-06], dtype=float32)"; |
---|
[913a7f1] | 15 | |
---|
| 16 | PyObject * Py_aubio_window(PyObject *self, PyObject *args); |
---|
| 17 | |
---|
[665b711] | 18 | static char Py_aubio_level_lin_doc[] = "" |
---|
[0bb2d63] | 19 | "level_lin(x)\n" |
---|
[665b711] | 20 | "\n" |
---|
[0bb2d63] | 21 | "Compute sound pressure level of `x`, on a linear scale.\n" |
---|
[665b711] | 22 | "\n" |
---|
[0bb2d63] | 23 | "Parameters\n" |
---|
| 24 | "----------\n" |
---|
| 25 | "x : fvec\n" |
---|
| 26 | " input vector\n" |
---|
| 27 | "\n" |
---|
| 28 | "Returns\n" |
---|
| 29 | "-------\n" |
---|
| 30 | "float\n" |
---|
| 31 | " Linear level of `x`.\n" |
---|
[665b711] | 32 | "\n" |
---|
| 33 | "Example\n" |
---|
| 34 | "-------\n" |
---|
| 35 | "\n" |
---|
[0bb2d63] | 36 | ">>> aubio.level_lin(aubio.fvec(numpy.ones(1024)))\n" |
---|
| 37 | "1.0\n" |
---|
| 38 | "\n" |
---|
| 39 | "Note\n" |
---|
| 40 | "----\n" |
---|
| 41 | "Computed as the average of the squared amplitudes:\n" |
---|
| 42 | "\n" |
---|
| 43 | ".. math:: L = \\frac {\\sum_{n=0}^{N-1} {x_n}^2} {N}\n" |
---|
| 44 | "\n" |
---|
| 45 | "See Also\n" |
---|
| 46 | "--------\n" |
---|
| 47 | "db_spl, silence_detection, level_detection\n" |
---|
| 48 | ""; |
---|
[665b711] | 49 | |
---|
| 50 | PyObject * Py_aubio_level_lin(PyObject *self, PyObject *args); |
---|
| 51 | |
---|
| 52 | static char Py_aubio_db_spl_doc[] = "" |
---|
[0bb2d63] | 53 | "db_spl(x)\n" |
---|
[665b711] | 54 | "\n" |
---|
[0bb2d63] | 55 | "Compute Sound Pressure Level (SPL) of `x`, in dB.\n" |
---|
[665b711] | 56 | "\n" |
---|
[0bb2d63] | 57 | "Parameters\n" |
---|
| 58 | "----------\n" |
---|
| 59 | "x : fvec\n" |
---|
| 60 | " input vector\n" |
---|
| 61 | "\n" |
---|
| 62 | "Returns\n" |
---|
| 63 | "-------\n" |
---|
| 64 | "float\n" |
---|
| 65 | " Level of `x`, in dB SPL.\n" |
---|
[665b711] | 66 | "\n" |
---|
| 67 | "Example\n" |
---|
| 68 | "-------\n" |
---|
| 69 | "\n" |
---|
[0bb2d63] | 70 | ">>> aubio.db_spl(aubio.fvec(np.ones(1024)))\n" |
---|
| 71 | "1.0\n" |
---|
| 72 | ">>> aubio.db_spl(0.7*aubio.fvec(np.ones(32)))\n" |
---|
| 73 | "-3.098040819168091\n" |
---|
| 74 | "\n" |
---|
| 75 | "Note\n" |
---|
| 76 | "----\n" |
---|
| 77 | "Computed as `log10` of :py:func:`level_lin`:\n" |
---|
| 78 | "\n" |
---|
| 79 | ".. math::\n" |
---|
| 80 | "\n" |
---|
| 81 | " {SPL}_{dB} = log10{\\frac {\\sum_{n=0}^{N-1}{x_n}^2} {N}}\n" |
---|
| 82 | "\n" |
---|
| 83 | "This quantity is often incorrectly called 'loudness'.\n" |
---|
| 84 | "\n" |
---|
| 85 | "See Also\n" |
---|
| 86 | "--------\n" |
---|
| 87 | "level_lin, silence_detection, level_detection\n" |
---|
| 88 | ""; |
---|
[665b711] | 89 | |
---|
| 90 | PyObject * Py_aubio_db_spl(PyObject *self, PyObject *args); |
---|
| 91 | |
---|
[31a09d2] | 92 | static char Py_aubio_silence_detection_doc[] = "" |
---|
[0bb2d63] | 93 | "silence_detection(vec, level)\n" |
---|
[31a09d2] | 94 | "\n" |
---|
[0bb2d63] | 95 | "Check if level of `vec`, in dB SPL, is under a given threshold.\n" |
---|
[31a09d2] | 96 | "\n" |
---|
[0bb2d63] | 97 | "Parameters\n" |
---|
| 98 | "----------\n" |
---|
| 99 | "vec : fvec\n" |
---|
| 100 | " input vector\n" |
---|
| 101 | "level : float\n" |
---|
| 102 | " level threshold, in dB SPL\n" |
---|
[31a09d2] | 103 | "\n" |
---|
[0bb2d63] | 104 | "Returns\n" |
---|
| 105 | "-------\n" |
---|
| 106 | "int\n" |
---|
| 107 | " `1` if level of `vec`, in dB SPL, is under `level`,\n" |
---|
| 108 | " `0` otherwise.\n" |
---|
| 109 | "\n" |
---|
| 110 | "Examples\n" |
---|
| 111 | "--------\n" |
---|
| 112 | "\n" |
---|
| 113 | ">>> aubio.silence_detection(aubio.fvec(32), -100.)\n" |
---|
| 114 | "1\n" |
---|
| 115 | ">>> aubio.silence_detection(aubio.fvec(np.ones(32)), 0.)\n" |
---|
| 116 | "0\n" |
---|
| 117 | "\n" |
---|
| 118 | "See Also\n" |
---|
| 119 | "--------\n" |
---|
| 120 | "level_detection, db_spl, level_lin\n" |
---|
| 121 | ""; |
---|
[31a09d2] | 122 | |
---|
| 123 | PyObject * Py_aubio_silence_detection(PyObject *self, PyObject *args); |
---|
| 124 | |
---|
[9c8c8a6] | 125 | static char Py_aubio_level_detection_doc[] = "" |
---|
[0bb2d63] | 126 | "level_detection(vec, level)\n" |
---|
| 127 | "\n" |
---|
| 128 | "Check if `vec` is above threshold `level`, in dB SPL.\n" |
---|
| 129 | "\n" |
---|
| 130 | "Parameters\n" |
---|
| 131 | "----------\n" |
---|
| 132 | "vec : fvec\n" |
---|
| 133 | " input vector\n" |
---|
| 134 | "level : float\n" |
---|
| 135 | " level threshold, in dB SPL\n" |
---|
| 136 | "\n" |
---|
| 137 | "Returns\n" |
---|
| 138 | "-------\n" |
---|
| 139 | "float\n" |
---|
| 140 | " `1.0` if level of `vec` in dB SPL is under `level`,\n" |
---|
| 141 | " `db_spl(vec)` otherwise.\n" |
---|
[9c8c8a6] | 142 | "\n" |
---|
| 143 | "Example\n" |
---|
| 144 | "-------\n" |
---|
| 145 | "\n" |
---|
[0bb2d63] | 146 | ">>> aubio.level_detection(0.7*aubio.fvec(np.ones(1024)), -3.)\n" |
---|
| 147 | "1.0\n" |
---|
| 148 | ">>> aubio.level_detection(0.7*aubio.fvec(np.ones(1024)), -4.)\n" |
---|
| 149 | "-3.0980708599090576\n" |
---|
| 150 | "\n" |
---|
| 151 | "See Also\n" |
---|
| 152 | "--------\n" |
---|
| 153 | "silence_detection, db_spl, level_lin\n" |
---|
| 154 | ""; |
---|
[9c8c8a6] | 155 | |
---|
| 156 | PyObject * Py_aubio_level_detection(PyObject *self, PyObject *args); |
---|
| 157 | |
---|
[b532275] | 158 | static char Py_aubio_shift_doc[] = "" |
---|
| 159 | "Swap left and right partitions of a vector\n" |
---|
| 160 | "\n" |
---|
| 161 | "Returns the swapped vector. The input vector is also modified.\n" |
---|
| 162 | "\n" |
---|
| 163 | "For a vector of length N, the partition is split at index N - N//2.\n" |
---|
| 164 | "\n" |
---|
| 165 | "Example\n" |
---|
| 166 | "-------\n" |
---|
| 167 | "\n" |
---|
| 168 | ">>> import numpy\n" |
---|
| 169 | ">>> shift(numpy.arange(3, dtype=aubio.float_type))\n" |
---|
| 170 | "array([2., 0., 1.], dtype=" AUBIO_NPY_SMPL_STR ")"; |
---|
| 171 | PyObject * Py_aubio_shift(PyObject *self, PyObject *args); |
---|
| 172 | |
---|
| 173 | static char Py_aubio_ishift_doc[] = "" |
---|
| 174 | "Swap right and left partitions of a vector\n" |
---|
| 175 | "\n" |
---|
| 176 | "Returns the swapped vector. The input vector is also modified.\n" |
---|
| 177 | "\n" |
---|
| 178 | "Unlike with shift(), the partition is split at index N//2.\n" |
---|
| 179 | "\n" |
---|
| 180 | "Example\n" |
---|
| 181 | "-------\n" |
---|
| 182 | "\n" |
---|
| 183 | ">>> import numpy\n" |
---|
| 184 | ">>> ishift(numpy.arange(3, dtype=aubio.float_type))\n" |
---|
| 185 | "array([1., 2., 0.], dtype=" AUBIO_NPY_SMPL_STR ")"; |
---|
| 186 | PyObject * Py_aubio_ishift(PyObject *self, PyObject *args); |
---|
| 187 | |
---|
[6f42c16] | 188 | #endif /* PY_AUBIO_MUSICUTILS_H */ |
---|