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

« back to all changes in this revision

Viewing changes to src/objects/panmodule.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:
265
265
static void
266
266
Panner_dealloc(Panner* self)
267
267
{
268
 
    free(self->data);
 
268
    pyo_DEALLOC
269
269
    free(self->buffer_streams);
270
270
    Panner_clear(self);
271
271
    self->ob_type->tp_free((PyObject*)self);
272
272
}
273
273
 
274
 
static PyObject * Panner_deleteStream(Panner *self) { DELETE_STREAM };
275
 
 
276
274
static PyObject *
277
275
Panner_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
278
276
{
279
277
    int i;
 
278
    PyObject *inputtmp, *input_streamtmp, *pantmp=NULL, *spreadtmp=NULL;
280
279
    Panner *self;
281
280
    self = (Panner *)type->tp_alloc(type, 0);
282
281
    
290
289
    self->modebuffer[0] = 0;
291
290
    self->modebuffer[1] = 0;
292
291
 
293
 
    return (PyObject *)self;
294
 
}
295
 
 
296
 
static int
297
 
Panner_init(Panner *self, PyObject *args, PyObject *kwds)
298
 
{
299
 
    PyObject *inputtmp, *input_streamtmp, *pantmp=NULL, *spreadtmp=NULL;
300
 
 
301
292
    static char *kwlist[] = {"input", "outs", "pan", "spread", NULL};
302
293
 
303
294
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iOO", kwlist, &inputtmp, &self->chnls, &pantmp, &spreadtmp))
304
 
        return -1; 
 
295
        Py_RETURN_NONE;
305
296
 
306
297
    INIT_INPUT_STREAM
307
298
 
313
304
        PyObject_CallMethod((PyObject *)self, "setSpread", "O", spreadtmp);
314
305
    }
315
306
 
316
 
    Py_INCREF(self->stream);
317
307
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
318
308
 
319
309
    if (self->chnls < 1)
323
313
 
324
314
    (*self->mode_func_ptr)(self);
325
315
 
326
 
    Py_INCREF(self);
327
 
    return 0;
 
316
    return (PyObject *)self;
328
317
}
329
318
 
