History

ext/py-sink.c: do not generate

Paul Brossier committed 12 years ago

Commit f1100a41 parent 9e58e785 files · +103 −0Browse files

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

Unified · Split

5 files
  1. python/ext/aubio-types.h +1 −0
  2. python/ext/aubiomodule.c +3 −0
  3. python/ext/py-sink.c +97 −0
  4. python/lib/generator.py +1 −0
  5. python/setup.py +1 −0
python/ext/aubio-types.h+1−0
@@ -70,3 +70,4 @@ extern PyTypeObject Py_pvocType; · 69 unmodified lines
7070
7171 extern PyTypeObject Py_sourceType;
7272
73+extern PyTypeObject Py_sinkType;
python/ext/aubiomodule.c+3−0
@@ -199,6 +199,7 @@ init_aubio (void) · 198 unmodified lines
199199 || (PyType_Ready (&Py_fftType) < 0)
200200 || (PyType_Ready (&Py_pvocType) < 0)
201201 || (PyType_Ready (&Py_sourceType) < 0)
202+ || (PyType_Ready (&Py_sinkType) < 0)
202203 // generated objects
203204 || (generated_types_ready() < 0 )
204205 ) {
@@ -229,6 +230,8 @@ init_aubio (void) · 24 unmodified lines
229230 PyModule_AddObject (m, "pvoc", (PyObject *) & Py_pvocType);
230231 Py_INCREF (&Py_sourceType);
231232 PyModule_AddObject (m, "source", (PyObject *) & Py_sourceType);
233+ Py_INCREF (&Py_sinkType);
234+ PyModule_AddObject (m, "sink", (PyObject *) & Py_sinkType);
232235
233236 // add generated objects
234237 add_generated_objects(m);
python/ext/py-sink.c+97−0
@@ -0,0 +1,97 @@
1+#include "aubiowraphell.h"
2+
3+typedef struct
4+{
5+ PyObject_HEAD
6+ aubio_sink_t * o;
7+ char_t* uri;
8+ uint_t samplerate;
9+} Py_sink;
10+
11+static char Py_sink_doc[] = "sink object";
12+
13+static PyObject *
14+Py_sink_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
15+{
16+ Py_sink *self;
17+ char_t* uri = NULL;
18+ uint_t samplerate = 0;
19+ static char *kwlist[] = { "uri", "samplerate", NULL };
20+
21+ if (!PyArg_ParseTupleAndKeywords (args, kwds, "|sI", kwlist,
22+ &uri, &samplerate)) {
23+ return NULL;
24+ }
25+
26+ self = (Py_sink *) pytype->tp_alloc (pytype, 0);
27+
28+ if (self == NULL) {
29+ return NULL;
30+ }
31+
32+ self->uri = "none";
33+ if (uri != NULL) {
34+ self->uri = uri;
35+ }
36+
37+ self->samplerate = Py_aubio_default_samplerate;
38+ if ((sint_t)samplerate > 0) {
39+ self->samplerate = samplerate;
40+ } else if ((sint_t)samplerate < 0) {
41+ PyErr_SetString (PyExc_ValueError,
42+ "can not use negative value for samplerate");
43+ return NULL;
44+ }
45+
46+ return (PyObject *) self;
47+}
48+
49+AUBIO_INIT(sink , self->uri, self->samplerate)
50+
51+AUBIO_DEL(sink)
52+
53+/* function Py_sink_do */
54+static PyObject *
55+Py_sink_do(Py_sink * self, PyObject * args)
56+{
57+ /* input vectors python prototypes */
58+ PyObject * write_data_obj;
59+
60+ /* input vectors prototypes */
61+ fvec_t* write_data;
62+ uint_t write;
63+
64+
65+ if (!PyArg_ParseTuple (args, "OI", &write_data_obj, &write)) {
66+ return NULL;
67+ }
68+
69+
70+ /* input vectors parsing */
71+ write_data = PyAubio_ArrayToCFvec (write_data_obj);
72+
73+ if (write_data == NULL) {
74+ return NULL;
75+ }
76+
77+
78+
79+
80+
81+ /* compute _do function */
82+ aubio_sink_do (self->o, write_data, write);
83+
84+ Py_RETURN_NONE;
85+}
86+
87+AUBIO_MEMBERS_START(sink)
88+ {"uri", T_STRING, offsetof (Py_sink, uri), READONLY, ""},
89+ {"samplerate", T_INT, offsetof (Py_sink, samplerate), READONLY, ""},
90+AUBIO_MEMBERS_STOP(sink)
91+
92+
93+static PyMethodDef Py_sink_methods[] = {
94+ {NULL} /* sentinel */
95+};
96+
97+AUBIO_TYPEOBJECT(sink, "aubio.sink")
python/lib/generator.py+1−0
@@ -54,6 +54,7 @@ def generate_object_files(output_path): · 53 unmodified lines
5454 'pitchspecacf',
5555 'pitchyin',
5656 'pitchyinfft',
57+ 'sink',
5758 'sink_apple_audio',
5859 'sink_sndfile',
5960 'source',
python/setup.py+1−0
@@ -54,6 +54,7 @@ aubio_extension = Extension("aubio._aubio", [ · 53 unmodified lines
5454 "ext/py-fft.c",
5555 "ext/py-phasevoc.c",
5656 "ext/py-source.c",
57+ "ext/py-sink.c",
5758 # generated files
5859 ] + generated_object_files,
5960 include_dirs = include_dirs,

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