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

« back to all changes in this revision

Viewing changes to src/objects/patternmodule.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:
129
129
static void
130
130
Pattern_dealloc(Pattern* self)
131
131
{
132
 
    free(self->data);
 
132
    pyo_DEALLOC
133
133
    Pattern_clear(self);
134
134
    self->ob_type->tp_free((PyObject*)self);
135
135
}
136
136
 
137
 
static PyObject * Pattern_deleteStream(Pattern *self) { DELETE_STREAM };
138
 
 
139
137
static PyObject *
140
138
Pattern_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
141
139
{
142
140
    int i;
 
141
    PyObject *timetmp=NULL, *calltmp=NULL;
143
142
    Pattern *self;
144
143
    self = (Pattern *)type->tp_alloc(type, 0);
145
144
    
155
154
    
156
155
    self->sampleToSec = 1. / self->sr;
157
156
    self->currentTime = 0.;
158
 
    
159
 
    return (PyObject *)self;
160
 
}
161
157
 
162
 
static int
163
 
Pattern_init(Pattern *self, PyObject *args, PyObject *kwds)
164
 
{
165
 
    PyObject *timetmp=NULL, *calltmp=NULL;
166
 
    
167
158
    static char *kwlist[] = {"callable", "time", NULL};
168
159
    
169
160
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|O", kwlist, &calltmp, &timetmp))
170
 
        return -1; 
 
161
        Py_RETURN_NONE;
171
162
   
172
163
    if (calltmp) {
173
164
        PyObject_CallMethod((PyObject *)self, "setFunction", "O", calltmp);
177
168
        PyObject_CallMethod((PyObject *)self, "setTime", "O", timetmp);
178
169
    }
179
170
    
180
 
    Py_INCREF(self->stream);
181
171
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
182
172
 
183
173
    (*self->mode_func_ptr)(self);
184
 
        
185
 
    Py_INCREF(self);
186
 
    return 0;
 
174
    
 
175
    return (PyObject *)self;
187
176
}
188
177
 
