History

[python] add docstrings for sink

Paul Brossier committed 8 years ago

Commit d2816981 parent 58eb2501 file · +55 −30Browse files

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

Unified · Split

python/ext/py-sink.c+55−30
@@ -12,53 +12,78 @@ typedef struct · 11 unmodified lines
1212 } Py_sink;
1313
1414 static char Py_sink_doc[] = ""
15−" __new__(path, samplerate = 44100, channels = 1)\n"
15+"sink(path, samplerate=44100, channels=1)\n"
1616 "\n"
17−" Create a new sink, opening the given path for writing.\n"
17+"Open `path` to write a WAV file.\n"
1818 "\n"
19−" Examples\n"
20−" --------\n"
19+"Parameters\n"
20+"----------\n"
21+"path : str\n"
22+" Pathname of the file to be opened for writing.\n"
23+"samplerate : int\n"
24+" Sampling rate of the file, in Hz.\n"
25+"channels : int\n"
26+" Number of channels to create the file with.\n"
2127 "\n"
22−" Create a new sink at 44100Hz, mono:\n"
28+"Examples\n"
29+"--------\n"
2330 "\n"
24−" >>> sink('/tmp/t.wav')\n"
31+"Create a new sink at 44100Hz, mono:\n"
2532 "\n"
26−" Create a new sink at 8000Hz, mono:\n"
33+">>> snk = aubio.sink('out.wav')\n"
2734 "\n"
28−" >>> sink('/tmp/t.wav', samplerate = 8000)\n"
35+"Create a new sink at 32000Hz, stereo, write 100 samples into it:\n"
2936 "\n"
30−" Create a new sink at 32000Hz, stereo:\n"
37+">>> snk = aubio.sink('out.wav', samplerate=16000, channels=3)\n"
38+">>> snk(aubio.fvec(100), 100)\n"
3139 "\n"
32−" >>> sink('/tmp/t.wav', samplerate = 32000, channels = 2)\n"
40+"Open a new sink at 48000Hz, stereo, write `1234` samples into it:\n"
3341 "\n"
34−" Create a new sink at 32000Hz, 5 channels:\n"
42+">>> with aubio.sink('out.wav', samplerate=48000, channels=2) as src:\n"
43+"... snk(aubio.fvec(1024), 1024)\n"
44+"... snk(aubio.fvec(210), 210)\n"
45+"...\n"
3546 "\n"
36−" >>> sink('/tmp/t.wav', channels = 5, samplerate = 32000)\n"
37−"\n"
38−" __call__(vec, write)\n"
39−" x(vec,write) <==> x.do(vec, write)\n"
40−"\n"
41−" Write vector to sink.\n"
42−"\n"
43−" See also\n"
44−" --------\n"
45−" aubio.sink.do\n"
47+"See also\n"
48+"--------\n"
49+"source: read audio samples from a file.\n"
4650 "\n";
4751
4852 static char Py_sink_do_doc[] = ""
49−"x.do(vec, write) <==> x(vec, write)\n"
53+"do(vec, write)\n"
5054 "\n"
51−"write monophonic vector to sink";
55+"Write a single channel vector to sink.\n"
56+"\n"
57+"Parameters\n"
58+"----------\n"
59+"vec : fvec\n"
60+" input vector `(n,)` where `n >= 0`.\n"
61+"write : int\n"
62+" Number of samples to write.\n"
63+"";
5264
5365 static char Py_sink_do_multi_doc[] = ""
54−"x.do_multi(mat, write)\n"
66+"do_multi(mat, write)\n"
67+"\n"
68+"Write a matrix containing vectors from multiple channels to sink.\n"
5569 "\n"
56−"write polyphonic vector to sink";
70+"Parameters\n"
71+"----------\n"
72+"mat : numpy.ndarray\n"
73+" input matrix of shape `(channels, n)`, where `n >= 0`.\n"
74+"write : int\n"
75+" Number of frames to write.\n"
76+"";
5777
5878 static char Py_sink_close_doc[] = ""
59−"x.close()\n"
79+"close()\n"
80+"\n"
81+"Close this sink now.\n"
6082 "\n"
61−"close this sink now";
83+"By default, the file gets closed when deleting the object. Explicitely\n"
84+"closing a sink can be useful to control the number of file opened\n"
85+"simultaneously.\n"
86+"";
6287
6388 static PyObject *
6489 Py_sink_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
@@ -188,11 +213,11 @@ Py_sink_do_multi(Py_sink * self, PyObject * args) · 123 unmodified lines
188213
189214 static PyMemberDef Py_sink_members[] = {
190215 {"uri", T_STRING, offsetof (Py_sink, uri), READONLY,
191− "path at which the sink was created"},
216+ "str (read-only): Path at which the sink was created."},
192217 {"samplerate", T_INT, offsetof (Py_sink, samplerate), READONLY,
193− "samplerate at which the sink was created"},
218+ "int (read-only): Samplerate at which the sink was created."},
194219 {"channels", T_INT, offsetof (Py_sink, channels), READONLY,
195− "number of channels with which the sink was created"},
220+ "int (read-only): Number of channels with which the sink was created."},
196221 { NULL } // sentinel
197222 };
198223

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