History

python/ext/py-{source,sink}.c: improve documentation

Paul Brossier committed 12 years ago

Commit a79ec761 parent 96a96d72 files · +130 −28Browse files

Showing the changes to python (2 of 2 files). Show all

Unified · Split

2 files
  1. python/ext/py-sink.c +58 −19
  2. python/ext/py-source.c +72 −9
python/ext/py-sink.c+58−19
@@ -9,7 +9,54 @@ typedef struct · 8 unmodified lines
9 uint_t channels;9 uint_t channels;
10} Py_sink;10} Py_sink;
11 11
12static char Py_sink_doc[] = "sink object";12static char Py_sink_doc[] = ""
13" __new__(path, samplerate = 44100, channels = 1)\n"
14"\n"
15" Create a new sink, opening the given path for writing.\n"
16"\n"
17" Examples\n"
18" --------\n"
19"\n"
20" Create a new sink at 44100Hz, mono:\n"
21"\n"
22" >>> sink('/tmp/t.wav')\n"
23"\n"
24" Create a new sink at 8000Hz, mono:\n"
25"\n"
26" >>> sink('/tmp/t.wav', samplerate = 8000)\n"
27"\n"
28" Create a new sink at 32000Hz, stereo:\n"
29"\n"
30" >>> sink('/tmp/t.wav', samplerate = 32000, channels = 2)\n"
31"\n"
32" Create a new sink at 32000Hz, 5 channels:\n"
33"\n"
34" >>> sink('/tmp/t.wav', channels = 5, samplerate = 32000)\n"
35"\n"
36" __call__(vec, write)\n"
37" x(vec,write) <==> x.do(vec, write)\n"
38"\n"
39" Write vector to sink.\n"
40"\n"
41" See also\n"
42" --------\n"
43" aubio.sink.do\n"
44"\n";
45
46static char Py_sink_do_doc[] = ""
47"x.do(vec, write) <==> x(vec, write)\n"
48"\n"
49"write monophonic vector to sink";
50
51static char Py_sink_do_multi_doc[] = ""
52"x.do_multi(mat, write)\n"
53"\n"
54"write polyphonic vector to sink";
55
56static char Py_sink_close_doc[] = ""
57"x.close()\n"
58"\n"
59"close this sink now";
13 60
14static PyObject *61static PyObject *
15Py_sink_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)62Py_sink_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
@@ -113,7 +160,7 @@ Py_sink_do(Py_sink * self, PyObject * args) · 97 unmodified lines
113 Py_RETURN_NONE;160 Py_RETURN_NONE;
114}161}
115 162
116/* function Py_sink_do */163/* function Py_sink_do_multi */
117static PyObject *164static PyObject *
118Py_sink_do_multi(Py_sink * self, PyObject * args)165Py_sink_do_multi(Py_sink * self, PyObject * args)
119{166{
@@ -147,9 +194,12 @@ Py_sink_do_multi(Py_sink * self, PyObject * args) · 27 unmodified lines
147}194}
148 195
149AUBIO_MEMBERS_START(sink)196AUBIO_MEMBERS_START(sink)
150 {"uri", T_STRING, offsetof (Py_sink, uri), READONLY, ""},197 {"uri", T_STRING, offsetof (Py_sink, uri), READONLY,
151 {"samplerate", T_INT, offsetof (Py_sink, samplerate), READONLY, ""},198 "path at which the sink was created"},
152 {"channels", T_INT, offsetof (Py_sink, channels), READONLY, ""},199 {"samplerate", T_INT, offsetof (Py_sink, samplerate), READONLY,
200 "samplerate at which the sink was created"},
201 {"channels", T_INT, offsetof (Py_sink, channels), READONLY,
202 "number of channels with which the sink was created"},
153AUBIO_MEMBERS_STOP(sink)203AUBIO_MEMBERS_STOP(sink)
154 204
155static PyObject *205static PyObject *
@@ -160,20 +210,9 @@ Pyaubio_sink_close (Py_sink *self, PyObject *unused) · 4 unmodified lines
160}210}
161 211
162static PyMethodDef Py_sink_methods[] = {212static PyMethodDef Py_sink_methods[] = {
163 {"__call__", (PyCFunction) Py_sink_do, METH_VARARGS,213 {"do", (PyCFunction) Py_sink_do, METH_VARARGS, Py_sink_do_doc},
164 "x.__call__(vec, write)\n"214 {"do_multi", (PyCFunction) Py_sink_do_multi, METH_VARARGS, Py_sink_do_multi_doc},
165 "write monophonic vector to sink"215 {"close", (PyCFunction) Pyaubio_sink_close, METH_NOARGS, Py_sink_close_doc},
166 ""},
167 {"do", (PyCFunction) Py_sink_do, METH_VARARGS,
168 "x.do(vec, write)\n"
169 "write monophonic vector to sink"
170 ""},
171 {"do_multi", (PyCFunction) Py_sink_do_multi, METH_VARARGS,
172 "x.do_multi(mat, write)\n"
173 "write polyphonic vector to sink"},
174 {"close", (PyCFunction) Pyaubio_sink_close, METH_NOARGS,
175 "x.close()\n"
176 "close this sink now"},
177 {NULL} /* sentinel */216 {NULL} /* sentinel */
178};217};
179 218
python/ext/py-source.c+72−9
@@ -10,7 +10,64 @@ typedef struct · 9 unmodified lines
10 uint_t hop_size;10 uint_t hop_size;
11} Py_source;11} Py_source;
12 12
13static char Py_source_doc[] = "source object";13static char Py_source_doc[] = ""
14" __new__(path, samplerate = 0, hop_size = 512, channels = 1)\n"
15"\n"
16" Create a new source, opening the given path for reading.\n"
17"\n"
18" Examples\n"
19" --------\n"
20"\n"
21" Create a new source, using the original samplerate, with hop_size = 512:\n"
22"\n"
23" >>> source('/tmp/t.wav')\n"
24"\n"
25" Create a new source, resampling the original to 8000Hz:\n"
26"\n"
27" >>> source('/tmp/t.wav', samplerate = 8000)\n"
28"\n"
29" Create a new source, resampling it at 32000Hz, hop_size = 32:\n"
30"\n"
31" >>> source('/tmp/t.wav', samplerate = 32000, hop_size = 32)\n"
32"\n"
33" Create a new source, using its original samplerate:\n"
34"\n"
35" >>> source('/tmp/t.wav', samplerate = 0)\n"
36"\n"
37" __call__()\n"
38" vec, read = x() <==> vec, read = x.do()\n"
39"\n"
40" Read vector from source.\n"
41"\n"
42" See also\n"
43" --------\n"
44" aubio.source.do\n"
45"\n";
46
47static char Py_source_get_samplerate_doc[] = ""
48"x.get_samplerate() -> source samplerate\n"
49"\n"
50"Get samplerate of source.";
51
52static char Py_source_get_channels_doc[] = ""
53"x.get_channels() -> number of channels\n"
54"\n"
55"Get number of channels in source.";
56
57static char Py_source_do_doc[] = ""
58"vec, read = x.do() <==> vec, read = x()\n"
59"\n"
60"Read monophonic vector from source.";
61
62static char Py_source_do_multi_doc[] = ""
63"mat, read = x.do_multi()\n"
64"\n"
65"Read polyphonic vector from source.";
66
67static char Py_source_close_doc[] = ""
68"x.close()\n"
69"\n"
70"Close this source now.";
14 71
15static PyObject *72static PyObject *
16Py_source_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)73Py_source_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
@@ -135,10 +192,14 @@ Py_source_do_multi(Py_source * self, PyObject * args) · 118 unmodified lines
135}192}
136 193
137AUBIO_MEMBERS_START(source)194AUBIO_MEMBERS_START(source)
138 {"uri", T_STRING, offsetof (Py_source, uri), READONLY, ""},195 {"uri", T_STRING, offsetof (Py_source, uri), READONLY,
139 {"samplerate", T_INT, offsetof (Py_source, samplerate), READONLY, ""},196 "path at which the source was created"},
140 {"channels", T_INT, offsetof (Py_source, channels), READONLY, ""},197 {"samplerate", T_INT, offsetof (Py_source, samplerate), READONLY,
141 {"hop_size", T_INT, offsetof (Py_source, hop_size), READONLY, ""},198 "samplerate at which the source is viewed"},
199 {"channels", T_INT, offsetof (Py_source, channels), READONLY,
200 "number of channels found in the source"},
201 {"hop_size", T_INT, offsetof (Py_source, hop_size), READONLY,
202 "number of consecutive frames that will be read at each do or do_multi call"},
142AUBIO_MEMBERS_STOP(source)203AUBIO_MEMBERS_STOP(source)
143 204
144 205
@@ -165,13 +226,15 @@ Pyaubio_source_close (Py_source *self, PyObject *unused) · 20 unmodified lines
165 226
166static PyMethodDef Py_source_methods[] = {227static PyMethodDef Py_source_methods[] = {
167 {"get_samplerate", (PyCFunction) Pyaubio_source_get_samplerate,228 {"get_samplerate", (PyCFunction) Pyaubio_source_get_samplerate,
168 METH_NOARGS, ""},229 METH_NOARGS, Py_source_get_samplerate_doc},
169 {"get_channels", (PyCFunction) Pyaubio_source_get_channels,230 {"get_channels", (PyCFunction) Pyaubio_source_get_channels,
170 METH_NOARGS, ""},231 METH_NOARGS, Py_source_get_channels_doc},
232 {"do", (PyCFunction) Py_source_do,
233 METH_NOARGS, Py_source_do_doc},
171 {"do_multi", (PyCFunction) Py_source_do_multi,234 {"do_multi", (PyCFunction) Py_source_do_multi,
172 METH_NOARGS, ""},235 METH_NOARGS, Py_source_do_multi_doc},
173 {"close", (PyCFunction) Pyaubio_source_close,236 {"close", (PyCFunction) Pyaubio_source_close,
174 METH_NOARGS, ""},237 METH_NOARGS, Py_source_close_doc},
175 {NULL} /* sentinel */238 {NULL} /* sentinel */
176};239};
177 240

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