Showing the changes to python/ext (1 of 1 file). Show all
Unified · Split
| @@ -16,58 +16,142 @@ static char Py_aubio_window_doc[] = "" · 15 unmodified lines | |||
| 16 | PyObject * Py_aubio_window(PyObject *self, PyObject *args); | 16 | PyObject * Py_aubio_window(PyObject *self, PyObject *args); |
| 17 | 17 | ||
| 18 | static char Py_aubio_level_lin_doc[] = "" | 18 | static char Py_aubio_level_lin_doc[] = "" |
| 19 | "level_lin(fvec) -> fvec\n" | 19 | "level_lin(x)\n" |
| 20 | "\n" | 20 | "\n" |
| 21 | "Compute sound level on a linear scale.\n" | 21 | "Compute sound pressure level of `x`, on a linear scale.\n" |
| 22 | "\n" | 22 | "\n" |
| 23 | "This gives the average of the square amplitudes.\n" | 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" | ||
| 24 | "\n" | 32 | "\n" |
| 25 | "Example\n" | 33 | "Example\n" |
| 26 | "-------\n" | 34 | "-------\n" |
| 27 | "\n" | 35 | "\n" |
| 28 | ">>> level_Lin(numpy.ones(1024))\n" | 36 | ">>> aubio.level_lin(aubio.fvec(numpy.ones(1024)))\n" |
| 29 | "1.0"; | 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 | ""; | ||
| 30 | 49 | ||
| 31 | PyObject * Py_aubio_level_lin(PyObject *self, PyObject *args); | 50 | PyObject * Py_aubio_level_lin(PyObject *self, PyObject *args); |
| 32 | 51 | ||
| 33 | static char Py_aubio_db_spl_doc[] = "" | 52 | static char Py_aubio_db_spl_doc[] = "" |
| 34 | "Compute sound pressure level (SPL) in dB\n" | 53 | "db_spl(x)\n" |
| 35 | "\n" | 54 | "\n" |
| 36 | "This quantity is often wrongly called 'loudness'.\n" | 55 | "Compute Sound Pressure Level (SPL) of `x`, in dB.\n" |
| 37 | "\n" | 56 | "\n" |
| 38 | "This gives ten times the log10 of the average of the square amplitudes.\n" | 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" | ||
| 39 | "\n" | 66 | "\n" |
| 40 | "Example\n" | 67 | "Example\n" |
| 41 | "-------\n" | 68 | "-------\n" |
| 42 | "\n" | 69 | "\n" |
| 43 | ">>> db_spl(numpy.ones(1024))\n" | 70 | ">>> aubio.db_spl(aubio.fvec(np.ones(1024)))\n" |
| 44 | "1.0"; | 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 | ""; | ||
| 45 | 89 | ||
| 46 | PyObject * Py_aubio_db_spl(PyObject *self, PyObject *args); | 90 | PyObject * Py_aubio_db_spl(PyObject *self, PyObject *args); |
| 47 | 91 | ||
| 48 | static char Py_aubio_silence_detection_doc[] = "" | 92 | static char Py_aubio_silence_detection_doc[] = "" |
| 49 | "Check if buffer level in dB SPL is under a given threshold\n" | 93 | "silence_detection(vec, level)\n" |
| 50 | "\n" | 94 | "\n" |
| 51 | "Return 0 if level is under the given threshold, 1 otherwise.\n" | 95 | "Check if level of `vec`, in dB SPL, is under a given threshold.\n" |
| 52 | "\n" | 96 | "\n" |
| 53 | "Example\n" | 97 | "Parameters\n" |
| 54 | "-------\n" | 98 | "----------\n" |
| 99 | "vec : fvec\n" | ||
| 100 | " input vector\n" | ||
| 101 | "level : float\n" | ||
| 102 | " level threshold, in dB SPL\n" | ||
| 55 | "\n" | 103 | "\n" |
| 56 | ">>> import numpy\n""" | 104 | "Returns\n" |
| 57 | ">>> silence_detection(numpy.ones(1024, dtype=\"float32\"), -80)\n" | 105 | "-------\n" |
| 58 | "0"; | 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 | ""; | ||
| 59 | 122 | ||
| 60 | PyObject * Py_aubio_silence_detection(PyObject *self, PyObject *args); | 123 | PyObject * Py_aubio_silence_detection(PyObject *self, PyObject *args); |
| 61 | 124 | ||
| 62 | static char Py_aubio_level_detection_doc[] = "" | 125 | static char Py_aubio_level_detection_doc[] = "" |
| 63 | "Get buffer level in dB SPL if over a given threshold, 1. otherwise.\n" | 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" | ||
| 64 | "\n" | 142 | "\n" |
| 65 | "Example\n" | 143 | "Example\n" |
| 66 | "-------\n" | 144 | "-------\n" |
| 67 | "\n" | 145 | "\n" |
| 68 | ">>> import numpy\n""" | 146 | ">>> aubio.level_detection(0.7*aubio.fvec(np.ones(1024)), -3.)\n" |
| 69 | ">>> level_detection(0.7*numpy.ones(1024, dtype=\"float32\"), -80)\n" | 147 | "1.0\n" |
| 70 | "0"; | 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 | ""; | ||
| 71 | 155 | ||
| 72 | PyObject * Py_aubio_level_detection(PyObject *self, PyObject *args); | 156 | PyObject * Py_aubio_level_detection(PyObject *self, PyObject *args); |
| 73 | 157 | ||