source: python/ext/py-musicutils.h @ 7a7dea2

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5
Last change on this file since 7a7dea2 was 7a7dea2, checked in by Paul Brossier <piem@piem.org>, 5 years ago

[python] improve docstrings for shift and ishift

  • Property mode set to 100644
File size: 4.5 KB
Line 
1#ifndef PY_AUBIO_MUSICUTILS_H
2#define PY_AUBIO_MUSICUTILS_H
3
4static 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"
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)";
15
16PyObject * Py_aubio_window(PyObject *self, PyObject *args);
17
18static char Py_aubio_level_lin_doc[] = ""
19"level_lin(x)\n"
20"\n"
21"Compute sound pressure level of `x`, on a linear scale.\n"
22"\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"
32"\n"
33"Example\n"
34"-------\n"
35"\n"
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"";
49
50PyObject * Py_aubio_level_lin(PyObject *self, PyObject *args);
51
52static char Py_aubio_db_spl_doc[] = ""
53"db_spl(x)\n"
54"\n"
55"Compute Sound Pressure Level (SPL) of `x`, in dB.\n"
56"\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"
66"\n"
67"Example\n"
68"-------\n"
69"\n"
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"";
89
90PyObject * Py_aubio_db_spl(PyObject *self, PyObject *args);
91
92static char Py_aubio_silence_detection_doc[] = ""
93"silence_detection(vec, level)\n"
94"\n"
95"Check if level of `vec`, in dB SPL, is under a given threshold.\n"
96"\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"
103"\n"
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"";
122
123PyObject * Py_aubio_silence_detection(PyObject *self, PyObject *args);
124
125static char Py_aubio_level_detection_doc[] = ""
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"
142"\n"
143"Example\n"
144"-------\n"
145"\n"
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"";
155
156PyObject * Py_aubio_level_detection(PyObject *self, PyObject *args);
157
158static char Py_aubio_shift_doc[] = ""
159"shift(vec)\n"
160"\n"
161"Swap left and right partitions of a vector, in-place.\n"
162"\n"
163"Parameters\n"
164"----------\n"
165"vec : fvec\n"
166"   input vector to shift\n"
167"\n"
168"Returns\n"
169"-------\n"
170"fvec\n"
171"   The swapped vector.\n"
172"\n"
173"Notes\n"
174"-----\n"
175"The input vector is also modified.\n"
176"\n"
177"For a vector of length N, the partition is split at index N - N//2.\n"
178"\n"
179"Example\n"
180"-------\n"
181"\n"
182">>> aubio.shift(aubio.fvec(np.arange(3)))\n"
183"array([2., 0., 1.], dtype=" AUBIO_NPY_SMPL_STR ")\n"
184"\n"
185"See Also\n"
186"--------\n"
187"ishift\n"
188"";
189PyObject * Py_aubio_shift(PyObject *self, PyObject *args);
190
191static char Py_aubio_ishift_doc[] = ""
192"ishift(vec)\n"
193"\n"
194"Swap right and left partitions of a vector, in-place.\n"
195"\n"
196"Parameters\n"
197"----------\n"
198"vec : fvec\n"
199"   input vector to shift\n"
200"\n"
201"Returns\n"
202"-------\n"
203"fvec\n"
204"   The swapped vector.\n"
205"\n"
206"Notes\n"
207"-----\n"
208"The input vector is also modified.\n"
209"\n"
210"Unlike with :py:func:`shift`, the partition is split at index N//2.\n"
211"\n"
212"Example\n"
213"-------\n"
214"\n"
215">>> aubio.ishift(aubio.fvec(np.arange(3)))\n"
216"array([1., 2., 0.], dtype=" AUBIO_NPY_SMPL_STR ")\n"
217"\n"
218"See Also\n"
219"--------\n"
220"shift\n"
221"";
222PyObject * Py_aubio_ishift(PyObject *self, PyObject *args);
223
224#endif /* PY_AUBIO_MUSICUTILS_H */
Note: See TracBrowser for help on using the repository browser.