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
70 70
71extern PyTypeObject Py_sourceType;71extern PyTypeObject Py_sourceType;
72 72
73extern PyTypeObject Py_sinkType;
python/ext/aubiomodule.c+3−0
@@ -199,6 +199,7 @@ init_aubio (void) · 198 unmodified lines
199 || (PyType_Ready (&Py_fftType) < 0)199 || (PyType_Ready (&Py_fftType) < 0)
200 || (PyType_Ready (&Py_pvocType) < 0)200 || (PyType_Ready (&Py_pvocType) < 0)
201 || (PyType_Ready (&Py_sourceType) < 0)201 || (PyType_Ready (&Py_sourceType) < 0)
202 || (PyType_Ready (&Py_sinkType) < 0)
202 // generated objects203 // generated objects
203 || (generated_types_ready() < 0 )204 || (generated_types_ready() < 0 )
204 ) {205 ) {
@@ -229,6 +230,8 @@ init_aubio (void) · 24 unmodified lines
229 PyModule_AddObject (m, "pvoc", (PyObject *) & Py_pvocType);230 PyModule_AddObject (m, "pvoc", (PyObject *) & Py_pvocType);
230 Py_INCREF (&Py_sourceType);231 Py_INCREF (&Py_sourceType);
231 PyModule_AddObject (m, "source", (PyObject *) & Py_sourceType);232 PyModule_AddObject (m, "source", (PyObject *) & Py_sourceType);
233 Py_INCREF (&Py_sinkType);
234 PyModule_AddObject (m, "sink", (PyObject *) & Py_sinkType);
232 235
233 // add generated objects236 // add generated objects
234 add_generated_objects(m);237 add_generated_objects(m);
python/ext/py-sink.c+97−0
@@ -0,0 +1,97 @@
1#include "aubiowraphell.h"
2
3typedef struct
4{
5 PyObject_HEAD
6 aubio_sink_t * o;
7 char_t* uri;
8 uint_t samplerate;
9} Py_sink;
10
11static char Py_sink_doc[] = "sink object";
12
13static PyObject *
14Py_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
49AUBIO_INIT(sink , self->uri, self->samplerate)
50
51AUBIO_DEL(sink)
52
53/* function Py_sink_do */
54static PyObject *
55Py_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
87AUBIO_MEMBERS_START(sink)
88 {"uri", T_STRING, offsetof (Py_sink, uri), READONLY, ""},
89 {"samplerate", T_INT, offsetof (Py_sink, samplerate), READONLY, ""},
90AUBIO_MEMBERS_STOP(sink)
91
92
93static PyMethodDef Py_sink_methods[] = {
94 {NULL} /* sentinel */
95};
96
97AUBIO_TYPEOBJECT(sink, "aubio.sink")
python/lib/generator.py+1−0
@@ -54,6 +54,7 @@ def generate_object_files(output_path): · 53 unmodified lines
54 'pitchspecacf',54 'pitchspecacf',
55 'pitchyin',55 'pitchyin',
56 'pitchyinfft',56 'pitchyinfft',
57 'sink',
57 'sink_apple_audio',58 'sink_apple_audio',
58 'sink_sndfile',59 'sink_sndfile',
59 'source',60 'source',
python/setup.py+1−0
@@ -54,6 +54,7 @@ aubio_extension = Extension("aubio._aubio", [ · 53 unmodified lines
54 "ext/py-fft.c",54 "ext/py-fft.c",
55 "ext/py-phasevoc.c",55 "ext/py-phasevoc.c",
56 "ext/py-source.c",56 "ext/py-source.c",
57 "ext/py-sink.c",
57 # generated files58 # generated files
58 ] + generated_object_files,59 ] + generated_object_files,
59 include_dirs = include_dirs,60 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