189
178
static PyObject * Pattern_getServer(Pattern* self) { GET_SERVER };
262
251
static PyMethodDef Pattern_methods[] = {
263
252
{"getServer", (PyCFunction)Pattern_getServer, METH_NOARGS, "Returns server object."},
264
253
{"_getStream", (PyCFunction)Pattern_getStream, METH_NOARGS, "Returns stream object."},
265
 
{"deleteStream", (PyCFunction)Pattern_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
266
254
{"play", (PyCFunction)Pattern_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
267
255
{"stop", (PyCFunction)Pattern_stop, METH_NOARGS, "Stops computing."},
268
256
{"setTime", (PyCFunction)Pattern_setTime, METH_O, "Sets time factor."},
307
295
0,                         /* tp_descr_get */
308
296
0,                         /* tp_descr_set */
309
297
0,                         /* tp_dictoffset */
310
 
(initproc)Pattern_init,      /* tp_init */
 
298
0,      /* tp_init */
311
299
0,                         /* tp_alloc */
312
300
Pattern_new,                 /* tp_new */
313
301
};
373
361
static void
374
362
Score_dealloc(Score* self)
375
363
{
376
 
    free(self->data);
377
 
        free(self->curfname);
 
364
    pyo_DEALLOC
378
365
    Score_clear(self);
379
366
    self->ob_type->tp_free((PyObject*)self);
380
367
}
381
368
 
382
 
static PyObject * Score_deleteStream(Score *self) { DELETE_STREAM };
383
 
 
384
369
static PyObject *
385
370
Score_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
386
371
{
387
372
    int i;
 
373
    PyObject *inputtmp, *input_streamtmp;
388
374
    Score *self;
389
375
    self = (Score *)type->tp_alloc(type, 0);
390
376
    
393
379
    INIT_OBJECT_COMMON
394
380
    Stream_setFunctionPtr(self->stream, Score_compute_next_data_frame);
395
381
    self->mode_func_ptr = Score_setProcMode;
396
 
    
397
 
    return (PyObject *)self;
398
 
}
399
382
 
400
 
static int
401
 
Score_init(Score *self, PyObject *args, PyObject *kwds)
402
 
{
403
 
    PyObject *inputtmp, *input_streamtmp;
404
 
    
405
383
    static char *kwlist[] = {"input", "fname", NULL};
406
384
    
407
385
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|s", kwlist, &inputtmp, &self->fname))
408
 
        return -1; 
 
386
        Py_RETURN_NONE;
409
387
    
410
388
    INIT_INPUT_STREAM
411
389
    
412
 
    Py_INCREF(self->stream);
413
390
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
414
391
        
415
392
    (*self->mode_func_ptr)(self);
416
393
    
417
 
    Py_INCREF(self);
418
 
    return 0;
 
394
    return (PyObject *)self;
419
395
}
420
396
 
421
397
static PyObject * Score_getServer(Score* self) { GET_SERVER };
433
409
static PyMethodDef Score_methods[] = {
434
410
{"getServer", (PyCFunction)Score_getServer, METH_NOARGS, "Returns server object."},
435
411
{"_getStream", (PyCFunction)Score_getStream, METH_NOARGS, "Returns stream object."},
436
 
{"deleteStream", (PyCFunction)Score_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
437
412
{"play", (PyCFunction)Score_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
438
413
{"stop", (PyCFunction)Score_stop, METH_NOARGS, "Stops computing."},
439
414
{NULL}  /* Sentinel */
476
451
0,                         /* tp_descr_get */
477
452
0,                         /* tp_descr_set */
478
453
0,                         /* tp_dictoffset */
479
 
(initproc)Score_init,      /* tp_init */
 
454
0,      /* tp_init */
480
455
0,                         /* tp_alloc */
481
456
Score_new,                 /* tp_new */
482
457
};
549
524
static void
550
525
CallAfter_dealloc(CallAfter* self)
551
526
{
552
 
    free(self->data);
 
527
    pyo_DEALLOC
553
528
    CallAfter_clear(self);
554
529
    self->ob_type->tp_free((PyObject*)self);
555
530
}
556
531
 
557
 
static PyObject * CallAfter_deleteStream(CallAfter *self) { DELETE_STREAM };
558
 
 
559
532
static PyObject *
560
533
CallAfter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
561
534
{
562
535
    int i;
 
536
    PyObject *calltmp=NULL, *argtmp=NULL;
563
537
    CallAfter *self;
564
538
    self = (CallAfter *)type->tp_alloc(type, 0);
565
539
    
572
546
 
573
547
    self->sampleToSec = 1. / self->sr;
574
548
    self->currentTime = 0.;
575
 
    
576
 
    return (PyObject *)self;
577
 
}
578
549
 
579
 
static int
580
 
CallAfter_init(CallAfter *self, PyObject *args, PyObject *kwds)
581
 
{
582
 
    PyObject *calltmp=NULL, *argtmp=NULL;
583
 
    
584
550
    static char *kwlist[] = {"callable", "time", "arg", NULL};
585
551
    
586
552
    if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_FO, kwlist, &calltmp, &self->time, &argtmp))
587
 
        return -1; 
 
553
        Py_RETURN_NONE;
588
554
    
589
555
    if (! PyCallable_Check(calltmp))
590
 
        return -1;
 
556
        Py_RETURN_NONE;
591
557
 
592
558
    if (argtmp) {
593
559
        Py_DECREF(self->arg);
595
561
        self->arg = argtmp;
596
562
    }
597
563
    
 
564
    Py_INCREF(calltmp);
598
565
    Py_XDECREF(self->callable);
599
566
    self->callable = calltmp;
600
567
 
601
 
    Py_INCREF(self->stream);
602
568
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
603
569
    
604
570
    (*self->mode_func_ptr)(self);
605
 
        
606
 
    Py_INCREF(self);
607
 
    return 0;
 
571
    
 
572
    return (PyObject *)self;
608
573
}
609
574
 
610
575
static PyObject * CallAfter_getServer(CallAfter* self) { GET_SERVER };
622
587
static PyMethodDef CallAfter_methods[] = {
623
588
{"getServer", (PyCFunction)CallAfter_getServer, METH_NOARGS, "Returns server object."},
624
589
{"_getStream", (PyCFunction)CallAfter_getStream, METH_NOARGS, "Returns stream object."},
625
 
{"deleteStream", (PyCFunction)CallAfter_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
626
590
{"play", (PyCFunction)CallAfter_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
627
591
{"stop", (PyCFunction)CallAfter_stop, METH_NOARGS, "Stops computing."},
628
592
{NULL}  /* Sentinel */
665
629
0,                         /* tp_descr_get */
666
630
0,                         /* tp_descr_set */
667
631
0,                         /* tp_dictoffset */
668
 
(initproc)CallAfter_init,      /* tp_init */
 
632
0,      /* tp_init */
669
633
0,                         /* tp_alloc */
670
634
CallAfter_new,                 /* tp_new */
671
635
};