~ubuntu-branches/ubuntu/quantal/python-pyo/quantal

« back to all changes in this revision

Viewing changes to src/objects/hilbertmodule.c

  • Committer: Package Import Robot
  • Author(s): Tiago Bortoletto Vaz
  • Date: 2012-07-03 23:45:41 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120703234541-jh5jg00lvljnwq8m
Tags: 0.6.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
} HilbertMain;
39
39
 
40
40
/* 6th order allpass poles */
41
 
const MYFLT poles[12] = {.3609, 2.7412, 11.1573, 44.7581, 179.6242, 798.4578, 
 
41
static const MYFLT poles[12] = {.3609, 2.7412, 11.1573, 44.7581, 179.6242, 798.4578, 
42
42
                    1.2524, 5.5671, 22.3423, 89.6271, 364.7914, 2770.1114};
43
43
 
44
44
static void
124
124
static void
125
125
HilbertMain_dealloc(HilbertMain* self)
126
126
{
127
 
    free(self->data);
 
127
    pyo_DEALLOC
128
128
    free(self->buffer_streams);
129
129
    HilbertMain_clear(self);
130
130
    self->ob_type->tp_free((PyObject*)self);
131
131
}
132
132
 
133
 
static PyObject * HilbertMain_deleteStream(HilbertMain *self) { DELETE_STREAM };
134
 
 
135
133
static PyObject *
136
134
HilbertMain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
137
135
{
138
136
    int i;
 
137
    PyObject *inputtmp, *input_streamtmp;
139
138
    HilbertMain *self;
140
139
    self = (HilbertMain *)type->tp_alloc(type, 0);
141
140
    
148
147
        self->y1[i] = 0.0;
149
148
    }
150
149
 
151
 
    return (PyObject *)self;
152
 
}
153
 
 
154
 
static int
155
 
HilbertMain_init(HilbertMain *self, PyObject *args, PyObject *kwds)
156
 
{
157
 
    PyObject *inputtmp, *input_streamtmp;
158
 
    
159
150
    static char *kwlist[] = {"input", NULL};
160
151
    
161
152
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &inputtmp))
162
 
        return -1; 
 
153
        Py_RETURN_NONE;
163
154
 
164
155
    INIT_INPUT_STREAM
165
156
 
166
 
    Py_INCREF(self->stream);
167
157
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
168
158
 
169
159
    self->buffer_streams = (MYFLT *)realloc(self->buffer_streams, 2 * self->bufsize * sizeof(MYFLT));
171
161
    HilbertMain_compute_variables((HilbertMain *)self);
172
162
 
173
163
    (*self->mode_func_ptr)(self);
174
 
    
175
 
    Py_INCREF(self);
176
 
    return 0;
 
164
 
 
165
    return (PyObject *)self;
177
166
}
178
167
 
179
168
static PyObject * HilbertMain_getServer(HilbertMain* self) { GET_SERVER };
192
181
static PyMethodDef HilbertMain_methods[] = {
193
182
{"getServer", (PyCFunction)HilbertMain_getServer, METH_NOARGS, "Returns server object."},
194
183
{"_getStream", (PyCFunction)HilbertMain_getStream, METH_NOARGS, "Returns stream object."},
195
 
{"deleteStream", (PyCFunction)HilbertMain_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
196
184
{"play", (PyCFunction)HilbertMain_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
197
185
{"stop", (PyCFunction)HilbertMain_stop, METH_NOARGS, "Stops computing."},
198
186
{NULL}  /* Sentinel */
235
223
0,                                              /* tp_descr_get */
236
224
0,                                              /* tp_descr_set */
237
225
0,                                              /* tp_dictoffset */
238
 
(initproc)HilbertMain_init,                          /* tp_init */
 
226
0,                          /* tp_init */
239
227
0,                                              /* tp_alloc */
240
228
HilbertMain_new,                                     /* tp_new */
241
229
};
329
317
static void
330
318
Hilbert_dealloc(Hilbert* self)
331
319
{
332
 
    free(self->data);
 
320
    pyo_DEALLOC
333
321
    Hilbert_clear(self);
334
322
    self->ob_type->tp_free((PyObject*)self);
335
323
}
336
324
 
337
 
static PyObject * Hilbert_deleteStream(Hilbert *self) { DELETE_STREAM };
338
 
 
339
325
static PyObject *
340
326
Hilbert_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
341
327
{
342
328
    int i;
 
329
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
343
330
    Hilbert *self;
344
331
    self = (Hilbert *)type->tp_alloc(type, 0);
345
332
    
349
336
    INIT_OBJECT_COMMON
350
337
    Stream_setFunctionPtr(self->stream, Hilbert_compute_next_data_frame);
351
338
    self->mode_func_ptr = Hilbert_setProcMode;
352
 
    
353
 
    return (PyObject *)self;
354
 
}
355
339
 
356
 
static int
357
 
Hilbert_init(Hilbert *self, PyObject *args, PyObject *kwds)
358
 
{
359
 
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
360
 
    
361
340
    static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
362
341
    
363
342
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
364
 
        return -1; 
 
343
        Py_RETURN_NONE;
365
344
    
366
345
    Py_XDECREF(self->mainSplitter);
367
346
    Py_INCREF(maintmp);
375
354
        PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
376
355
    }
377
356
    
378
 
    Py_INCREF(self->stream);
379
357
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
380
358
    
381
359
    (*self->mode_func_ptr)(self);
382
 
        
383
 
    Py_INCREF(self);
384
 
    return 0;
 
360
    
 
361
    return (PyObject *)self;
385
362
}
386
363
 
387
364
static PyObject * Hilbert_getServer(Hilbert* self) { GET_SERVER };
415
392
static PyMethodDef Hilbert_methods[] = {
416
393
{"getServer", (PyCFunction)Hilbert_getServer, METH_NOARGS, "Returns server object."},
417
394
{"_getStream", (PyCFunction)Hilbert_getStream, METH_NOARGS, "Returns stream object."},
418
 
{"deleteStream", (PyCFunction)Hilbert_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
419
395
{"play", (PyCFunction)Hilbert_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
420
396
{"out", (PyCFunction)Hilbert_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
421
397
{"stop", (PyCFunction)Hilbert_stop, METH_NOARGS, "Stops computing."},
505
481
0,                         /* tp_descr_get */
506
482
0,                         /* tp_descr_set */
507
483
0,                         /* tp_dictoffset */
508
 
(initproc)Hilbert_init,      /* tp_init */
 
484
0,      /* tp_init */
509
485
0,                         /* tp_alloc */
510
486
Hilbert_new,                 /* tp_new */
511
487
};