History

[python] improve docstrings for db_spl, level_lin, level_detection, silence_detection

Paul Brossier committed 8 years ago

Commit 0bb2d631 parent 55b62601 file · +105 −21Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/ext/py-musicutils.h+105−21
@@ -16,58 +16,142 @@ static char Py_aubio_window_doc[] = "" · 15 unmodified lines
1616 PyObject * Py_aubio_window(PyObject *self, PyObject *args);
1717
1818 static char Py_aubio_level_lin_doc[] = ""
19−"level_lin(fvec) -> fvec\n"
19+"level_lin(x)\n"
2020 "\n"
21−"Compute sound level on a linear scale.\n"
21+"Compute sound pressure level of `x`, on a linear scale.\n"
2222 "\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"
2432 "\n"
2533 "Example\n"
2634 "-------\n"
2735 "\n"
28−">>> level_Lin(numpy.ones(1024))\n"
29−"1.0";
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+"";
3049
3150 PyObject * Py_aubio_level_lin(PyObject *self, PyObject *args);
3251
3352 static char Py_aubio_db_spl_doc[] = ""
34−"Compute sound pressure level (SPL) in dB\n"
53+"db_spl(x)\n"
3554 "\n"
36−"This quantity is often wrongly called 'loudness'.\n"
55+"Compute Sound Pressure Level (SPL) of `x`, in dB.\n"
3756 "\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"
3966 "\n"
4067 "Example\n"
4168 "-------\n"
4269 "\n"
43−">>> db_spl(numpy.ones(1024))\n"
44−"1.0";
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+"";
4589
4690 PyObject * Py_aubio_db_spl(PyObject *self, PyObject *args);
4791
4892 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"
5094 "\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"
5296 "\n"
53−"Example\n"
54−"-------\n"
97+"Parameters\n"
98+"----------\n"
99+"vec : fvec\n"
100+" input vector\n"
101+"level : float\n"
102+" level threshold, in dB SPL\n"
55103 "\n"
56−">>> import numpy\n"""
57−">>> silence_detection(numpy.ones(1024, dtype=\"float32\"), -80)\n"
58−"0";
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+"";
59122
60123 PyObject * Py_aubio_silence_detection(PyObject *self, PyObject *args);
61124
62125 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"
64142 "\n"
65143 "Example\n"
66144 "-------\n"
67145 "\n"
68−">>> import numpy\n"""
69−">>> level_detection(0.7*numpy.ones(1024, dtype=\"float32\"), -80)\n"
70−"0";
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+"";
71155
72156 PyObject * Py_aubio_level_detection(PyObject *self, PyObject *args);
73157

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t