330
319
static PyObject * Panner_getServer(Panner* self) { GET_SERVER };
413
402
static PyMethodDef Panner_methods[] = {
414
403
{"getServer", (PyCFunction)Panner_getServer, METH_NOARGS, "Returns server object."},
415
404
{"_getStream", (PyCFunction)Panner_getStream, METH_NOARGS, "Returns stream object."},
416
 
{"deleteStream", (PyCFunction)Panner_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
417
405
{"play", (PyCFunction)Panner_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
418
406
{"stop", (PyCFunction)Panner_stop, METH_NOARGS, "Stops computing."},
419
407
{"setPan", (PyCFunction)Panner_setPan, METH_O, "Sets panning value between 0 and 1."},
458
446
0,                                              /* tp_descr_get */
459
447
0,                                              /* tp_descr_set */
460
448
0,                                              /* tp_dictoffset */
461
 
(initproc)Panner_init,                          /* tp_init */
 
449
0,                          /* tp_init */
462
450
0,                                              /* tp_alloc */
463
451
Panner_new,                                     /* tp_new */
464
452
};
552
540
static void
553
541
Pan_dealloc(Pan* self)
554
542
{
555
 
    free(self->data);
 
543
    pyo_DEALLOC
556
544
    Pan_clear(self);
557
545
    self->ob_type->tp_free((PyObject*)self);
558
546
}
559
547
 
560
 
static PyObject * Pan_deleteStream(Pan *self) { DELETE_STREAM };
561
 
 
562
548
static PyObject *
563
549
Pan_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
564
550
{
565
551
    int i;
 
552
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
566
553
    Pan *self;
567
554
    self = (Pan *)type->tp_alloc(type, 0);
568
555
    
572
559
    INIT_OBJECT_COMMON
573
560
    Stream_setFunctionPtr(self->stream, Pan_compute_next_data_frame);
574
561
    self->mode_func_ptr = Pan_setProcMode;
575
 
    
576
 
    return (PyObject *)self;
577
 
}
578
562
 
579
 
static int
580
 
Pan_init(Pan *self, PyObject *args, PyObject *kwds)
581
 
{
582
 
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
583
 
    
584
563
    static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
585
564
    
586
565
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
587
 
        return -1; 
 
566
        Py_RETURN_NONE;
588
567
    
589
568
    Py_XDECREF(self->mainSplitter);
590
569
    Py_INCREF(maintmp);
598
577
        PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
599
578
    }
600
579
    
601
 
    Py_INCREF(self->stream);
602
580
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
603
581
    
604
582
    (*self->mode_func_ptr)(self);
605
 
        
606
 
    Py_INCREF(self);
607
 
    return 0;
 
583
    
 
584
    return (PyObject *)self;
608
585
}
609
586
 
610
587
static PyObject * Pan_getServer(Pan* self) { GET_SERVER };
638
615
static PyMethodDef Pan_methods[] = {
639
616
{"getServer", (PyCFunction)Pan_getServer, METH_NOARGS, "Returns server object."},
640
617
{"_getStream", (PyCFunction)Pan_getStream, METH_NOARGS, "Returns stream object."},
641
 
{"deleteStream", (PyCFunction)Pan_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
642
618
{"play", (PyCFunction)Pan_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
643
619
{"out", (PyCFunction)Pan_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
644
620
{"stop", (PyCFunction)Pan_stop, METH_NOARGS, "Stops computing."},
728
704
0,                         /* tp_descr_get */
729
705
0,                         /* tp_descr_set */
730
706
0,                         /* tp_dictoffset */
731
 
(initproc)Pan_init,      /* tp_init */
 
707
0,      /* tp_init */
732
708
0,                         /* tp_alloc */
733
709
Pan_new,                 /* tp_new */
734
710
};
946
922
static void
947
923
SPanner_dealloc(SPanner* self)
948
924
{
949
 
    free(self->data);
 
925
    pyo_DEALLOC
950
926
    free(self->buffer_streams);
951
927
    SPanner_clear(self);
952
928
    self->ob_type->tp_free((PyObject*)self);
953
929
}
954
930
 
955
 
static PyObject * SPanner_deleteStream(SPanner *self) { DELETE_STREAM };
956
 
 
957
931
static PyObject *
958
932
SPanner_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
959
933
{
960
934
    int i;
 
935
    PyObject *inputtmp, *input_streamtmp, *pantmp=NULL;
961
936
    SPanner *self;
962
937
    self = (SPanner *)type->tp_alloc(type, 0);
963
938
    
970
945
    self->k1 = 0;
971
946
    self->k2 = self->bufsize;
972
947
    self->modebuffer[0] = 0;
973
 
    
974
 
    return (PyObject *)self;
975
 
}
976
948
 
977
 
static int
978
 
SPanner_init(SPanner *self, PyObject *args, PyObject *kwds)
979
 
{
980
 
    int i;
981
 
    PyObject *inputtmp, *input_streamtmp, *pantmp=NULL;
982
 
    
983
949
    static char *kwlist[] = {"input", "outs", "pan", NULL};
984
950
    
985
951
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iO", kwlist, &inputtmp, &self->chnls, &pantmp))
986
 
        return -1; 
 
952
        Py_RETURN_NONE;
987
953
    
988
954
    INIT_INPUT_STREAM
989
955
    
991
957
        PyObject_CallMethod((PyObject *)self, "setPan", "O", pantmp);
992
958
    }
993
959
 
994
 
    Py_INCREF(self->stream);
995
960
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
996
961
 
997
962
    if (self->chnls < 1)
1005
970
    for (i=0; i<len; i++) {
1006
971
        self->buffer_streams[i] = 0.0;
1007
972
    }
1008
 
 
1009
 
    Py_INCREF(self);
1010
 
    return 0;
 
973
    
 
974
    return (PyObject *)self;
1011
975
}
1012
976
 
1013
977
static PyObject * SPanner_getServer(SPanner* self) { GET_SERVER };
1061
1025
static PyMethodDef SPanner_methods[] = {
1062
1026
{"getServer", (PyCFunction)SPanner_getServer, METH_NOARGS, "Returns server object."},
1063
1027
{"_getStream", (PyCFunction)SPanner_getStream, METH_NOARGS, "Returns stream object."},
1064
 
{"deleteStream", (PyCFunction)SPanner_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
1065
1028
{"play", (PyCFunction)SPanner_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
1066
1029
{"stop", (PyCFunction)SPanner_stop, METH_NOARGS, "Stops computing."},
1067
1030
{"setPan", (PyCFunction)SPanner_setPan, METH_O, "Sets panning value between 0 and 1."},
1105
1068
0,                                              /* tp_descr_get */
1106
1069
0,                                              /* tp_descr_set */
1107
1070
0,                                              /* tp_dictoffset */
1108
 
(initproc)SPanner_init,                          /* tp_init */
 
1071
0,                          /* tp_init */
1109
1072
0,                                              /* tp_alloc */
1110
1073
SPanner_new,                                     /* tp_new */
1111
1074
};
1199
1162
static void
1200
1163
SPan_dealloc(SPan* self)
1201
1164
{
1202
 
    free(self->data);
 
1165
    pyo_DEALLOC
1203
1166
    SPan_clear(self);
1204
1167
    self->ob_type->tp_free((PyObject*)self);
1205
1168
}
1206
1169
 
1207
 
static PyObject * SPan_deleteStream(SPan *self) { DELETE_STREAM };
1208
 
 
1209
1170
static PyObject *
1210
1171
SPan_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1211
1172
{
1212
1173
    int i;
 
1174
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
1213
1175
    SPan *self;
1214
1176
    self = (SPan *)type->tp_alloc(type, 0);
1215
1177
    
1219
1181
    INIT_OBJECT_COMMON
1220
1182
    Stream_setFunctionPtr(self->stream, SPan_compute_next_data_frame);
1221
1183
    self->mode_func_ptr = SPan_setProcMode;
1222
 
    
1223
 
    return (PyObject *)self;
1224
 
}
1225
1184
 
1226
 
static int
1227
 
SPan_init(SPan *self, PyObject *args, PyObject *kwds)
1228
 
{
1229
 
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
1230
 
    
1231
1185
    static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
1232
1186
    
1233
1187
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
1234
 
        return -1; 
 
1188
        Py_RETURN_NONE;
1235
1189
    
1236
1190
    Py_XDECREF(self->mainSplitter);
1237
1191
    Py_INCREF(maintmp);
1245
1199
        PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
1246
1200
    }
1247
1201
    
1248
 
    Py_INCREF(self->stream);
1249
1202
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
1250
1203
    
1251
1204
    (*self->mode_func_ptr)(self);
1252
1205
    
1253
 
    Py_INCREF(self);
1254
 
    return 0;
 
1206
    return (PyObject *)self;
1255
1207
}
1256
1208
 
1257
1209
static PyObject * SPan_getServer(SPan* self) { GET_SERVER };
1285
1237
static PyMethodDef SPan_methods[] = {
1286
1238
{"getServer", (PyCFunction)SPan_getServer, METH_NOARGS, "Returns server object."},
1287
1239
{"_getStream", (PyCFunction)SPan_getStream, METH_NOARGS, "Returns stream object."},
1288
 
{"deleteStream", (PyCFunction)SPan_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
1289
1240
{"play", (PyCFunction)SPan_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
1290
1241
{"out", (PyCFunction)SPan_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
1291
1242
{"stop", (PyCFunction)SPan_stop, METH_NOARGS, "Stops computing."},
1375
1326
0,                         /* tp_descr_get */
1376
1327
0,                         /* tp_descr_set */
1377
1328
0,                         /* tp_dictoffset */
1378
 
(initproc)SPan_init,      /* tp_init */
 
1329
0,      /* tp_init */
1379
1330
0,                         /* tp_alloc */
1380
1331
SPan_new,                 /* tp_new */
1381
1332
};
1523
1474
static void
1524
1475
Switcher_dealloc(Switcher* self)
1525
1476
{
1526
 
    free(self->data);
 
1477
    pyo_DEALLOC
1527
1478
    free(self->buffer_streams);
1528
1479
    Switcher_clear(self);
1529
1480
    self->ob_type->tp_free((PyObject*)self);
1530
1481
}
1531
1482
 
1532
 
static PyObject * Switcher_deleteStream(Switcher *self) { DELETE_STREAM };
1533
 
 
1534
1483
static PyObject *
1535
1484
Switcher_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1536
1485
{
1537
1486
    int i;
 
1487
    PyObject *inputtmp, *input_streamtmp, *voicetmp=NULL;
1538
1488
    Switcher *self;
1539
1489
    self = (Switcher *)type->tp_alloc(type, 0);
1540
1490
    
1547
1497
    self->k1 = 0;
1548
1498
    self->k2 = self->bufsize;
1549
1499
    self->modebuffer[0] = 0;
1550
 
    
1551
 
    return (PyObject *)self;
1552
 
}
1553
1500
 
1554
 
static int
1555
 
Switcher_init(Switcher *self, PyObject *args, PyObject *kwds)
1556
 
{
1557
 
    int i;
1558
 
    PyObject *inputtmp, *input_streamtmp, *voicetmp=NULL;
1559
 
    
1560
1501
    static char *kwlist[] = {"input", "outs", "voice", NULL};
1561
1502
    
1562
1503
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iO", kwlist, &inputtmp, &self->chnls, &voicetmp))
1563
 
        return -1; 
 
1504
        Py_RETURN_NONE;
1564
1505
    
1565
1506
    INIT_INPUT_STREAM
1566
1507
    
1568
1509
        PyObject_CallMethod((PyObject *)self, "setVoice", "O", voicetmp);
1569
1510
    }
1570
1511
    
1571
 
    Py_INCREF(self->stream);
1572
1512
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
1573
1513
    
1574
1514
    self->buffer_streams = (MYFLT *)realloc(self->buffer_streams, self->chnls * self->bufsize * sizeof(MYFLT));
1579
1519
    for (i=0; i<len; i++) {
1580
1520
        self->buffer_streams[i] = 0.0;
1581
1521
    }
1582
 
        
1583
 
    Py_INCREF(self);
1584
 
    return 0;
 
1522
    
 
1523
    return (PyObject *)self;
1585
1524
}
1586
1525
 
1587
1526
static PyObject * Switcher_getServer(Switcher* self) { GET_SERVER };
1635
1574
static PyMethodDef Switcher_methods[] = {
1636
1575
    {"getServer", (PyCFunction)Switcher_getServer, METH_NOARGS, "Returns server object."},
1637
1576
    {"_getStream", (PyCFunction)Switcher_getStream, METH_NOARGS, "Returns stream object."},
1638
 
    {"deleteStream", (PyCFunction)Switcher_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
1639
1577
    {"play", (PyCFunction)Switcher_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
1640
1578
    {"stop", (PyCFunction)Switcher_stop, METH_NOARGS, "Stops computing."},
1641
1579
    {"setVoice", (PyCFunction)Switcher_setVoice, METH_O, "Sets voice value between 0 and outs-1."},
1679
1617
    0,                                              /* tp_descr_get */
1680
1618
    0,                                              /* tp_descr_set */
1681
1619
    0,                                              /* tp_dictoffset */
1682
 
    (initproc)Switcher_init,                          /* tp_init */
 
1620
    0,                          /* tp_init */
1683
1621
    0,                                              /* tp_alloc */
1684
1622
    Switcher_new,                                     /* tp_new */
1685
1623
};
1773
1711
static void
1774
1712
Switch_dealloc(Switch* self)
1775
1713
{
1776
 
    free(self->data);
 
1714
    pyo_DEALLOC
1777
1715
    Switch_clear(self);
1778
1716
    self->ob_type->tp_free((PyObject*)self);
1779
1717
}
1780
1718
 
1781
 
static PyObject * Switch_deleteStream(Switch *self) { DELETE_STREAM };
1782
 
 
1783
1719
static PyObject *
1784
1720
Switch_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1785
1721
{
1786
1722
    int i;
 
1723
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
1787
1724
    Switch *self;
1788
1725
    self = (Switch *)type->tp_alloc(type, 0);
1789
1726
    
1793
1730
    INIT_OBJECT_COMMON
1794
1731
    Stream_setFunctionPtr(self->stream, Switch_compute_next_data_frame);
1795
1732
    self->mode_func_ptr = Switch_setProcMode;
1796
 
    
1797
 
    return (PyObject *)self;
1798
 
}
1799
1733
 
1800
 
static int
1801
 
Switch_init(Switch *self, PyObject *args, PyObject *kwds)
1802
 
{
1803
 
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
1804
 
    
1805
1734
    static char *kwlist[] = {"mainSplitter", "chnl", "mul", "add", NULL};
1806
1735
    
1807
1736
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
1808
 
        return -1; 
 
1737
        Py_RETURN_NONE;
1809
1738
    
1810
1739
    Py_XDECREF(self->mainSplitter);
1811
1740
    Py_INCREF(maintmp);
1819
1748
        PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
1820
1749
    }
1821
1750
    
1822
 
    Py_INCREF(self->stream);
1823
1751
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
1824
1752
    
1825
1753
    (*self->mode_func_ptr)(self);
1826
 
        
1827
 
    Py_INCREF(self);
1828
 
    return 0;
 
1754
    
 
1755
    return (PyObject *)self;
1829
1756
}
1830
1757
 
1831
1758
static PyObject * Switch_getServer(Switch* self) { GET_SERVER };
1859
1786
static PyMethodDef Switch_methods[] = {
1860
1787
    {"getServer", (PyCFunction)Switch_getServer, METH_NOARGS, "Returns server object."},
1861
1788
    {"_getStream", (PyCFunction)Switch_getStream, METH_NOARGS, "Returns stream object."},
1862
 
    {"deleteStream", (PyCFunction)Switch_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
1863
1789
    {"play", (PyCFunction)Switch_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
1864
1790
    {"out", (PyCFunction)Switch_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
1865
1791
    {"stop", (PyCFunction)Switch_stop, METH_NOARGS, "Stops computing."},
1949
1875
    0,                         /* tp_descr_get */
1950
1876
    0,                         /* tp_descr_set */
1951
1877
    0,                         /* tp_dictoffset */
1952
 
    (initproc)Switch_init,      /* tp_init */
 
1878
    0,      /* tp_init */
1953
1879
    0,                         /* tp_alloc */
1954
1880
    Switch_new,                 /* tp_new */
1955
1881
};
2074
2000
static void
2075
2001
VoiceManager_dealloc(VoiceManager* self)
2076
2002
{
2077
 
    free(self->data);
 
2003
    pyo_DEALLOC
 
2004
    if (self->voices != NULL)
 
2005
        free(self->voices);
2078
2006
    VoiceManager_clear(self);
2079
2007
    self->ob_type->tp_free((PyObject*)self);
2080
2008
}
2081
2009
 
2082
 
static PyObject * VoiceManager_deleteStream(VoiceManager *self) { DELETE_STREAM };
2083
 
 
2084
2010
static PyObject *
2085
2011
VoiceManager_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
2086
2012
{
2087
2013
    int i;
 
2014
    PyObject *inputtmp, *input_streamtmp, *triggerstmp=NULL, *multmp=NULL, *addtmp=NULL;
2088
2015
    VoiceManager *self;
2089
2016
    self = (VoiceManager *)type->tp_alloc(type, 0);
2090
2017
 
 
2018
    self->voices = NULL;
2091
2019
    self->maxVoices = 0; 
2092
2020
        self->modebuffer[0] = 0;
2093
2021
        self->modebuffer[1] = 0;
2095
2023
    INIT_OBJECT_COMMON
2096
2024
    Stream_setFunctionPtr(self->stream, VoiceManager_compute_next_data_frame);
2097
2025
    self->mode_func_ptr = VoiceManager_setProcMode;
2098
 
    return (PyObject *)self;
2099
 
}
2100
2026
 
2101
 
static int
2102
 
VoiceManager_init(VoiceManager *self, PyObject *args, PyObject *kwds)
2103
 
{
2104
 
    PyObject *inputtmp, *input_streamtmp, *triggerstmp=NULL, *multmp=NULL, *addtmp=NULL;
2105
 
    
2106
2027
    static char *kwlist[] = {"input", "triggers", "mul", "add", NULL};
2107
2028
 
2108
2029
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputtmp, &triggerstmp, &multmp, &addtmp))
2109
 
        return -1; 
 
2030
        Py_RETURN_NONE;
2110
2031
   
2111
2032
    INIT_INPUT_STREAM
2112
2033
    
2113
2034
    if (triggerstmp && triggerstmp != Py_None) {
2114
 
        printf("fuck\n");
2115
2035
        PyObject_CallMethod((PyObject *)self, "setTriggers", "O", triggerstmp);
2116
2036
    }
2117
2037
    
2123
2043
        PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
2124
2044
    }
2125
2045
    
2126
 
    Py_INCREF(self->stream);
2127
2046
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
2128
2047
 
2129
2048
    (*self->mode_func_ptr)(self);
2130
 
        
2131
 
    Py_INCREF(self);
2132
 
    return 0;
 
2049
 
 
2050
    return (PyObject *)self;
2133
2051
}
2134
2052
 
2135
2053
static PyObject * VoiceManager_getServer(VoiceManager* self) { GET_SERVER };
2170
2088
        self->voices[i] = 0;
2171
2089
    }
2172
2090
 
2173
 
        Py_INCREF(Py_None);
2174
 
        return Py_None;
 
2091
    Py_RETURN_NONE;
2175
2092
}       
2176
2093
 
2177
2094
static PyMemberDef VoiceManager_members[] = {
2187
2104
static PyMethodDef VoiceManager_methods[] = {
2188
2105
{"getServer", (PyCFunction)VoiceManager_getServer, METH_NOARGS, "Returns server object."},
2189
2106
{"_getStream", (PyCFunction)VoiceManager_getStream, METH_NOARGS, "Returns stream object."},
2190
 
{"deleteStream", (PyCFunction)VoiceManager_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
2191
2107
{"play", (PyCFunction)VoiceManager_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
2192
2108
{"stop", (PyCFunction)VoiceManager_stop, METH_NOARGS, "Stops computing."},
2193
2109
{"setTriggers", (PyCFunction)VoiceManager_setTriggers, METH_O, "Sets list of trigger streams."},
2277
2193
0,                                              /* tp_descr_get */
2278
2194
0,                                              /* tp_descr_set */
2279
2195
0,                                              /* tp_dictoffset */
2280
 
(initproc)VoiceManager_init,                          /* tp_init */
 
2196
0,                          /* tp_init */
2281
2197
0,                                              /* tp_alloc */
2282
2198
VoiceManager_new,                                     /* tp_new */
2283
2199
};
2314
2230
    keys = PyDict_Keys(self->inputs);
2315
2231
    num = PyList_Size(keys);
2316
2232
 
2317
 
    if (num == 0)
2318
 
        return;
2319
 
 
2320
2233
    for (j=0; j<num; j++) {
2321
 
        key = PyList_GET_ITEM(keys, j);
 
2234
        key = PyList_GetItem(keys, j);
2322
2235
        MYFLT *st = Stream_getData((Stream *)PyObject_CallMethod((PyObject *)PyDict_GetItem(self->inputs, key), "_getStream", NULL));
2323
2236
        list_of_gains = PyDict_GetItem(self->gains, key);
2324
2237
        list_of_last_gains = PyDict_GetItem(self->lastGains, key);
2326
2239
        list_of_step_vals = PyDict_GetItem(self->stepVals, key);
2327
2240
        list_of_time_counts = PyDict_GetItem(self->timeCounts, key);
2328
2241
        for (k=0; k<self->num_outs; k++) {
2329
 
            amp = (MYFLT)PyFloat_AS_DOUBLE(PyList_GET_ITEM(list_of_gains, k));
2330
 
            lastAmp = (MYFLT)PyFloat_AS_DOUBLE(PyList_GET_ITEM(list_of_last_gains, k));
2331
 
            currentAmp = (MYFLT)PyFloat_AS_DOUBLE(PyList_GET_ITEM(list_of_current_gains, k));
2332
 
            tmpStepVal = (MYFLT)PyFloat_AS_DOUBLE(PyList_GET_ITEM(list_of_step_vals, k));
2333
 
            tmpCount = (int)PyLong_AsLong(PyList_GET_ITEM(list_of_time_counts, k));
 
2242
            amp = (MYFLT)PyFloat_AS_DOUBLE(PyList_GetItem(list_of_gains, k));
 
2243
            lastAmp = (MYFLT)PyFloat_AS_DOUBLE(PyList_GetItem(list_of_last_gains, k));
 
2244
            currentAmp = (MYFLT)PyFloat_AS_DOUBLE(PyList_GetItem(list_of_current_gains, k));
 
2245
            tmpStepVal = (MYFLT)PyFloat_AS_DOUBLE(PyList_GetItem(list_of_step_vals, k));
 
2246
            tmpCount = (int)PyLong_AsLong(PyList_GetItem(list_of_time_counts, k));
2334
2247
            if (amp != lastAmp) {
2335
2248
                tmpCount = 0;
2336
2249
                tmpStepVal = (amp - currentAmp) / self->timeStep;
2337
 
                PyList_SET_ITEM(list_of_last_gains, k, PyFloat_FromDouble(amp));
 
2250
                PyList_SetItem(list_of_last_gains, k, PyFloat_FromDouble(amp));
2338
2251
            }    
2339
2252
            for (i=0; i<self->bufsize; i++) {
2340
2253
                if (tmpCount == (self->timeStep - 1)) {
2347
2260
                }    
2348
2261
                self->buffer_streams[self->bufsize * k + i] += st[i] * currentAmp;
2349
2262
            }
2350
 
            PyList_SET_ITEM(list_of_current_gains, k, PyFloat_FromDouble(currentAmp));
2351
 
            PyList_SET_ITEM(list_of_step_vals, k, PyFloat_FromDouble(tmpStepVal));
2352
 
            PyList_SET_ITEM(list_of_time_counts, k, PyLong_FromLong(tmpCount));
2353
 
        }    
 
2263
            PyList_SetItem(list_of_current_gains, k, PyFloat_FromDouble(currentAmp));
 
2264
            PyList_SetItem(list_of_step_vals, k, PyFloat_FromDouble(tmpStepVal));
 
2265
            PyList_SetItem(list_of_time_counts, k, PyLong_FromLong(tmpCount));
 
2266
        }
2354
2267
    }
 
2268
    Py_XDECREF(keys);
2355
2269
}
2356
2270
 
2357
2271
MYFLT *
2378
2292
    pyo_VISIT
2379
2293
    Py_VISIT(self->inputs);
2380
2294
    Py_VISIT(self->gains);
 
2295
    Py_VISIT(self->lastGains);
 
2296
    Py_VISIT(self->currentGains);
 
2297
    Py_VISIT(self->stepVals);
 
2298
    Py_VISIT(self->timeCounts);
2381
2299
    return 0;
2382
2300
}
2383
2301
 
2387
2305
    pyo_CLEAR
2388
2306
    Py_CLEAR(self->inputs);
2389
2307
    Py_CLEAR(self->gains);
 
2308
    Py_CLEAR(self->lastGains);
 
2309
    Py_CLEAR(self->currentGains);
 
2310
    Py_CLEAR(self->stepVals);
 
2311
    Py_CLEAR(self->timeCounts);
2390
2312
    return 0;
2391
2313
}
2392
2314
 
2393
2315
static void
2394
2316
Mixer_dealloc(Mixer* self)
2395
2317
{
2396
 
    free(self->data);
 
2318
    pyo_DEALLOC
2397
2319
    free(self->buffer_streams);
2398
2320
    Mixer_clear(self);
2399
2321
    self->ob_type->tp_free((PyObject*)self);
2400
2322
}
2401
2323
 
2402
 
static PyObject * Mixer_deleteStream(Mixer *self) { DELETE_STREAM };
2403
 
 
2404
2324
static PyObject *
2405
2325
Mixer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
2406
2326
{
2407
2327
    int i;
 
2328
    PyObject *timetmp=NULL;
2408
2329
    Mixer *self;
2409
2330
    self = (Mixer *)type->tp_alloc(type, 0);
2410
2331
    
2421
2342
    INIT_OBJECT_COMMON
2422
2343
    Stream_setFunctionPtr(self->stream, Mixer_compute_next_data_frame);
2423
2344
    self->mode_func_ptr = Mixer_setProcMode;
2424
 
    return (PyObject *)self;
2425
 
}
2426
2345
 
2427
 
static int
2428
 
Mixer_init(Mixer *self, PyObject *args, PyObject *kwds)
2429
 
{    
2430
2346
    static char *kwlist[] = {"outs", "time", NULL};
2431
 
    
2432
 
    PyObject *timetmp=NULL;
2433
 
    
 
2347
        
2434
2348
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "|iO", kwlist, &self->num_outs, &timetmp))
2435
 
        return -1; 
2436
 
 
 
2349
        Py_RETURN_NONE; 
 
2350
    
2437
2351
    if (timetmp) {
2438
2352
        PyObject_CallMethod((PyObject *)self, "setTime", "O", timetmp);
2439
2353
    }
2440
2354
    
2441
 
    Py_INCREF(self->stream);
2442
2355
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
2443
 
 
 
2356
    
2444
2357
    self->buffer_streams = (MYFLT *)realloc(self->buffer_streams, self->num_outs * self->bufsize * sizeof(MYFLT));
2445
 
 
 
2358
    
2446
2359
    (*self->mode_func_ptr)(self);
2447
2360
    
2448
 
    Py_INCREF(self);
2449
 
    return 0;
 
2361
    return (PyObject *)self;
2450
2362
}
2451
2363
 
2452
2364
static PyObject * Mixer_getServer(Mixer* self) { GET_SERVER };
2592
2504
static PyMethodDef Mixer_methods[] = {
2593
2505
    {"getServer", (PyCFunction)Mixer_getServer, METH_NOARGS, "Returns server object."},
2594
2506
    {"_getStream", (PyCFunction)Mixer_getStream, METH_NOARGS, "Returns stream object."},
2595
 
    {"deleteStream", (PyCFunction)Mixer_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
2596
2507
    {"play", (PyCFunction)Mixer_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
2597
2508
    {"stop", (PyCFunction)Mixer_stop, METH_NOARGS, "Stops computing."},
2598
2509
    {"setTime", (PyCFunction)Mixer_setTime, METH_O, "Sets ramp time in seconds."},
2639
2550
    0,                                              /* tp_descr_get */
2640
2551
    0,                                              /* tp_descr_set */
2641
2552
    0,                                              /* tp_dictoffset */
2642
 
    (initproc)Mixer_init,                          /* tp_init */
 
2553
    0,                          /* tp_init */
2643
2554
    0,                                              /* tp_alloc */
2644
2555
    Mixer_new,                                     /* tp_new */
2645
2556
};
2733
2644
static void
2734
2645
MixerVoice_dealloc(MixerVoice* self)
2735
2646
{
2736
 
    free(self->data);
 
2647
    pyo_DEALLOC
2737
2648
    MixerVoice_clear(self);
2738
2649
    self->ob_type->tp_free((PyObject*)self);
2739
2650
}
2740
2651
 
2741
 
static PyObject * MixerVoice_deleteStream(MixerVoice *self) { DELETE_STREAM };
2742
 
 
2743
2652
static PyObject *
2744
2653
MixerVoice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
2745
2654
{
2746
2655
    int i;
 
2656
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
2747
2657
    MixerVoice *self;
2748
2658
    self = (MixerVoice *)type->tp_alloc(type, 0);
2749
2659
    
2753
2663
    INIT_OBJECT_COMMON
2754
2664
    Stream_setFunctionPtr(self->stream, MixerVoice_compute_next_data_frame);
2755
2665
    self->mode_func_ptr = MixerVoice_setProcMode;
2756
 
    
2757
 
    return (PyObject *)self;
2758
 
}
2759
2666
 
2760
 
static int
2761
 
MixerVoice_init(MixerVoice *self, PyObject *args, PyObject *kwds)
2762
 
{
2763
 
    PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
2764
 
    
2765
2667
    static char *kwlist[] = {"mainMixer", "chnl", "mul", "add", NULL};
2766
2668
    
2767
2669
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi|OO", kwlist, &maintmp, &self->chnl, &multmp, &addtmp))
2768
 
        return -1; 
 
2670
        Py_RETURN_NONE; 
2769
2671
    
2770
2672
    Py_XDECREF(self->mainMixer);
2771
2673
    Py_INCREF(maintmp);
2779
2681
        PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
2780
2682
    }
2781
2683
    
2782
 
    Py_INCREF(self->stream);
2783
2684
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
2784
2685
    
2785
 
    (*self->mode_func_ptr)(self);
2786
 
    
2787
 
    Py_INCREF(self);
2788
 
    return 0;
 
2686
    return (PyObject *)self;
2789
2687
}
2790
2688
 
2791
2689
static PyObject * MixerVoice_getServer(MixerVoice* self) { GET_SERVER };
2819
2717
static PyMethodDef MixerVoice_methods[] = {
2820
2718
    {"getServer", (PyCFunction)MixerVoice_getServer, METH_NOARGS, "Returns server object."},
2821
2719
    {"_getStream", (PyCFunction)MixerVoice_getStream, METH_NOARGS, "Returns stream object."},
2822
 
    {"deleteStream", (PyCFunction)MixerVoice_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
2823
2720
    {"play", (PyCFunction)MixerVoice_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
2824
2721
    {"out", (PyCFunction)MixerVoice_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
2825
2722
    {"stop", (PyCFunction)MixerVoice_stop, METH_NOARGS, "Stops computing."},
2909
2806
    0,                         /* tp_descr_get */
2910
2807
    0,                         /* tp_descr_set */
2911
2808
    0,                         /* tp_dictoffset */
2912
 
    (initproc)MixerVoice_init,      /* tp_init */
 
2809
    0,      /* tp_init */
2913
2810
    0,                         /* tp_alloc */
2914
2811
    MixerVoice_new,                 /* tp_new */
2915
2812
};
3082
2979
static void
3083
2980
Selector_dealloc(Selector* self)
3084
2981
{
3085
 
    free(self->data);
 
2982
    pyo_DEALLOC
3086
2983
    Selector_clear(self);
3087
2984
    self->ob_type->tp_free((PyObject*)self);
3088
2985
}
3089
2986
 
3090
 
static PyObject * Selector_deleteStream(Selector *self) { DELETE_STREAM };
3091
 
 
3092
2987
static PyObject *
3093
2988
Selector_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
3094
2989
{
3095
2990
    int i;
 
2991
    PyObject *inputstmp=NULL, *voicetmp=NULL, *multmp=NULL, *addtmp=NULL;
3096
2992
    Selector *self;
3097
2993
    self = (Selector *)type->tp_alloc(type, 0);
3098
2994
    
3104
3000
    INIT_OBJECT_COMMON
3105
3001
    Stream_setFunctionPtr(self->stream, Selector_compute_next_data_frame);
3106
3002
    self->mode_func_ptr = Selector_setProcMode;
3107
 
    return (PyObject *)self;
3108
 
}
3109
3003
 
3110
 
static int
3111
 
Selector_init(Selector *self, PyObject *args, PyObject *kwds)
3112
 
{
3113
 
    PyObject *inputstmp=NULL, *voicetmp=NULL, *multmp=NULL, *addtmp=NULL;
3114
 
    
3115
3004
    static char *kwlist[] = {"inputs", "voice", "mul", "add", NULL};
3116
3005
    
3117
3006
    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOO", kwlist, &inputstmp, &voicetmp, &multmp, &addtmp))
3118
 
        return -1; 
 
3007
        Py_RETURN_NONE;
3119
3008
    
3120
3009
    if (inputstmp) {
3121
3010
        PyObject_CallMethod((PyObject *)self, "setInputs", "O", inputstmp);
3133
3022
        PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
3134
3023
    }
3135
3024
    
3136
 
    Py_INCREF(self->stream);
3137
3025
    PyObject_CallMethod(self->server, "addStream", "O", self->stream);
3138
3026
    
3139
3027
    (*self->mode_func_ptr)(self);
3140
 
        
3141
 
    Py_INCREF(self);
3142
 
    return 0;
 
3028
 
 
3029
    return (PyObject *)self;
3143
3030
}
3144
3031
 
3145
3032
static PyObject * Selector_getServer(Selector* self) { GET_SERVER };
3230
3117
static PyMethodDef Selector_methods[] = {
3231
3118
{"getServer", (PyCFunction)Selector_getServer, METH_NOARGS, "Returns server object."},
3232
3119
{"_getStream", (PyCFunction)Selector_getStream, METH_NOARGS, "Returns stream object."},
3233
 
{"deleteStream", (PyCFunction)Selector_deleteStream, METH_NOARGS, "Remove stream from server and delete the object."},
3234
3120
{"play", (PyCFunction)Selector_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
3235
3121
{"out", (PyCFunction)Selector_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
3236
3122
{"stop", (PyCFunction)Selector_stop, METH_NOARGS, "Stops computing."},
3322
3208
0,                                              /* tp_descr_get */
3323
3209
0,                                              /* tp_descr_set */
3324
3210
0,                                              /* tp_dictoffset */
3325
 
(initproc)Selector_init,                          /* tp_init */
 
3211
0,                          /* tp_init */
3326
3212
0,                                              /* tp_alloc */
3327
3213
Selector_new,                                     /* tp_new */
3328
3214
};