Changes in python/ext/py-musicutils.h [16e2bb0:b532275]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/ext/py-musicutils.h
r16e2bb0 rb532275 3 3 4 4 static char Py_aubio_window_doc[] = "" 5 "window( window_type, size)\n"5 "window(string, integer) -> fvec\n" 6 6 "\n" 7 "Create a window of length `size`. `window_type` should be one\n" 8 "of the following:\n" 7 "Create a window\n" 9 8 "\n" 10 "- `default` (same as `hanningz`).\n" 11 "- `ones`\n" 12 "- `rectangle`\n" 13 "- `hamming`\n" 14 "- `hanning`\n" 15 "- `hanningz` [1]_\n" 16 "- `blackman`\n" 17 "- `blackman_harris`\n" 18 "- `gaussian`\n" 19 "- `welch`\n" 20 "- `parzen`\n" 9 "Example\n" 10 "-------\n" 21 11 "\n" 22 "Parameters\n" 23 "----------\n" 24 "window_type : str\n" 25 " Type of window.\n" 26 "size : int\n" 27 " Length of window.\n" 28 "\n" 29 "Returns\n" 30 "-------\n" 31 "fvec\n" 32 " Array of shape `(length,)` containing the new window.\n" 33 "\n" 34 "See Also\n" 35 "--------\n" 36 "pvoc, fft\n" 37 "\n" 38 "Examples\n" 39 "--------\n" 40 "Compute a zero-phase Hann window on `1024` points:\n" 41 "\n" 42 ">>> aubio.window('hanningz', 1024)\n" 12 ">>> window('hanningz', 1024)\n" 43 13 "array([ 0.00000000e+00, 9.41753387e-06, 3.76403332e-05, ...,\n" 44 " 8.46982002e-05, 3.76403332e-05, 9.41753387e-06], dtype=float32)\n" 45 "\n" 46 "Plot different window types with `matplotlib <https://matplotlib.org/>`_:\n" 47 "\n" 48 ">>> import matplotlib.pyplot as plt\n" 49 ">>> modes = ['default', 'ones', 'rectangle', 'hamming', 'hanning',\n" 50 "... 'hanningz', 'blackman', 'blackman_harris', 'gaussian',\n" 51 "... 'welch', 'parzen']; n = 2048\n" 52 ">>> for m in modes: plt.plot(aubio.window(m, n), label=m)\n" 53 "...\n" 54 ">>> plt.legend(); plt.show()\n" 55 "\n" 56 "Note\n" 57 "----\n" 58 "The following examples contain the equivalent source code to compute\n" 59 "each type of window with `NumPy <https://numpy.org>`_:\n" 60 "\n" 61 ">>> n = 1024; x = np.arange(n, dtype=aubio.float_type)\n" 62 ">>> ones = np.ones(n).astype(aubio.float_type)\n" 63 ">>> rectangle = 0.5 * ones\n" 64 ">>> hanning = 0.5 - 0.5 * np.cos(2 * np.pi * x / n)\n" 65 ">>> hanningz = 0.5 * (1 - np.cos(2 * np.pi * x / n))\n" 66 ">>> hamming = 0.54 - 0.46 * np.cos(2.*np.pi * x / (n - 1))\n" 67 ">>> blackman = 0.42 \\\n" 68 "... - 0.50 * np.cos(2 * np.pi * x / (n - 1)) \\\n" 69 "... + 0.08 * np.cos(4 * np.pi * x / (n - 1))\n" 70 ">>> blackman_harris = 0.35875 \\\n" 71 "... - 0.48829 * np.cos(2 * np.pi * x / (n - 1)) \\\n" 72 "... + 0.14128 * np.cos(4 * np.pi * x / (n - 1)) \\\n" 73 "... + 0.01168 * np.cos(6 * np.pi * x / (n - 1))\n" 74 ">>> gaussian = np.exp( - 0.5 * ((x - 0.5 * (n - 1)) \\\n" 75 "... / (0.25 * (n - 1)) )**2 )\n" 76 ">>> welch = 1 - ((2 * x - n) / (n + 1))**2\n" 77 ">>> parzen = 1 - np.abs((2 * x - n) / (n + 1))\n" 78 ">>> default = hanningz\n" 79 "References\n" 80 "----------\n" 81 #if 0 82 "`Window function <https://en.wikipedia.org/wiki/Window_function>`_ on\n" 83 "Wikipedia.\n" 84 "\n" 85 #endif 86 ".. [1] Amalia de Götzen, Nicolas Bernardini, and Daniel Arfib. Traditional\n" 87 " (?) implementations of a phase vocoder: the tricks of the trade.\n" 88 " In *Proceedings of the International Conference on Digital Audio\n" 89 " Effects* (DAFx-00), pages 37–44, University of Verona, Italy, 2000.\n" 90 " (`online version <" 91 "https://www.cs.princeton.edu/courses/archive/spr09/cos325/Bernardini.pdf" 92 ">`_).\n" 93 ""; 14 " 8.46982002e-05, 3.76403332e-05, 9.41753387e-06], dtype=float32)"; 94 15 95 16 PyObject * Py_aubio_window(PyObject *self, PyObject *args); 96 17 97 18 static char Py_aubio_level_lin_doc[] = "" 98 "level_lin( x)\n"19 "level_lin(fvec) -> fvec\n" 99 20 "\n" 100 "Compute sound pressure level of `x`,on a linear scale.\n"21 "Compute sound level on a linear scale.\n" 101 22 "\n" 102 "Parameters\n" 103 "----------\n" 104 "x : fvec\n" 105 " input vector\n" 106 "\n" 107 "Returns\n" 108 "-------\n" 109 "float\n" 110 " Linear level of `x`.\n" 23 "This gives the average of the square amplitudes.\n" 111 24 "\n" 112 25 "Example\n" 113 26 "-------\n" 114 27 "\n" 115 ">>> aubio.level_lin(aubio.fvec(numpy.ones(1024)))\n" 116 "1.0\n" 117 "\n" 118 "Note\n" 119 "----\n" 120 "Computed as the average of the squared amplitudes:\n" 121 "\n" 122 ".. math:: L = \\frac {\\sum_{n=0}^{N-1} {x_n}^2} {N}\n" 123 "\n" 124 "See Also\n" 125 "--------\n" 126 "db_spl, silence_detection, level_detection\n" 127 ""; 28 ">>> level_Lin(numpy.ones(1024))\n" 29 "1.0"; 128 30 129 31 PyObject * Py_aubio_level_lin(PyObject *self, PyObject *args); 130 32 131 33 static char Py_aubio_db_spl_doc[] = "" 132 " db_spl(x)\n"34 "Compute sound pressure level (SPL) in dB\n" 133 35 "\n" 134 " Compute Sound Pressure Level (SPL) of `x`, in dB.\n"36 "This quantity is often wrongly called 'loudness'.\n" 135 37 "\n" 136 "Parameters\n" 137 "----------\n" 138 "x : fvec\n" 139 " input vector\n" 140 "\n" 141 "Returns\n" 142 "-------\n" 143 "float\n" 144 " Level of `x`, in dB SPL.\n" 38 "This gives ten times the log10 of the average of the square amplitudes.\n" 145 39 "\n" 146 40 "Example\n" 147 41 "-------\n" 148 42 "\n" 149 ">>> aubio.db_spl(aubio.fvec(np.ones(1024)))\n" 150 "1.0\n" 151 ">>> aubio.db_spl(0.7*aubio.fvec(np.ones(32)))\n" 152 "-3.098040819168091\n" 153 "\n" 154 "Note\n" 155 "----\n" 156 "Computed as `log10` of :py:func:`level_lin`:\n" 157 "\n" 158 ".. math::\n" 159 "\n" 160 " {SPL}_{dB} = log10{\\frac {\\sum_{n=0}^{N-1}{x_n}^2} {N}}\n" 161 "\n" 162 "This quantity is often incorrectly called 'loudness'.\n" 163 "\n" 164 "See Also\n" 165 "--------\n" 166 "level_lin, silence_detection, level_detection\n" 167 ""; 43 ">>> db_spl(numpy.ones(1024))\n" 44 "1.0"; 168 45 169 46 PyObject * Py_aubio_db_spl(PyObject *self, PyObject *args); 170 47 171 48 static char Py_aubio_silence_detection_doc[] = "" 172 " silence_detection(vec, level)\n"49 "Check if buffer level in dB SPL is under a given threshold\n" 173 50 "\n" 174 " Check if level of `vec`, in dB SPL, is under a given threshold.\n"51 "Return 0 if level is under the given threshold, 1 otherwise.\n" 175 52 "\n" 176 "Parameters\n" 177 "----------\n" 178 "vec : fvec\n" 179 " input vector\n" 180 "level : float\n" 181 " level threshold, in dB SPL\n" 53 "Example\n" 54 "-------\n" 182 55 "\n" 183 "Returns\n" 184 "-------\n" 185 "int\n" 186 " `1` if level of `vec`, in dB SPL, is under `level`,\n" 187 " `0` otherwise.\n" 188 "\n" 189 "Examples\n" 190 "--------\n" 191 "\n" 192 ">>> aubio.silence_detection(aubio.fvec(32), -100.)\n" 193 "1\n" 194 ">>> aubio.silence_detection(aubio.fvec(np.ones(32)), 0.)\n" 195 "0\n" 196 "\n" 197 "See Also\n" 198 "--------\n" 199 "level_detection, db_spl, level_lin\n" 200 ""; 56 ">>> import numpy\n""" 57 ">>> silence_detection(numpy.ones(1024, dtype=\"float32\"), -80)\n" 58 "0"; 201 59 202 60 PyObject * Py_aubio_silence_detection(PyObject *self, PyObject *args); 203 61 204 62 static char Py_aubio_level_detection_doc[] = "" 205 "level_detection(vec, level)\n" 206 "\n" 207 "Check if `vec` is above threshold `level`, in dB SPL.\n" 208 "\n" 209 "Parameters\n" 210 "----------\n" 211 "vec : fvec\n" 212 " input vector\n" 213 "level : float\n" 214 " level threshold, in dB SPL\n" 215 "\n" 216 "Returns\n" 217 "-------\n" 218 "float\n" 219 " `1.0` if level of `vec` in dB SPL is under `level`,\n" 220 " `db_spl(vec)` otherwise.\n" 63 "Get buffer level in dB SPL if over a given threshold, 1. otherwise.\n" 221 64 "\n" 222 65 "Example\n" 223 66 "-------\n" 224 67 "\n" 225 ">>> aubio.level_detection(0.7*aubio.fvec(np.ones(1024)), -3.)\n" 226 "1.0\n" 227 ">>> aubio.level_detection(0.7*aubio.fvec(np.ones(1024)), -4.)\n" 228 "-3.0980708599090576\n" 229 "\n" 230 "See Also\n" 231 "--------\n" 232 "silence_detection, db_spl, level_lin\n" 233 ""; 68 ">>> import numpy\n""" 69 ">>> level_detection(0.7*numpy.ones(1024, dtype=\"float32\"), -80)\n" 70 "0"; 234 71 235 72 PyObject * Py_aubio_level_detection(PyObject *self, PyObject *args); 236 73 237 74 static char Py_aubio_shift_doc[] = "" 238 " shift(vec)\n"75 "Swap left and right partitions of a vector\n" 239 76 "\n" 240 "Swap left and right partitions of a vector, in-place.\n" 241 "\n" 242 "Parameters\n" 243 "----------\n" 244 "vec : fvec\n" 245 " input vector to shift\n" 246 "\n" 247 "Returns\n" 248 "-------\n" 249 "fvec\n" 250 " The swapped vector.\n" 251 "\n" 252 "Notes\n" 253 "-----\n" 254 "The input vector is also modified.\n" 77 "Returns the swapped vector. The input vector is also modified.\n" 255 78 "\n" 256 79 "For a vector of length N, the partition is split at index N - N//2.\n" … … 259 82 "-------\n" 260 83 "\n" 261 ">>> aubio.shift(aubio.fvec(np.arange(3)))\n" 262 "array([2., 0., 1.], dtype=" AUBIO_NPY_SMPL_STR ")\n" 263 "\n" 264 "See Also\n" 265 "--------\n" 266 "ishift\n" 267 ""; 84 ">>> import numpy\n" 85 ">>> shift(numpy.arange(3, dtype=aubio.float_type))\n" 86 "array([2., 0., 1.], dtype=" AUBIO_NPY_SMPL_STR ")"; 268 87 PyObject * Py_aubio_shift(PyObject *self, PyObject *args); 269 88 270 89 static char Py_aubio_ishift_doc[] = "" 271 " ishift(vec)\n"90 "Swap right and left partitions of a vector\n" 272 91 "\n" 273 " Swap right and left partitions of a vector, in-place.\n"92 "Returns the swapped vector. The input vector is also modified.\n" 274 93 "\n" 275 "Parameters\n" 276 "----------\n" 277 "vec : fvec\n" 278 " input vector to shift\n" 279 "\n" 280 "Returns\n" 281 "-------\n" 282 "fvec\n" 283 " The swapped vector.\n" 284 "\n" 285 "Notes\n" 286 "-----\n" 287 "The input vector is also modified.\n" 288 "\n" 289 "Unlike with :py:func:`shift`, the partition is split at index N//2.\n" 94 "Unlike with shift(), the partition is split at index N//2.\n" 290 95 "\n" 291 96 "Example\n" 292 97 "-------\n" 293 98 "\n" 294 ">>> aubio.ishift(aubio.fvec(np.arange(3)))\n" 295 "array([1., 2., 0.], dtype=" AUBIO_NPY_SMPL_STR ")\n" 296 "\n" 297 "See Also\n" 298 "--------\n" 299 "shift\n" 300 ""; 99 ">>> import numpy\n" 100 ">>> ishift(numpy.arange(3, dtype=aubio.float_type))\n" 101 "array([1., 2., 0.], dtype=" AUBIO_NPY_SMPL_STR ")"; 301 102 PyObject * Py_aubio_ishift(PyObject *self, PyObject *args); 302 103
Note: See TracChangeset
for help on using the changeset viewer.