Debian Codegraph @

src/objects/metromodule.c

raw
1 /**************************************************************************
2 * Copyright 2009-2015 Olivier Belanger *
3 * *
4 * This file is part of pyo, a python module to help digital signal *
5 * processing script creation. *
6 * *
7 * pyo is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU Lesser General Public License as *
9 * published by the Free Software Foundation, either version 3 of the *
10 * License, or (at your option) any later version. *
11 * *
12 * pyo is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU Lesser General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
19 *************************************************************************/
20
21 #include <Python.h>
22 #include "structmember.h"
23 #include "pyomodule.h"
24 #include "streammodule.h"
25 #include "servermodule.h"
26 #include "dummymodule.h"
27
28 /****************/
29 /**** Metro *****/
30 /****************/
31 typedef struct
32 {
33 pyo_audio_HEAD
34 PyObject *time;
35 Stream *time_stream;
36 int modebuffer[3];
37 double sampleToSec;
38 double currentTime;
39 double offset;
40 int flag;
41 } Metro;
42
43 static void
44 Metro_generate_i(Metro *self)
45 {
46 MYFLT val;
47 double tm, off;
48 int i;
49
50 tm = PyFloat_AS_DOUBLE(self->time);
51 off = tm * self->offset;
52
53 for (i = 0; i < self->bufsize; i++)
54 {
55 if (self->currentTime >= tm)
56 {
57 val = 0;
58 self->currentTime -= tm;
59 self->flag = 1;
60 }
61 else if (self->currentTime >= off && self->flag == 1)
62 {
63 val = 1;
64 self->flag = 0;
65 }
66 else
67 val = 0;
68
69 self->data[i] = val;
70 self->currentTime += self->sampleToSec;
71 }
72 }
73
74 static void
75 Metro_generate_a(Metro *self)
76 {
77 MYFLT val;
78 double off, tmd;
79 int i;
80
81 MYFLT *tm = Stream_getData((Stream *)self->time_stream);
82
83 for (i = 0; i < self->bufsize; i++)
84 {
85 tmd = (double)tm[i];
86 off = tmd * self->offset;
87
88 if (self->currentTime >= tmd)
89 {
90 val = 0;
91 self->currentTime -= tmd;
92 self->flag = 1;
93 }
94 else if (self->currentTime >= off && self->flag == 1)
95 {
96 val = 1;
97 self->flag = 0;
98 }
99 else
100 val = 0;
101
102 self->data[i] = val;
103 self->currentTime += self->sampleToSec;
104 }
105 }
106
107 static void Metro_postprocessing_ii(Metro *self) { POST_PROCESSING_II };
108 static void Metro_postprocessing_ai(Metro *self) { POST_PROCESSING_AI };
109 static void Metro_postprocessing_ia(Metro *self) { POST_PROCESSING_IA };
110 static void Metro_postprocessing_aa(Metro *self) { POST_PROCESSING_AA };
111 static void Metro_postprocessing_ireva(Metro *self) { POST_PROCESSING_IREVA };
112 static void Metro_postprocessing_areva(Metro *self) { POST_PROCESSING_AREVA };
113 static void Metro_postprocessing_revai(Metro *self) { POST_PROCESSING_REVAI };
114 static void Metro_postprocessing_revaa(Metro *self) { POST_PROCESSING_REVAA };
115 static void Metro_postprocessing_revareva(Metro *self) { POST_PROCESSING_REVAREVA };
116
117 static void
118 Metro_setProcMode(Metro *self)
119 {
120 int procmode, muladdmode;
121 procmode = self->modebuffer[2];
122 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
123
124 switch (procmode)
125 {
126 case 0:
127 self->proc_func_ptr = Metro_generate_i;
128 break;
129
130 case 1:
131 self->proc_func_ptr = Metro_generate_a;
132 break;
133 }
134
135 switch (muladdmode)
136 {
137 case 0:
138 self->muladd_func_ptr = Metro_postprocessing_ii;
139 break;
140
141 case 1:
142 self->muladd_func_ptr = Metro_postprocessing_ai;
143 break;
144
145 case 2:
146 self->muladd_func_ptr = Metro_postprocessing_revai;
147 break;
148
149 case 10:
150 self->muladd_func_ptr = Metro_postprocessing_ia;
151 break;
152
153 case 11:
154 self->muladd_func_ptr = Metro_postprocessing_aa;
155 break;
156
157 case 12:
158 self->muladd_func_ptr = Metro_postprocessing_revaa;
159 break;
160
161 case 20:
162 self->muladd_func_ptr = Metro_postprocessing_ireva;
163 break;
164
165 case 21:
166 self->muladd_func_ptr = Metro_postprocessing_areva;
167 break;
168
169 case 22:
170 self->muladd_func_ptr = Metro_postprocessing_revareva;
171 break;
172 }
173 }
174
175 static void
176 Metro_compute_next_data_frame(Metro *self)
177 {
178 (*self->proc_func_ptr)(self);
179 (*self->muladd_func_ptr)(self);
180 }
181
182 static int
183 Metro_traverse(Metro *self, visitproc visit, void *arg)
184 {
185 pyo_VISIT
186 Py_VISIT(self->time);
187 return 0;
188 }
189
190 static int
191 Metro_clear(Metro *self)
192 {
193 pyo_CLEAR
194 Py_CLEAR(self->time);
195 return 0;
196 }
197
198 static void
199 Metro_dealloc(Metro* self)
200 {
201 pyo_DEALLOC
202 Metro_clear(self);
203 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
204 Py_TYPE(self)->tp_free((PyObject*)self);
205 }
206
207 static PyObject *
208 Metro_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
209 {
210 int i;
211 PyObject *timetmp = NULL;
212 Metro *self;
213 self = (Metro *)type->tp_alloc(type, 0);
214
215 self->time = PyFloat_FromDouble(1.);
216 self->modebuffer[0] = 0;
217 self->modebuffer[1] = 0;
218 self->modebuffer[2] = 0;
219 self->flag = 1;
220
221 INIT_OBJECT_COMMON
222 Stream_setFunctionPtr(self->stream, Metro_compute_next_data_frame);
223 self->mode_func_ptr = Metro_setProcMode;
224
225 Stream_setStreamActive(self->stream, 0);
226
227 self->sampleToSec = 1.0 / self->sr;
228 self->currentTime = 0.;
229
230 static char *kwlist[] = {"time", "offset", NULL};
231
232 if (! PyArg_ParseTupleAndKeywords(args, kwds, "|Od", kwlist, &timetmp, &self->offset))
233 Py_RETURN_NONE;
234
235 if (timetmp)
236 {
237 PyObject_CallMethod((PyObject *)self, "setTime", "O", timetmp);
238 }
239
240 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
241
242 (*self->mode_func_ptr)(self);
243
244 return (PyObject *)self;
245 }
246
247 static PyObject * Metro_getServer(Metro* self) { GET_SERVER };
248 static PyObject * Metro_getStream(Metro* self) { GET_STREAM };
249 static PyObject * Metro_setMul(Metro *self, PyObject *arg) { SET_MUL };
250 static PyObject * Metro_setAdd(Metro *self, PyObject *arg) { SET_ADD };
251 static PyObject * Metro_setSub(Metro *self, PyObject *arg) { SET_SUB };
252 static PyObject * Metro_setDiv(Metro *self, PyObject *arg) { SET_DIV };
253
254 static PyObject * Metro_play(Metro *self, PyObject *args, PyObject *kwds) { PLAY };
255 static PyObject * Metro_stop(Metro *self, PyObject *args, PyObject *kwds) { STOP };
256
257 static PyObject * Metro_multiply(Metro *self, PyObject *arg) { MULTIPLY };
258 static PyObject * Metro_inplace_multiply(Metro *self, PyObject *arg) { INPLACE_MULTIPLY };
259 static PyObject * Metro_add(Metro *self, PyObject *arg) { ADD };
260 static PyObject * Metro_inplace_add(Metro *self, PyObject *arg) { INPLACE_ADD };
261 static PyObject * Metro_sub(Metro *self, PyObject *arg) { SUB };
262 static PyObject * Metro_inplace_sub(Metro *self, PyObject *arg) { INPLACE_SUB };
263 static PyObject * Metro_div(Metro *self, PyObject *arg) { DIV };
264 static PyObject * Metro_inplace_div(Metro *self, PyObject *arg) { INPLACE_DIV };
265
266 static PyObject * Metro_setTime(Metro *self, PyObject *arg) { SET_PARAM(self->time, self->time_stream, 2); }
267
268 static PyMemberDef Metro_members[] =
269 {
270 {"server", T_OBJECT_EX, offsetof(Metro, server), 0, "Pyo server."},
271 {"stream", T_OBJECT_EX, offsetof(Metro, stream), 0, "Stream object."},
272 {"time", T_OBJECT_EX, offsetof(Metro, time), 0, "Metro time factor."},
273 {"mul", T_OBJECT_EX, offsetof(Metro, mul), 0, "Mul factor."},
274 {"add", T_OBJECT_EX, offsetof(Metro, add), 0, "Add factor."},
275 {NULL} /* Sentinel */
276 };
277
278 static PyMethodDef Metro_methods[] =
279 {
280 {"getServer", (PyCFunction)Metro_getServer, METH_NOARGS, "Returns server object."},
281 {"_getStream", (PyCFunction)Metro_getStream, METH_NOARGS, "Returns stream object."},
282 {"play", (PyCFunction)Metro_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
283 {"stop", (PyCFunction)Metro_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
284 {"setTime", (PyCFunction)Metro_setTime, METH_O, "Sets time factor."},
285 {"setMul", (PyCFunction)Metro_setMul, METH_O, "Sets oscillator mul factor."},
286 {"setAdd", (PyCFunction)Metro_setAdd, METH_O, "Sets oscillator add factor."},
287 {"setSub", (PyCFunction)Metro_setSub, METH_O, "Sets inverse add factor."},
288 {"setDiv", (PyCFunction)Metro_setDiv, METH_O, "Sets inverse mul factor."},
289 {NULL} /* Sentinel */
290 };
291
292 static PyNumberMethods Metro_as_number =
293 {
294 (binaryfunc)Metro_add, /*nb_add*/
295 (binaryfunc)Metro_sub, /*nb_subtract*/
296 (binaryfunc)Metro_multiply, /*nb_multiply*/
297 0, /*nb_remainder*/
298 0, /*nb_divmod*/
299 0, /*nb_power*/
300 0, /*nb_neg*/
301 0, /*nb_pos*/
302 0, /*(unaryfunc)array_abs,*/
303 0, /*nb_nonzero*/
304 0, /*nb_invert*/
305 0, /*nb_lshift*/
306 0, /*nb_rshift*/
307 0, /*nb_and*/
308 0, /*nb_xor*/
309 0, /*nb_or*/
310 0, /*nb_int*/
311 0, /*nb_long*/
312 0, /*nb_float*/
313 (binaryfunc)Metro_inplace_add, /*inplace_add*/
314 (binaryfunc)Metro_inplace_sub, /*inplace_subtract*/
315 (binaryfunc)Metro_inplace_multiply, /*inplace_multiply*/
316 0, /*inplace_remainder*/
317 0, /*inplace_power*/
318 0, /*inplace_lshift*/
319 0, /*inplace_rshift*/
320 0, /*inplace_and*/
321 0, /*inplace_xor*/
322 0, /*inplace_or*/
323 0, /*nb_floor_divide*/
324 (binaryfunc)Metro_div, /*nb_true_divide*/
325 0, /*nb_inplace_floor_divide*/
326 (binaryfunc)Metro_inplace_div, /*nb_inplace_true_divide*/
327 0, /* nb_index */
328 };
329
330 PyTypeObject MetroType =
331 {
332 PyVarObject_HEAD_INIT(NULL, 0)
333 "_pyo.Metro_base", /*tp_name*/
334 sizeof(Metro), /*tp_basicsize*/
335 0, /*tp_itemsize*/
336 (destructor)Metro_dealloc, /*tp_dealloc*/
337 0, /*tp_print*/
338 0, /*tp_getattr*/
339 0, /*tp_setattr*/
340 0, /*tp_as_async (tp_compare in Python 2)*/
341 0, /*tp_repr*/
342 &Metro_as_number, /*tp_as_number*/
343 0, /*tp_as_sequence*/
344 0, /*tp_as_mapping*/
345 0, /*tp_hash */
346 0, /*tp_call*/
347 0, /*tp_str*/
348 0, /*tp_getattro*/
349 0, /*tp_setattro*/
350 0, /*tp_as_buffer*/
351 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
352 "Metro objects. Create a metronome.", /* tp_doc */
353 (traverseproc)Metro_traverse, /* tp_traverse */
354 (inquiry)Metro_clear, /* tp_clear */
355 0, /* tp_richcompare */
356 0, /* tp_weaklistoffset */
357 0, /* tp_iter */
358 0, /* tp_iternext */
359 Metro_methods, /* tp_methods */
360 Metro_members, /* tp_members */
361 0, /* tp_getset */
362 0, /* tp_base */
363 0, /* tp_dict */
364 0, /* tp_descr_get */
365 0, /* tp_descr_set */
366 0, /* tp_dictoffset */
367 0, /* tp_init */
368 0, /* tp_alloc */
369 Metro_new, /* tp_new */
370 };
371
372 /****************/
373 /**** Seqer *****/
374 /****************/
375 typedef struct
376 {
377 pyo_audio_HEAD
378 PyObject *time;
379 Stream *time_stream;
380 PyObject *speed;
381 Stream *speed_stream;
382 PyObject *tmp;
383 int modebuffer[2];
384 double sampleToSec;
385 double currentTime;
386 double *seq;
387 double when;
388 MYFLT *buffer_streams;
389 int seqsize;
390 int poly;
391 int tap;
392 int voiceCount;
393 int newseq;
394 int onlyonce;
395 int to_stop;
396 } Seqer;
397
398 static void
399 Seqer_reset(Seqer *self)
400 {
401 int i;
402
403 self->seqsize = PyList_Size(self->tmp);
404 self->seq = (double *)PyMem_RawRealloc(self->seq, self->seqsize * sizeof(double));
405
406 for (i = 0; i < self->seqsize; i++)
407 {
408 self->seq[i] = PyFloat_AsDouble(PyList_GET_ITEM(self->tmp, i));
409 }
410
411 self->newseq = 0;
412 }
413
414 static void
415 Seqer_generate_ii(Seqer *self)
416 {
417 double tm, sp;
418 int i;
419
420 tm = PyFloat_AS_DOUBLE(self->time);
421 sp = PyFloat_AS_DOUBLE(self->speed);
422
423 for (i = 0; i < (self->poly * self->bufsize); i++)
424 {
425 self->buffer_streams[i] = 0.0;
426 }
427
428 if (self->to_stop)
429 {
430 PyObject_CallMethod((PyObject *)self, "stop", NULL);
431 self->to_stop = 0;
432 return;
433 }
434
435 for (i = 0; i < self->bufsize; i++)
436 {
437 self->currentTime += (self->sampleToSec * sp);
438
439 if (self->currentTime >= self->when)
440 {
441 self->currentTime -= self->when;
442 self->when = self->seq[self->tap] * tm;
443 self->buffer_streams[i + self->voiceCount * self->bufsize] = 1.0;
444 self->voiceCount++;
445
446 if (self->voiceCount >= self->poly)
447 self->voiceCount = 0;
448
449 self->tap++;
450
451 if (self->tap >= self->seqsize)
452 {
453 self->tap = 0;
454
455 if (self->newseq == 1)
456 Seqer_reset(self);
457
458 if (self->onlyonce)
459 {
460 self->to_stop = 1;
461 return;
462 }
463 }
464 }
465 }
466 }
467
468 static void
469 Seqer_generate_ai(Seqer *self)
470 {
471 int i;
472 double sp;
473
474 MYFLT *time = Stream_getData((Stream *)self->time_stream);
475 sp = PyFloat_AS_DOUBLE(self->speed);
476
477 for (i = 0; i < (self->poly * self->bufsize); i++)
478 {
479 self->buffer_streams[i] = 0.0;
480 }
481
482 if (self->to_stop)
483 {
484 PyObject_CallMethod((PyObject *)self, "stop", NULL);
485 self->to_stop = 0;
486 return;
487 }
488
489 for (i = 0; i < self->bufsize; i++)
490 {
491 self->currentTime += (self->sampleToSec * sp);
492
493 if (self->currentTime >= self->when)
494 {
495 self->currentTime -= self->when;
496 self->when = self->seq[self->tap] * (double)time[i];
497 self->buffer_streams[i + self->voiceCount * self->bufsize] = 1.0;
498 self->voiceCount++;
499
500 if (self->voiceCount >= self->poly)
501 self->voiceCount = 0;
502
503 self->tap++;
504
505 if (self->tap >= self->seqsize)
506 {
507 self->tap = 0;
508
509 if (self->newseq == 1)
510 Seqer_reset(self);
511
512 if (self->onlyonce)
513 {
514 self->to_stop = 1;
515 return;
516 }
517 }
518 }
519 }
520 }
521
522 static void
523 Seqer_generate_ia(Seqer *self)
524 {
525 double tm;
526 int i;
527
528 tm = PyFloat_AS_DOUBLE(self->time);
529 MYFLT *speed = Stream_getData((Stream *)self->speed_stream);
530
531 for (i = 0; i < (self->poly * self->bufsize); i++)
532 {
533 self->buffer_streams[i] = 0.0;
534 }
535
536 if (self->to_stop)
537 {
538 PyObject_CallMethod((PyObject *)self, "stop", NULL);
539 self->to_stop = 0;
540 return;
541 }
542
543 for (i = 0; i < self->bufsize; i++)
544 {
545 self->currentTime += (self->sampleToSec * (double)speed[i]);
546
547 if (self->currentTime >= self->when)
548 {
549 self->currentTime -= self->when;
550 self->when = self->seq[self->tap] * tm;
551 self->buffer_streams[i + self->voiceCount * self->bufsize] = 1.0;
552 self->voiceCount++;
553
554 if (self->voiceCount >= self->poly)
555 self->voiceCount = 0;
556
557 self->tap++;
558
559 if (self->tap >= self->seqsize)
560 {
561 self->tap = 0;
562
563 if (self->newseq == 1)
564 Seqer_reset(self);
565
566 if (self->onlyonce)
567 {
568 self->to_stop = 1;
569 return;
570 }
571 }
572 }
573 }
574 }
575
576 static void
577 Seqer_generate_aa(Seqer *self)
578 {
579 int i;
580
581 MYFLT *time = Stream_getData((Stream *)self->time_stream);
582 MYFLT *speed = Stream_getData((Stream *)self->speed_stream);
583
584 for (i = 0; i < (self->poly * self->bufsize); i++)
585 {
586 self->buffer_streams[i] = 0.0;
587 }
588
589 if (self->to_stop)
590 {
591 PyObject_CallMethod((PyObject *)self, "stop", NULL);
592 self->to_stop = 0;
593 return;
594 }
595
596 for (i = 0; i < self->bufsize; i++)
597 {
598 self->currentTime += (self->sampleToSec * (double)speed[i]);
599
600 if (self->currentTime >= self->when)
601 {
602 self->currentTime -= self->when;
603 self->when = self->seq[self->tap] * (double)time[i];
604 self->buffer_streams[i + self->voiceCount * self->bufsize] = 1.0;
605 self->voiceCount++;
606
607 if (self->voiceCount >= self->poly)
608 self->voiceCount = 0;
609
610 self->tap++;
611
612 if (self->tap >= self->seqsize)
613 {
614 self->tap = 0;
615
616 if (self->newseq == 1)
617 Seqer_reset(self);
618
619 if (self->onlyonce)
620 {
621 self->to_stop = 1;
622 return;
623 }
624 }
625 }
626 }
627 }
628
629 MYFLT *
630 Seqer_getSamplesBuffer(Seqer *self)
631 {
632 return (MYFLT *)self->buffer_streams;
633 }
634
635 static void
636 Seqer_setProcMode(Seqer *self)
637 {
638 int procmode = self->modebuffer[0] + self->modebuffer[1] * 10;
639
640 switch (procmode)
641 {
642 case 0:
643 self->proc_func_ptr = Seqer_generate_ii;
644 break;
645
646 case 1:
647 self->proc_func_ptr = Seqer_generate_ai;
648 break;
649
650 case 10:
651 self->proc_func_ptr = Seqer_generate_ia;
652 break;
653
654 case 11:
655 self->proc_func_ptr = Seqer_generate_aa;
656 break;
657 }
658 }
659
660 static void
661 Seqer_compute_next_data_frame(Seqer *self)
662 {
663 (*self->proc_func_ptr)(self);
664 }
665
666 static int
667 Seqer_traverse(Seqer *self, visitproc visit, void *arg)
668 {
669 pyo_VISIT
670 Py_VISIT(self->time);
671 Py_VISIT(self->speed);
672 Py_VISIT(self->tmp);
673 return 0;
674 }
675
676 static int
677 Seqer_clear(Seqer *self)
678 {
679 pyo_CLEAR
680 Py_CLEAR(self->time);
681 Py_CLEAR(self->speed);
682 Py_CLEAR(self->tmp);
683 return 0;
684 }
685
686 static void
687 Seqer_dealloc(Seqer* self)
688 {
689 pyo_DEALLOC
690 PyMem_RawFree(self->seq);
691 PyMem_RawFree(self->buffer_streams);
692 Seqer_clear(self);
693 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
694 Py_TYPE(self)->tp_free((PyObject*)self);
695 }
696
697 static PyObject *
698 Seqer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
699 {
700 int i;
701 PyObject *timetmp = NULL, *speedtmp = NULL, *seqtmp = NULL;
702 Seqer *self;
703 self = (Seqer *)type->tp_alloc(type, 0);
704
705 self->time = PyFloat_FromDouble(1.);
706 self->speed = PyFloat_FromDouble(1.);
707 self->poly = 1;
708 self->seqsize = 1;
709 self->seq = (double *)PyMem_RawRealloc(self->seq, self->seqsize * sizeof(double));
710 self->seq[0] = 1.0;
711 self->newseq = 0;
712 self->tap = 0;
713 self->voiceCount = 0;
714 self->onlyonce = 0;
715 self->to_stop = 0;
716 self->modebuffer[0] = 0;
717 self->modebuffer[1] = 0;
718
719 INIT_OBJECT_COMMON
720 Stream_setFunctionPtr(self->stream, Seqer_compute_next_data_frame);
721 self->mode_func_ptr = Seqer_setProcMode;
722
723 Stream_setStreamActive(self->stream, 0);
724
725 self->sampleToSec = 1.0 / self->sr;
726 self->currentTime = 0.0;
727
728 static char *kwlist[] = {"time", "seq", "poly", "onlyonce", "speed", NULL};
729
730 if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOiiO", kwlist, &timetmp, &seqtmp, &self->poly, &self->onlyonce, &speedtmp))
731 Py_RETURN_NONE;
732
733 if (timetmp)
734 {
735 PyObject_CallMethod((PyObject *)self, "setTime", "O", timetmp);
736 }
737
738 if (speedtmp)
739 {
740 PyObject_CallMethod((PyObject *)self, "setSpeed", "O", speedtmp);
741 }
742
743 if (seqtmp)
744 {
745 PyObject_CallMethod((PyObject *)self, "setSeq", "O", seqtmp);
746 }
747
748 Seqer_reset(self);
749
750 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
751
752 self->buffer_streams = (MYFLT *)PyMem_RawRealloc(self->buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
753
754 (*self->mode_func_ptr)(self);
755
756 return (PyObject *)self;
757 }
758
759 static PyObject * Seqer_getServer(Seqer* self) { GET_SERVER };
760 static PyObject * Seqer_getStream(Seqer* self) { GET_STREAM };
761
762 static PyObject * Seqer_play(Seqer *self, PyObject *args, PyObject *kwds)
763 {
764 self->currentTime = 0.0;
765 self->when = 0.0;
766 self->tap = 0;
767 self->voiceCount = 0;
768 PLAY
769 };
770 static PyObject * Seqer_stop(Seqer *self, PyObject *args, PyObject *kwds) { STOP };
771
772 static PyObject * Seqer_setTime(Seqer *self, PyObject *arg) { SET_PARAM(self->time, self->time_stream, 0); }
773 static PyObject * Seqer_setSpeed(Seqer *self, PyObject *arg) { SET_PARAM(self->speed, self->speed_stream, 1); }
774
775 static PyObject *
776 Seqer_setSeq(Seqer *self, PyObject *arg)
777 {
778 ASSERT_ARG_NOT_NULL
779
780 if (PyList_Check(arg))
781 {
782 Py_XDECREF(self->tmp);
783 self->tmp = arg;
784 Py_INCREF(self->tmp);
785 self->newseq = 1;
786 }
787
788 Py_RETURN_NONE;
789 }
790
791 static PyObject *
792 Seqer_setOnlyonce(Seqer *self, PyObject *arg)
793 {
794 ASSERT_ARG_NOT_NULL
795
796 if (PyLong_Check(arg))
797 {
798 self->onlyonce = PyLong_AsLong(arg);
799 }
800
801 Py_RETURN_NONE;
802 }
803
804 static PyMemberDef Seqer_members[] =
805 {
806 {"server", T_OBJECT_EX, offsetof(Seqer, server), 0, "Pyo server."},
807 {"stream", T_OBJECT_EX, offsetof(Seqer, stream), 0, "Stream object."},
808 {"time", T_OBJECT_EX, offsetof(Seqer, time), 0, "Seqer time factor."},
809 {"speed", T_OBJECT_EX, offsetof(Seqer, speed), 0, "Seqer speed factor."},
810 {NULL} /* Sentinel */
811 };
812
813 static PyMethodDef Seqer_methods[] =
814 {
815 {"getServer", (PyCFunction)Seqer_getServer, METH_NOARGS, "Returns server object."},
816 {"_getStream", (PyCFunction)Seqer_getStream, METH_NOARGS, "Returns stream object."},
817 {"play", (PyCFunction)Seqer_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
818 {"stop", (PyCFunction)Seqer_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
819 {"setTime", (PyCFunction)Seqer_setTime, METH_O, "Sets time factor."},
820 {"setSpeed", (PyCFunction)Seqer_setSpeed, METH_O, "Sets speed factor."},
821 {"setSeq", (PyCFunction)Seqer_setSeq, METH_O, "Sets duration sequence."},
822 {"setOnlyonce", (PyCFunction)Seqer_setOnlyonce, METH_O, "Sets onlyonce attribute."},
823 {NULL} /* Sentinel */
824 };
825
826 PyTypeObject SeqerType =
827 {
828 PyVarObject_HEAD_INIT(NULL, 0)
829 "_pyo.Seqer_base", /*tp_name*/
830 sizeof(Seqer), /*tp_basicsize*/
831 0, /*tp_itemsize*/
832 (destructor)Seqer_dealloc, /*tp_dealloc*/
833 0, /*tp_print*/
834 0, /*tp_getattr*/
835 0, /*tp_setattr*/
836 0, /*tp_as_async (tp_compare in Python 2)*/
837 0, /*tp_repr*/
838 0, /*tp_as_number*/
839 0, /*tp_as_sequence*/
840 0, /*tp_as_mapping*/
841 0, /*tp_hash */
842 0, /*tp_call*/
843 0, /*tp_str*/
844 0, /*tp_getattro*/
845 0, /*tp_setattro*/
846 0, /*tp_as_buffer*/
847 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
848 "Seqer objects. Creates a metronome with a duration sequence.", /* tp_doc */
849 (traverseproc)Seqer_traverse, /* tp_traverse */
850 (inquiry)Seqer_clear, /* tp_clear */
851 0, /* tp_richcompare */
852 0, /* tp_weaklistoffset */
853 0, /* tp_iter */
854 0, /* tp_iternext */
855 Seqer_methods, /* tp_methods */
856 Seqer_members, /* tp_members */
857 0, /* tp_getset */
858 0, /* tp_base */
859 0, /* tp_dict */
860 0, /* tp_descr_get */
861 0, /* tp_descr_set */
862 0, /* tp_dictoffset */
863 0, /* tp_init */
864 0, /* tp_alloc */
865 Seqer_new, /* tp_new */
866 };
867
868 /************************************************************************************************/
869 /* Seq streamer object per channel */
870 /************************************************************************************************/
871 typedef struct
872 {
873 pyo_audio_HEAD
874 Seqer *mainPlayer;
875 int chnl;
876 int modebuffer[2];
877 } Seq;
878
879 static void Seq_postprocessing_ii(Seq *self) { POST_PROCESSING_II };
880 static void Seq_postprocessing_ai(Seq *self) { POST_PROCESSING_AI };
881 static void Seq_postprocessing_ia(Seq *self) { POST_PROCESSING_IA };
882 static void Seq_postprocessing_aa(Seq *self) { POST_PROCESSING_AA };
883 static void Seq_postprocessing_ireva(Seq *self) { POST_PROCESSING_IREVA };
884 static void Seq_postprocessing_areva(Seq *self) { POST_PROCESSING_AREVA };
885 static void Seq_postprocessing_revai(Seq *self) { POST_PROCESSING_REVAI };
886 static void Seq_postprocessing_revaa(Seq *self) { POST_PROCESSING_REVAA };
887 static void Seq_postprocessing_revareva(Seq *self) { POST_PROCESSING_REVAREVA };
888
889 static void
890 Seq_setProcMode(Seq *self)
891 {
892 int muladdmode;
893 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
894
895 switch (muladdmode)
896 {
897 case 0:
898 self->muladd_func_ptr = Seq_postprocessing_ii;
899 break;
900
901 case 1:
902 self->muladd_func_ptr = Seq_postprocessing_ai;
903 break;
904
905 case 2:
906 self->muladd_func_ptr = Seq_postprocessing_revai;
907 break;
908
909 case 10:
910 self->muladd_func_ptr = Seq_postprocessing_ia;
911 break;
912
913 case 11:
914 self->muladd_func_ptr = Seq_postprocessing_aa;
915 break;
916
917 case 12:
918 self->muladd_func_ptr = Seq_postprocessing_revaa;
919 break;
920
921 case 20:
922 self->muladd_func_ptr = Seq_postprocessing_ireva;
923 break;
924
925 case 21:
926 self->muladd_func_ptr = Seq_postprocessing_areva;
927 break;
928
929 case 22:
930 self->muladd_func_ptr = Seq_postprocessing_revareva;
931 break;
932 }
933 }
934
935 static void
936 Seq_compute_next_data_frame(Seq *self)
937 {
938 int i;
939 MYFLT *tmp;
940 int offset = self->chnl * self->bufsize;
941 tmp = Seqer_getSamplesBuffer((Seqer *)self->mainPlayer);
942
943 for (i = 0; i < self->bufsize; i++)
944 {
945 self->data[i] = tmp[i + offset];
946 }
947
948 (*self->muladd_func_ptr)(self);
949 }
950
951 static int
952 Seq_traverse(Seq *self, visitproc visit, void *arg)
953 {
954 pyo_VISIT
955 Py_VISIT(self->mainPlayer);
956 return 0;
957 }
958
959 static int
960 Seq_clear(Seq *self)
961 {
962 pyo_CLEAR
963 Py_CLEAR(self->mainPlayer);
964 return 0;
965 }
966
967 static void
968 Seq_dealloc(Seq* self)
969 {
970 pyo_DEALLOC
971 Seq_clear(self);
972 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
973 Py_TYPE(self)->tp_free((PyObject*)self);
974 }
975
976 static PyObject *
977 Seq_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
978 {
979 int i;
980 PyObject *maintmp = NULL;
981 Seq *self;
982 self = (Seq *)type->tp_alloc(type, 0);
983
984 self->chnl = 0;
985 self->modebuffer[0] = 0;
986 self->modebuffer[1] = 0;
987
988 INIT_OBJECT_COMMON
989 Stream_setFunctionPtr(self->stream, Seq_compute_next_data_frame);
990 self->mode_func_ptr = Seq_setProcMode;
991
992 static char *kwlist[] = {"mainPlayer", "chnl", NULL};
993
994 if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
995 Py_RETURN_NONE;
996
997 self->mainPlayer = (Seqer *)maintmp;
998 Py_INCREF(self->mainPlayer);
999
1000 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
1001
1002 (*self->mode_func_ptr)(self);
1003
1004 return (PyObject *)self;
1005 }
1006
1007 static PyObject * Seq_getServer(Seq* self) { GET_SERVER };
1008 static PyObject * Seq_getStream(Seq* self) { GET_STREAM };
1009 static PyObject * Seq_setMul(Seq *self, PyObject *arg) { SET_MUL };
1010 static PyObject * Seq_setAdd(Seq *self, PyObject *arg) { SET_ADD };
1011 static PyObject * Seq_setSub(Seq *self, PyObject *arg) { SET_SUB };
1012 static PyObject * Seq_setDiv(Seq *self, PyObject *arg) { SET_DIV };
1013
1014 static PyObject * Seq_play(Seq *self, PyObject *args, PyObject *kwds) { PLAY };
1015 static PyObject * Seq_out(Seq *self, PyObject *args, PyObject *kwds) { OUT };
1016 static PyObject * Seq_stop(Seq *self, PyObject *args, PyObject *kwds) { STOP };
1017
1018 static PyObject * Seq_multiply(Seq *self, PyObject *arg) { MULTIPLY };
1019 static PyObject * Seq_inplace_multiply(Seq *self, PyObject *arg) { INPLACE_MULTIPLY };
1020 static PyObject * Seq_add(Seq *self, PyObject *arg) { ADD };
1021 static PyObject * Seq_inplace_add(Seq *self, PyObject *arg) { INPLACE_ADD };
1022 static PyObject * Seq_sub(Seq *self, PyObject *arg) { SUB };
1023 static PyObject * Seq_inplace_sub(Seq *self, PyObject *arg) { INPLACE_SUB };
1024 static PyObject * Seq_div(Seq *self, PyObject *arg) { DIV };
1025 static PyObject * Seq_inplace_div(Seq *self, PyObject *arg) { INPLACE_DIV };
1026
1027 static PyMemberDef Seq_members[] =
1028 {
1029 {"server", T_OBJECT_EX, offsetof(Seq, server), 0, "Pyo server."},
1030 {"stream", T_OBJECT_EX, offsetof(Seq, stream), 0, "Stream object."},
1031 {"mul", T_OBJECT_EX, offsetof(Seq, mul), 0, "Mul factor."},
1032 {"add", T_OBJECT_EX, offsetof(Seq, add), 0, "Add factor."},
1033 {NULL} /* Sentinel */
1034 };
1035
1036 static PyMethodDef Seq_methods[] =
1037 {
1038 {"getServer", (PyCFunction)Seq_getServer, METH_NOARGS, "Returns server object."},
1039 {"_getStream", (PyCFunction)Seq_getStream, METH_NOARGS, "Returns stream object."},
1040 {"play", (PyCFunction)Seq_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
1041 {"out", (PyCFunction)Seq_out, METH_VARARGS | METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
1042 {"stop", (PyCFunction)Seq_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
1043 {"setMul", (PyCFunction)Seq_setMul, METH_O, "Sets oscillator mul factor."},
1044 {"setAdd", (PyCFunction)Seq_setAdd, METH_O, "Sets oscillator add factor."},
1045 {"setSub", (PyCFunction)Seq_setSub, METH_O, "Sets inverse add factor."},
1046 {"setDiv", (PyCFunction)Seq_setDiv, METH_O, "Sets inverse mul factor."},
1047 {NULL} /* Sentinel */
1048 };
1049
1050 static PyNumberMethods Seq_as_number =
1051 {
1052 (binaryfunc)Seq_add, /*nb_add*/
1053 (binaryfunc)Seq_sub, /*nb_subtract*/
1054 (binaryfunc)Seq_multiply, /*nb_multiply*/
1055 0, /*nb_remainder*/
1056 0, /*nb_divmod*/
1057 0, /*nb_power*/
1058 0, /*nb_neg*/
1059 0, /*nb_pos*/
1060 0, /*(unaryfunc)array_abs,*/
1061 0, /*nb_nonzero*/
1062 0, /*nb_invert*/
1063 0, /*nb_lshift*/
1064 0, /*nb_rshift*/
1065 0, /*nb_and*/
1066 0, /*nb_xor*/
1067 0, /*nb_or*/
1068 0, /*nb_int*/
1069 0, /*nb_long*/
1070 0, /*nb_float*/
1071 (binaryfunc)Seq_inplace_add, /*inplace_add*/
1072 (binaryfunc)Seq_inplace_sub, /*inplace_subtract*/
1073 (binaryfunc)Seq_inplace_multiply, /*inplace_multiply*/
1074 0, /*inplace_remainder*/
1075 0, /*inplace_power*/
1076 0, /*inplace_lshift*/
1077 0, /*inplace_rshift*/
1078 0, /*inplace_and*/
1079 0, /*inplace_xor*/
1080 0, /*inplace_or*/
1081 0, /*nb_floor_divide*/
1082 (binaryfunc)Seq_div, /*nb_true_divide*/
1083 0, /*nb_inplace_floor_divide*/
1084 (binaryfunc)Seq_inplace_div, /*nb_inplace_true_divide*/
1085 0, /* nb_index */
1086 };
1087
1088 PyTypeObject SeqType =
1089 {
1090 PyVarObject_HEAD_INIT(NULL, 0)
1091 "_pyo.Seq_base", /*tp_name*/
1092 sizeof(Seq), /*tp_basicsize*/
1093 0, /*tp_itemsize*/
1094 (destructor)Seq_dealloc, /*tp_dealloc*/
1095 0, /*tp_print*/
1096 0, /*tp_getattr*/
1097 0, /*tp_setattr*/
1098 0, /*tp_as_async (tp_compare in Python 2)*/
1099 0, /*tp_repr*/
1100 &Seq_as_number, /*tp_as_number*/
1101 0, /*tp_as_sequence*/
1102 0, /*tp_as_mapping*/
1103 0, /*tp_hash */
1104 0, /*tp_call*/
1105 0, /*tp_str*/
1106 0, /*tp_getattro*/
1107 0, /*tp_setattro*/
1108 0, /*tp_as_buffer*/
1109 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
1110 "Seq objects. Reads a channel from a Seqer.", /* tp_doc */
1111 (traverseproc)Seq_traverse, /* tp_traverse */
1112 (inquiry)Seq_clear, /* tp_clear */
1113 0, /* tp_richcompare */
1114 0, /* tp_weaklistoffset */
1115 0, /* tp_iter */
1116 0, /* tp_iternext */
1117 Seq_methods, /* tp_methods */
1118 Seq_members, /* tp_members */
1119 0, /* tp_getset */
1120 0, /* tp_base */
1121 0, /* tp_dict */
1122 0, /* tp_descr_get */
1123 0, /* tp_descr_set */
1124 0, /* tp_dictoffset */
1125 0, /* tp_init */
1126 0, /* tp_alloc */
1127 Seq_new, /* tp_new */
1128 };
1129
1130 /****************/
1131 /**** Clouder *****/
1132 /****************/
1133 typedef struct
1134 {
1135 pyo_audio_HEAD
1136 PyObject *density;
1137 Stream *density_stream;
1138 int modebuffer[1];
1139 int poly;
1140 int voiceCount;
1141 MYFLT *buffer_streams;
1142 } Clouder;
1143
1144 static void
1145 Clouder_generate_i(Clouder *self)
1146 {
1147 int i;
1148 MYFLT rnd;
1149
1150 MYFLT dens = PyFloat_AS_DOUBLE(self->density);
1151
1152 if (dens <= 0.0)
1153 dens = 0.0;
1154 else if (dens > self->sr)
1155 dens = self->sr;
1156
1157 for (i = 0; i < (self->poly * self->bufsize); i++)
1158 {
1159 self->buffer_streams[i] = 0.0;
1160 }
1161
1162 dens *= 0.5;
1163
1164 for (i = 0; i < self->bufsize; i++)
1165 {
1166 rnd = RANDOM_UNIFORM * self->sr;
1167
1168 if (rnd < dens)
1169 {
1170 self->buffer_streams[i + self->voiceCount++ * self->bufsize] = 1.0;
1171
1172 if (self->voiceCount == self->poly)
1173 self->voiceCount = 0;
1174 }
1175 }
1176 }
1177
1178 static void
1179 Clouder_generate_a(Clouder *self)
1180 {
1181 MYFLT dens;
1182 int i;
1183 MYFLT rnd;
1184
1185 MYFLT *density = Stream_getData((Stream *)self->density_stream);
1186
1187 for (i = 0; i < (self->poly * self->bufsize); i++)
1188 {
1189 self->buffer_streams[i] = 0.0;
1190 }
1191
1192 for (i = 0; i < self->bufsize; i++)
1193 {
1194 dens = density[i];
1195
1196 if (dens <= 0.0)
1197 dens = 0.0;
1198 else if (dens > self->sr)
1199 dens = self->sr;
1200
1201 dens *= 0.5;
1202 rnd = RANDOM_UNIFORM * self->sr;
1203
1204 if (rnd < dens)
1205 {
1206 self->buffer_streams[i + self->voiceCount++ * self->bufsize] = 1.0;
1207
1208 if (self->voiceCount == self->poly)
1209 self->voiceCount = 0;
1210 }
1211 }
1212 }
1213
1214 MYFLT *
1215 Clouder_getSamplesBuffer(Clouder *self)
1216 {
1217 return (MYFLT *)self->buffer_streams;
1218 }
1219
1220 static void
1221 Clouder_setProcMode(Clouder *self)
1222 {
1223 int procmode = self->modebuffer[0];
1224
1225 switch (procmode)
1226 {
1227 case 0:
1228 self->proc_func_ptr = Clouder_generate_i;
1229 break;
1230
1231 case 1:
1232 self->proc_func_ptr = Clouder_generate_a;
1233 break;
1234 }
1235 }
1236
1237 static void
1238 Clouder_compute_next_data_frame(Clouder *self)
1239 {
1240 (*self->proc_func_ptr)(self);
1241 }
1242
1243 static int
1244 Clouder_traverse(Clouder *self, visitproc visit, void *arg)
1245 {
1246 pyo_VISIT
1247 Py_VISIT(self->density);
1248 return 0;
1249 }
1250
1251 static int
1252 Clouder_clear(Clouder *self)
1253 {
1254 pyo_CLEAR
1255 Py_CLEAR(self->density);
1256 return 0;
1257 }
1258
1259 static void
1260 Clouder_dealloc(Clouder* self)
1261 {
1262 pyo_DEALLOC
1263 PyMem_RawFree(self->buffer_streams);
1264 Clouder_clear(self);
1265 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
1266 Py_TYPE(self)->tp_free((PyObject*)self);
1267 }
1268
1269 static PyObject *
1270 Clouder_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1271 {
1272 int i;
1273 PyObject *densitytmp = NULL;
1274 Clouder *self;
1275 self = (Clouder *)type->tp_alloc(type, 0);
1276
1277 self->density = PyFloat_FromDouble(10.0);
1278 self->poly = 1;
1279 self->voiceCount = 0;
1280 self->modebuffer[0] = 0;
1281
1282 INIT_OBJECT_COMMON
1283 Stream_setFunctionPtr(self->stream, Clouder_compute_next_data_frame);
1284 self->mode_func_ptr = Clouder_setProcMode;
1285
1286 Stream_setStreamActive(self->stream, 0);
1287
1288 static char *kwlist[] = {"density", "poly", NULL};
1289
1290 if (! PyArg_ParseTupleAndKeywords(args, kwds, "|Oi", kwlist, &densitytmp, &self->poly))
1291 Py_RETURN_NONE;
1292
1293 if (densitytmp)
1294 {
1295 PyObject_CallMethod((PyObject *)self, "setDensity", "O", densitytmp);
1296 }
1297
1298 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
1299
1300 (*self->mode_func_ptr)(self);
1301
1302 Server_generateSeed((Server *)self->server, CLOUD_ID);
1303
1304 self->buffer_streams = (MYFLT *)PyMem_RawRealloc(self->buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
1305
1306 return (PyObject *)self;
1307 }
1308
1309 static PyObject * Clouder_getServer(Clouder* self) { GET_SERVER };
1310 static PyObject * Clouder_getStream(Clouder* self) { GET_STREAM };
1311
1312 static PyObject * Clouder_play(Clouder *self, PyObject *args, PyObject *kwds) { PLAY };
1313 static PyObject * Clouder_stop(Clouder *self, PyObject *args, PyObject *kwds) { STOP };
1314
1315 static PyObject * Clouder_setDensity(Clouder *self, PyObject *arg) { SET_PARAM(self->density, self->density_stream, 0); }
1316
1317 static PyMemberDef Clouder_members[] =
1318 {
1319 {"server", T_OBJECT_EX, offsetof(Clouder, server), 0, "Pyo server."},
1320 {"stream", T_OBJECT_EX, offsetof(Clouder, stream), 0, "Stream object."},
1321 {"density", T_OBJECT_EX, offsetof(Clouder, density), 0, "Clouder density factor."},
1322 {NULL} /* Sentinel */
1323 };
1324
1325 static PyMethodDef Clouder_methods[] =
1326 {
1327 {"getServer", (PyCFunction)Clouder_getServer, METH_NOARGS, "Returns server object."},
1328 {"_getStream", (PyCFunction)Clouder_getStream, METH_NOARGS, "Returns stream object."},
1329 {"play", (PyCFunction)Clouder_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
1330 {"stop", (PyCFunction)Clouder_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
1331 {"setDensity", (PyCFunction)Clouder_setDensity, METH_O, "Sets density factor."},
1332 {NULL} /* Sentinel */
1333 };
1334
1335 PyTypeObject ClouderType =
1336 {
1337 PyVarObject_HEAD_INIT(NULL, 0)
1338 "_pyo.Clouder_base", /*tp_name*/
1339 sizeof(Clouder), /*tp_basicsize*/
1340 0, /*tp_itemsize*/
1341 (destructor)Clouder_dealloc, /*tp_dealloc*/
1342 0, /*tp_print*/
1343 0, /*tp_getattr*/
1344 0, /*tp_setattr*/
1345 0, /*tp_as_async (tp_compare in Python 2)*/
1346 0, /*tp_repr*/
1347 0, /*tp_as_number*/
1348 0, /*tp_as_sequence*/
1349 0, /*tp_as_mapping*/
1350 0, /*tp_hash */
1351 0, /*tp_call*/
1352 0, /*tp_str*/
1353 0, /*tp_getattro*/
1354 0, /*tp_setattro*/
1355 0, /*tp_as_buffer*/
1356 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
1357 "Clouder objects. Create a cloud of triggers.", /* tp_doc */
1358 (traverseproc)Clouder_traverse, /* tp_traverse */
1359 (inquiry)Clouder_clear, /* tp_clear */
1360 0, /* tp_richcompare */
1361 0, /* tp_weaklistoffset */
1362 0, /* tp_iter */
1363 0, /* tp_iternext */
1364 Clouder_methods, /* tp_methods */
1365 Clouder_members, /* tp_members */
1366 0, /* tp_getset */
1367 0, /* tp_base */
1368 0, /* tp_dict */
1369 0, /* tp_descr_get */
1370 0, /* tp_descr_set */
1371 0, /* tp_dictoffset */
1372 0, /* tp_init */
1373 0, /* tp_alloc */
1374 Clouder_new, /* tp_new */
1375 };
1376
1377 /************************************************************************************************/
1378 /* Cloud streamer object per channel */
1379 /************************************************************************************************/
1380 typedef struct
1381 {
1382 pyo_audio_HEAD
1383 Clouder *mainPlayer;
1384 int chnl;
1385 int modebuffer[2];
1386 } Cloud;
1387
1388 static void Cloud_postprocessing_ii(Cloud *self) { POST_PROCESSING_II };
1389 static void Cloud_postprocessing_ai(Cloud *self) { POST_PROCESSING_AI };
1390 static void Cloud_postprocessing_ia(Cloud *self) { POST_PROCESSING_IA };
1391 static void Cloud_postprocessing_aa(Cloud *self) { POST_PROCESSING_AA };
1392 static void Cloud_postprocessing_ireva(Cloud *self) { POST_PROCESSING_IREVA };
1393 static void Cloud_postprocessing_areva(Cloud *self) { POST_PROCESSING_AREVA };
1394 static void Cloud_postprocessing_revai(Cloud *self) { POST_PROCESSING_REVAI };
1395 static void Cloud_postprocessing_revaa(Cloud *self) { POST_PROCESSING_REVAA };
1396 static void Cloud_postprocessing_revareva(Cloud *self) { POST_PROCESSING_REVAREVA };
1397
1398 static void
1399 Cloud_setProcMode(Cloud *self)
1400 {
1401 int muladdmode;
1402 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
1403
1404 switch (muladdmode)
1405 {
1406 case 0:
1407 self->muladd_func_ptr = Cloud_postprocessing_ii;
1408 break;
1409
1410 case 1:
1411 self->muladd_func_ptr = Cloud_postprocessing_ai;
1412 break;
1413
1414 case 2:
1415 self->muladd_func_ptr = Cloud_postprocessing_revai;
1416 break;
1417
1418 case 10:
1419 self->muladd_func_ptr = Cloud_postprocessing_ia;
1420 break;
1421
1422 case 11:
1423 self->muladd_func_ptr = Cloud_postprocessing_aa;
1424 break;
1425
1426 case 12:
1427 self->muladd_func_ptr = Cloud_postprocessing_revaa;
1428 break;
1429
1430 case 20:
1431 self->muladd_func_ptr = Cloud_postprocessing_ireva;
1432 break;
1433
1434 case 21:
1435 self->muladd_func_ptr = Cloud_postprocessing_areva;
1436 break;
1437
1438 case 22:
1439 self->muladd_func_ptr = Cloud_postprocessing_revareva;
1440 break;
1441 }
1442 }
1443
1444 static void
1445 Cloud_compute_next_data_frame(Cloud *self)
1446 {
1447 int i;
1448 MYFLT *tmp;
1449 int offset = self->chnl * self->bufsize;
1450 tmp = Clouder_getSamplesBuffer((Clouder *)self->mainPlayer);
1451
1452 for (i = 0; i < self->bufsize; i++)
1453 {
1454 self->data[i] = tmp[i + offset];
1455 }
1456
1457 (*self->muladd_func_ptr)(self);
1458 }
1459
1460 static int
1461 Cloud_traverse(Cloud *self, visitproc visit, void *arg)
1462 {
1463 pyo_VISIT
1464 Py_VISIT(self->mainPlayer);
1465 return 0;
1466 }
1467
1468 static int
1469 Cloud_clear(Cloud *self)
1470 {
1471 pyo_CLEAR
1472 Py_CLEAR(self->mainPlayer);
1473 return 0;
1474 }
1475
1476 static void
1477 Cloud_dealloc(Cloud* self)
1478 {
1479 pyo_DEALLOC
1480 Cloud_clear(self);
1481 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
1482 Py_TYPE(self)->tp_free((PyObject*)self);
1483 }
1484
1485 static PyObject *
1486 Cloud_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1487 {
1488 int i;
1489 PyObject *maintmp = NULL;
1490 Cloud *self;
1491 self = (Cloud *)type->tp_alloc(type, 0);
1492
1493 self->chnl = 0;
1494 self->modebuffer[0] = 0;
1495 self->modebuffer[1] = 0;
1496
1497 INIT_OBJECT_COMMON
1498 Stream_setFunctionPtr(self->stream, Cloud_compute_next_data_frame);
1499 self->mode_func_ptr = Cloud_setProcMode;
1500
1501 static char *kwlist[] = {"mainPlayer", "chnl", NULL};
1502
1503 if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
1504 Py_RETURN_NONE;
1505
1506 self->mainPlayer = (Clouder *)maintmp;
1507 Py_INCREF(self->mainPlayer);
1508
1509 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
1510
1511 (*self->mode_func_ptr)(self);
1512
1513 return (PyObject *)self;
1514 }
1515
1516 static PyObject * Cloud_getServer(Cloud* self) { GET_SERVER };
1517 static PyObject * Cloud_getStream(Cloud* self) { GET_STREAM };
1518 static PyObject * Cloud_setMul(Cloud *self, PyObject *arg) { SET_MUL };
1519 static PyObject * Cloud_setAdd(Cloud *self, PyObject *arg) { SET_ADD };
1520 static PyObject * Cloud_setSub(Cloud *self, PyObject *arg) { SET_SUB };
1521 static PyObject * Cloud_setDiv(Cloud *self, PyObject *arg) { SET_DIV };
1522
1523 static PyObject * Cloud_play(Cloud *self, PyObject *args, PyObject *kwds) { PLAY };
1524 static PyObject * Cloud_out(Cloud *self, PyObject *args, PyObject *kwds) { OUT };
1525 static PyObject * Cloud_stop(Cloud *self, PyObject *args, PyObject *kwds) { STOP };
1526
1527 static PyObject * Cloud_multiply(Cloud *self, PyObject *arg) { MULTIPLY };
1528 static PyObject * Cloud_inplace_multiply(Cloud *self, PyObject *arg) { INPLACE_MULTIPLY };
1529 static PyObject * Cloud_add(Cloud *self, PyObject *arg) { ADD };
1530 static PyObject * Cloud_inplace_add(Cloud *self, PyObject *arg) { INPLACE_ADD };
1531 static PyObject * Cloud_sub(Cloud *self, PyObject *arg) { SUB };
1532 static PyObject * Cloud_inplace_sub(Cloud *self, PyObject *arg) { INPLACE_SUB };
1533 static PyObject * Cloud_div(Cloud *self, PyObject *arg) { DIV };
1534 static PyObject * Cloud_inplace_div(Cloud *self, PyObject *arg) { INPLACE_DIV };
1535
1536 static PyMemberDef Cloud_members[] =
1537 {
1538 {"server", T_OBJECT_EX, offsetof(Cloud, server), 0, "Pyo server."},
1539 {"stream", T_OBJECT_EX, offsetof(Cloud, stream), 0, "Stream object."},
1540 {"mul", T_OBJECT_EX, offsetof(Cloud, mul), 0, "Mul factor."},
1541 {"add", T_OBJECT_EX, offsetof(Cloud, add), 0, "Add factor."},
1542 {NULL} /* Sentinel */
1543 };
1544
1545 static PyMethodDef Cloud_methods[] =
1546 {
1547 {"getServer", (PyCFunction)Cloud_getServer, METH_NOARGS, "Returns server object."},
1548 {"_getStream", (PyCFunction)Cloud_getStream, METH_NOARGS, "Returns stream object."},
1549 {"play", (PyCFunction)Cloud_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
1550 {"out", (PyCFunction)Cloud_out, METH_VARARGS | METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
1551 {"stop", (PyCFunction)Cloud_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
1552 {"setMul", (PyCFunction)Cloud_setMul, METH_O, "Sets oscillator mul factor."},
1553 {"setAdd", (PyCFunction)Cloud_setAdd, METH_O, "Sets oscillator add factor."},
1554 {"setSub", (PyCFunction)Cloud_setSub, METH_O, "Sets inverse add factor."},
1555 {"setDiv", (PyCFunction)Cloud_setDiv, METH_O, "Sets inverse mul factor."},
1556 {NULL} /* Sentinel */
1557 };
1558
1559 static PyNumberMethods Cloud_as_number =
1560 {
1561 (binaryfunc)Cloud_add, /*nb_add*/
1562 (binaryfunc)Cloud_sub, /*nb_subtract*/
1563 (binaryfunc)Cloud_multiply, /*nb_multiply*/
1564 0, /*nb_remainder*/
1565 0, /*nb_divmod*/
1566 0, /*nb_power*/
1567 0, /*nb_neg*/
1568 0, /*nb_pos*/
1569 0, /*(unaryfunc)array_abs,*/
1570 0, /*nb_nonzero*/
1571 0, /*nb_invert*/
1572 0, /*nb_lshift*/
1573 0, /*nb_rshift*/
1574 0, /*nb_and*/
1575 0, /*nb_xor*/
1576 0, /*nb_or*/
1577 0, /*nb_int*/
1578 0, /*nb_long*/
1579 0, /*nb_float*/
1580 (binaryfunc)Cloud_inplace_add, /*inplace_add*/
1581 (binaryfunc)Cloud_inplace_sub, /*inplace_subtract*/
1582 (binaryfunc)Cloud_inplace_multiply, /*inplace_multiply*/
1583 0, /*inplace_remainder*/
1584 0, /*inplace_power*/
1585 0, /*inplace_lshift*/
1586 0, /*inplace_rshift*/
1587 0, /*inplace_and*/
1588 0, /*inplace_xor*/
1589 0, /*inplace_or*/
1590 0, /*nb_floor_divide*/
1591 (binaryfunc)Cloud_div, /*nb_true_divide*/
1592 0, /*nb_inplace_floor_divide*/
1593 (binaryfunc)Cloud_inplace_div, /*nb_inplace_true_divide*/
1594 0, /* nb_index */
1595 };
1596
1597 PyTypeObject CloudType =
1598 {
1599 PyVarObject_HEAD_INIT(NULL, 0)
1600 "_pyo.Cloud_base", /*tp_name*/
1601 sizeof(Cloud), /*tp_basicsize*/
1602 0, /*tp_itemsize*/
1603 (destructor)Cloud_dealloc, /*tp_dealloc*/
1604 0, /*tp_print*/
1605 0, /*tp_getattr*/
1606 0, /*tp_setattr*/
1607 0, /*tp_as_async (tp_compare in Python 2)*/
1608 0, /*tp_repr*/
1609 &Cloud_as_number, /*tp_as_number*/
1610 0, /*tp_as_sequence*/
1611 0, /*tp_as_mapping*/
1612 0, /*tp_hash */
1613 0, /*tp_call*/
1614 0, /*tp_str*/
1615 0, /*tp_getattro*/
1616 0, /*tp_setattro*/
1617 0, /*tp_as_buffer*/
1618 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
1619 "Cloud objects. Reads a channel from a Clouder.", /* tp_doc */
1620 (traverseproc)Cloud_traverse, /* tp_traverse */
1621 (inquiry)Cloud_clear, /* tp_clear */
1622 0, /* tp_richcompare */
1623 0, /* tp_weaklistoffset */
1624 0, /* tp_iter */
1625 0, /* tp_iternext */
1626 Cloud_methods, /* tp_methods */
1627 Cloud_members, /* tp_members */
1628 0, /* tp_getset */
1629 0, /* tp_base */
1630 0, /* tp_dict */
1631 0, /* tp_descr_get */
1632 0, /* tp_descr_set */
1633 0, /* tp_dictoffset */
1634 0, /* tp_init */
1635 0, /* tp_alloc */
1636 Cloud_new, /* tp_new */
1637 };
1638
1639 /****************/
1640 /**** Trig *****/
1641 /****************/
1642 typedef struct
1643 {
1644 pyo_audio_HEAD
1645 int flag;
1646 int modebuffer[2];
1647 } Trig;
1648
1649 static void Trig_postprocessing_ii(Trig *self) { POST_PROCESSING_II };
1650 static void Trig_postprocessing_ai(Trig *self) { POST_PROCESSING_AI };
1651 static void Trig_postprocessing_ia(Trig *self) { POST_PROCESSING_IA };
1652 static void Trig_postprocessing_aa(Trig *self) { POST_PROCESSING_AA };
1653 static void Trig_postprocessing_ireva(Trig *self) { POST_PROCESSING_IREVA };
1654 static void Trig_postprocessing_areva(Trig *self) { POST_PROCESSING_AREVA };
1655 static void Trig_postprocessing_revai(Trig *self) { POST_PROCESSING_REVAI };
1656 static void Trig_postprocessing_revaa(Trig *self) { POST_PROCESSING_REVAA };
1657 static void Trig_postprocessing_revareva(Trig *self) { POST_PROCESSING_REVAREVA };
1658
1659 static void
1660 Trig_setProcMode(Trig *self)
1661 {
1662 int muladdmode;
1663 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
1664
1665 switch (muladdmode)
1666 {
1667 case 0:
1668 self->muladd_func_ptr = Trig_postprocessing_ii;
1669 break;
1670
1671 case 1:
1672 self->muladd_func_ptr = Trig_postprocessing_ai;
1673 break;
1674
1675 case 2:
1676 self->muladd_func_ptr = Trig_postprocessing_revai;
1677 break;
1678
1679 case 10:
1680 self->muladd_func_ptr = Trig_postprocessing_ia;
1681 break;
1682
1683 case 11:
1684 self->muladd_func_ptr = Trig_postprocessing_aa;
1685 break;
1686
1687 case 12:
1688 self->muladd_func_ptr = Trig_postprocessing_revaa;
1689 break;
1690
1691 case 20:
1692 self->muladd_func_ptr = Trig_postprocessing_ireva;
1693 break;
1694
1695 case 21:
1696 self->muladd_func_ptr = Trig_postprocessing_areva;
1697 break;
1698
1699 case 22:
1700 self->muladd_func_ptr = Trig_postprocessing_revareva;
1701 break;
1702 }
1703 }
1704
1705 static void
1706 Trig_compute_next_data_frame(Trig *self)
1707 {
1708 if (self->flag == 1)
1709 {
1710 self->data[0] = 1.0;
1711 self->flag = 0;
1712 }
1713 else
1714 self->data[0] = 0.0;
1715
1716 (*self->muladd_func_ptr)(self);
1717 }
1718
1719 static int
1720 Trig_traverse(Trig *self, visitproc visit, void *arg)
1721 {
1722 pyo_VISIT
1723 return 0;
1724 }
1725
1726 static int
1727 Trig_clear(Trig *self)
1728 {
1729 pyo_CLEAR
1730 return 0;
1731 }
1732
1733 static void
1734 Trig_dealloc(Trig* self)
1735 {
1736 pyo_DEALLOC
1737 Trig_clear(self);
1738 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
1739 Py_TYPE(self)->tp_free((PyObject*)self);
1740 }
1741
1742 static PyObject *
1743 Trig_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1744 {
1745 int i;
1746 Trig *self;
1747 self = (Trig *)type->tp_alloc(type, 0);
1748
1749 self->flag = 1;
1750 self->modebuffer[0] = 0;
1751 self->modebuffer[1] = 0;
1752
1753 INIT_OBJECT_COMMON
1754 Stream_setFunctionPtr(self->stream, Trig_compute_next_data_frame);
1755 self->mode_func_ptr = Trig_setProcMode;
1756
1757 static char *kwlist[] = {NULL};
1758
1759 if (! PyArg_ParseTupleAndKeywords(args, kwds, "", kwlist))
1760 Py_RETURN_NONE;
1761
1762 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
1763
1764 (*self->mode_func_ptr)(self);
1765
1766 return (PyObject *)self;
1767 }
1768
1769 static PyObject * Trig_getServer(Trig* self) { GET_SERVER };
1770 static PyObject * Trig_getStream(Trig* self) { GET_STREAM };
1771 static PyObject * Trig_setMul(Trig *self, PyObject *arg) { SET_MUL };
1772 static PyObject * Trig_setAdd(Trig *self, PyObject *arg) { SET_ADD };
1773 static PyObject * Trig_setSub(Trig *self, PyObject *arg) { SET_SUB };
1774 static PyObject * Trig_setDiv(Trig *self, PyObject *arg) { SET_DIV };
1775
1776 static PyObject * Trig_play(Trig *self, PyObject *args, PyObject *kwds)
1777 {
1778 self->flag = 1;
1779 PLAY
1780 };
1781
1782 static PyObject * Trig_stop(Trig *self, PyObject *args, PyObject *kwds) { STOP };
1783
1784 static PyObject * Trig_multiply(Trig *self, PyObject *arg) { MULTIPLY };
1785 static PyObject * Trig_inplace_multiply(Trig *self, PyObject *arg) { INPLACE_MULTIPLY };
1786 static PyObject * Trig_add(Trig *self, PyObject *arg) { ADD };
1787 static PyObject * Trig_inplace_add(Trig *self, PyObject *arg) { INPLACE_ADD };
1788 static PyObject * Trig_sub(Trig *self, PyObject *arg) { SUB };
1789 static PyObject * Trig_inplace_sub(Trig *self, PyObject *arg) { INPLACE_SUB };
1790 static PyObject * Trig_div(Trig *self, PyObject *arg) { DIV };
1791 static PyObject * Trig_inplace_div(Trig *self, PyObject *arg) { INPLACE_DIV };
1792
1793 static PyMemberDef Trig_members[] =
1794 {
1795 {"server", T_OBJECT_EX, offsetof(Trig, server), 0, "Pyo server."},
1796 {"stream", T_OBJECT_EX, offsetof(Trig, stream), 0, "Stream object."},
1797 {"mul", T_OBJECT_EX, offsetof(Trig, mul), 0, "Mul factor."},
1798 {"add", T_OBJECT_EX, offsetof(Trig, add), 0, "Add factor."},
1799 {NULL} /* Sentinel */
1800 };
1801
1802 static PyMethodDef Trig_methods[] =
1803 {
1804 {"getServer", (PyCFunction)Trig_getServer, METH_NOARGS, "Returns server object."},
1805 {"_getStream", (PyCFunction)Trig_getStream, METH_NOARGS, "Returns stream object."},
1806 {"play", (PyCFunction)Trig_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
1807 {"stop", (PyCFunction)Trig_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
1808 {"setMul", (PyCFunction)Trig_setMul, METH_O, "Sets oscillator mul factor."},
1809 {"setAdd", (PyCFunction)Trig_setAdd, METH_O, "Sets oscillator add factor."},
1810 {"setSub", (PyCFunction)Trig_setSub, METH_O, "Sets inverse add factor."},
1811 {"setDiv", (PyCFunction)Trig_setDiv, METH_O, "Sets inverse mul factor."},
1812 {NULL} /* Sentinel */
1813 };
1814
1815 static PyNumberMethods Trig_as_number =
1816 {
1817 (binaryfunc)Trig_add, /*nb_add*/
1818 (binaryfunc)Trig_sub, /*nb_subtract*/
1819 (binaryfunc)Trig_multiply, /*nb_multiply*/
1820 0, /*nb_remainder*/
1821 0, /*nb_divmod*/
1822 0, /*nb_power*/
1823 0, /*nb_neg*/
1824 0, /*nb_pos*/
1825 0, /*(unaryfunc)array_abs,*/
1826 0, /*nb_nonzero*/
1827 0, /*nb_invert*/
1828 0, /*nb_lshift*/
1829 0, /*nb_rshift*/
1830 0, /*nb_and*/
1831 0, /*nb_xor*/
1832 0, /*nb_or*/
1833 0, /*nb_int*/
1834 0, /*nb_long*/
1835 0, /*nb_float*/
1836 (binaryfunc)Trig_inplace_add, /*inplace_add*/
1837 (binaryfunc)Trig_inplace_sub, /*inplace_subtract*/
1838 (binaryfunc)Trig_inplace_multiply, /*inplace_multiply*/
1839 0, /*inplace_remainder*/
1840 0, /*inplace_power*/
1841 0, /*inplace_lshift*/
1842 0, /*inplace_rshift*/
1843 0, /*inplace_and*/
1844 0, /*inplace_xor*/
1845 0, /*inplace_or*/
1846 0, /*nb_floor_divide*/
1847 (binaryfunc)Trig_div, /*nb_true_divide*/
1848 0, /*nb_inplace_floor_divide*/
1849 (binaryfunc)Trig_inplace_div, /*nb_inplace_true_divide*/
1850 0, /* nb_index */
1851 };
1852
1853 PyTypeObject TrigType =
1854 {
1855 PyVarObject_HEAD_INIT(NULL, 0)
1856 "_pyo.Trig_base", /*tp_name*/
1857 sizeof(Trig), /*tp_basicsize*/
1858 0, /*tp_itemsize*/
1859 (destructor)Trig_dealloc, /*tp_dealloc*/
1860 0, /*tp_print*/
1861 0, /*tp_getattr*/
1862 0, /*tp_setattr*/
1863 0, /*tp_as_async (tp_compare in Python 2)*/
1864 0, /*tp_repr*/
1865 &Trig_as_number, /*tp_as_number*/
1866 0, /*tp_as_sequence*/
1867 0, /*tp_as_mapping*/
1868 0, /*tp_hash */
1869 0, /*tp_call*/
1870 0, /*tp_str*/
1871 0, /*tp_getattro*/
1872 0, /*tp_setattro*/
1873 0, /*tp_as_buffer*/
1874 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
1875 "Trig objects. Sends one trig.", /* tp_doc */
1876 (traverseproc)Trig_traverse, /* tp_traverse */
1877 (inquiry)Trig_clear, /* tp_clear */
1878 0, /* tp_richcompare */
1879 0, /* tp_weaklistoffset */
1880 0, /* tp_iter */
1881 0, /* tp_iternext */
1882 Trig_methods, /* tp_methods */
1883 Trig_members, /* tp_members */
1884 0, /* tp_getset */
1885 0, /* tp_base */
1886 0, /* tp_dict */
1887 0, /* tp_descr_get */
1888 0, /* tp_descr_set */
1889 0, /* tp_dictoffset */
1890 0, /* tp_init */
1891 0, /* tp_alloc */
1892 Trig_new, /* tp_new */
1893 };
1894
1895 /****************/
1896 /**** Beater *****/
1897 /****************/
1898 typedef struct
1899 {
1900 pyo_audio_HEAD
1901 PyObject *time;
1902 Stream *time_stream;
1903 int modebuffer[1];
1904 int poly;
1905 int voiceCount;
1906 int taps;
1907 int last_taps;
1908 int tapCount;
1909 int currentTap;
1910 int weight1;
1911 int last_weight1;
1912 int weight2;
1913 int last_weight2;
1914 int weight3;
1915 int last_weight3;
1916 int newFlag;
1917 int fillStart;
1918 int fillEnd;
1919 int sequence[64];
1920 int tmp_sequence[64];
1921 int tapList[64];
1922 int tapLength;
1923 int tapProb[64];
1924 int preset[32][65];
1925 int preCall;
1926 MYFLT durations[64];
1927 MYFLT tmp_durations[64];
1928 MYFLT accentTable[64];
1929 MYFLT tmp_accentTable[64];
1930 MYFLT tapDur;
1931 double sampleToSec;
1932 double currentTime;
1933 int onlyonce;
1934 int to_stop;
1935 MYFLT *buffer_streams;
1936 MYFLT *tap_buffer_streams;
1937 MYFLT *amp_buffer_streams;
1938 MYFLT *dur_buffer_streams;
1939 MYFLT *end_buffer_streams;
1940 MYFLT *amplitudes;
1941 } Beater;
1942
1943 static MYFLT
1944 Beater_defineAccent(int n)
1945 {
1946 if (n == 1)
1947 return (MYFLT)((pyorand() % 15) + 112) / 127.; // 112 -> 127
1948 else if (n == 2)
1949 return (MYFLT)((pyorand() % 20) + 70) / 127.; // 70 -> 90
1950 else if (n == 3)
1951 return (MYFLT)((pyorand() % 20) + 40) / 127.; // 40 -> 60
1952 else
1953 return 0.5;
1954 }
1955
1956 static void
1957 Beater_restore(Beater *self)
1958 {
1959 int i;
1960 self->fillEnd = 0;
1961
1962 for (i = 0; i < self->taps; i++)
1963 {
1964 self->accentTable[i] = self->tmp_accentTable[i];
1965 self->sequence[i] = self->tmp_sequence[i];
1966 self->durations[i] = self->tmp_durations[i];
1967 }
1968 }
1969
1970 static void
1971 Beater_makeTable(Beater *self, int fill)
1972 {
1973 short i;
1974 short len;
1975 int w1, w2, w3;
1976
1977 if (fill == 0)
1978 {
1979 self->last_taps = self->taps;
1980 w1 = self->last_weight1 = self->weight1;
1981 w2 = self->last_weight2 = self->weight2;
1982 w3 = self->last_weight3 = self->weight3;
1983 self->newFlag = 0;
1984 }
1985 else
1986 {
1987 w1 = self->weight1 + 20;
1988 w2 = self->weight2 + 20;
1989 w3 = self->weight3 + 20;
1990 self->fillStart = 0;
1991 self->fillEnd = 1;
1992
1993 for (i = 0; i < self->taps; i++)
1994 {
1995 self->tmp_accentTable[i] = self->accentTable[i];
1996 self->tmp_sequence[i] = self->sequence[i];
1997 self->tmp_durations[i] = self->durations[i];
1998 }
1999 }
2000
2001 if ((self->taps % 7) == 0)
2002 {
2003 len = 7;
2004
2005 for (i = 0; i < self->taps; i++)
2006 {
2007 if ((i % len) == 4 || (i % len) == 2)
2008 {
2009 self->tapProb[i] = w2;
2010 self->accentTable[i] = Beater_defineAccent(2);
2011 }
2012 else if ((i % len) == 0)
2013 {
2014 self->tapProb[i] = w1;
2015 self->accentTable[i] = Beater_defineAccent(1);
2016 }
2017 else
2018 {
2019 self->tapProb[i] = w3;
2020 self->accentTable[i] = Beater_defineAccent(3);
2021 }
2022 }
2023 }
2024 else if ((self->taps % 6) == 0)
2025 {
2026 len = 6;
2027
2028 for (i = 0; i < self->taps; i++)
2029 {
2030 if ((i % len) == 3)
2031 {
2032 self->tapProb[i] = w2;
2033 self->accentTable[i] = Beater_defineAccent(2);
2034 }
2035 else if ((i % len) == 0)
2036 {
2037 self->tapProb[i] = w1;
2038 self->accentTable[i] = Beater_defineAccent(1);
2039 }
2040 else
2041 {
2042 self->tapProb[i] = w3;
2043 self->accentTable[i] = Beater_defineAccent(3);
2044 }
2045 }
2046 }
2047 else if ((self->taps % 5) == 0)
2048 {
2049 len = 5;
2050
2051 for (i = 0; i < self->taps; i++)
2052 {
2053 if ((i % len) == 3)
2054 {
2055 self->tapProb[i] = w2;
2056 self->accentTable[i] = Beater_defineAccent(2);
2057 }
2058 else if ((i % len) == 0)
2059 {
2060 self->tapProb[i] = w1;
2061 self->accentTable[i] = Beater_defineAccent(1);
2062 }
2063 else
2064 {
2065 self->tapProb[i] = w3;
2066 self->accentTable[i] = Beater_defineAccent(3);
2067 }
2068 }
2069 }
2070 else if ((self->taps % 4) == 0)
2071 {
2072 len = 4;
2073
2074 for (i = 0; i < self->taps; i++)
2075 {
2076 if ((i % len) == 2)
2077 {
2078 self->tapProb[i] = w2;
2079 self->accentTable[i] = Beater_defineAccent(2);
2080 }
2081 else if ((i % len) == 0)
2082 {
2083 self->tapProb[i] = w1;
2084 self->accentTable[i] = Beater_defineAccent(1);
2085 }
2086 else
2087 {
2088 self->tapProb[i] = w3;
2089 self->accentTable[i] = Beater_defineAccent(3);
2090 }
2091 }
2092 }
2093 else if ((self->taps % 3) == 0)
2094 {
2095 len = 3;
2096
2097 for (i = 0; i < self->taps; i++)
2098 {
2099 if ((i % len) == 0)
2100 {
2101 self->tapProb[i] = w1;
2102 self->accentTable[i] = Beater_defineAccent(1);
2103 }
2104 else
2105 {
2106 self->tapProb[i] = w3;
2107 self->accentTable[i] = Beater_defineAccent(3);
2108 }
2109 }
2110 }
2111 else if ((self->taps % 2) == 0)
2112 {
2113 len = 2;
2114
2115 for (i = 0; i < self->taps; i++)
2116 {
2117 if ((i % len) == 0)
2118 {
2119 self->tapProb[i] = w1;
2120 self->accentTable[i] = Beater_defineAccent(1);
2121 }
2122 else
2123 {
2124 self->tapProb[i] = w3;
2125 self->accentTable[i] = Beater_defineAccent(3);
2126 }
2127 }
2128 }
2129 }
2130
2131 static void
2132 Beater_makeSequence(Beater *self)
2133 {
2134 short i, j;
2135
2136 j = 0;
2137
2138 for (i = 0; i < self->taps; i++)
2139 {
2140 if ((int)(pyorand() % 100) < self->tapProb[i])
2141 {
2142 self->sequence[i] = 1;
2143 self->tapList[j++] = i;
2144 }
2145 else
2146 self->sequence[i] = 0;
2147 }
2148
2149 self->tapLength = j;
2150 }
2151
2152 static void
2153 Beater_calculateDurations(Beater *self)
2154 {
2155 int i;
2156
2157 for (i = 0; i < (self->tapLength - 1); i++)
2158 {
2159 self->durations[self->tapList[i]] = (self->tapList[i + 1] - self->tapList[i]) * self->tapDur - 0.005;
2160 }
2161
2162 self->durations[self->tapList[self->tapLength - 1]] = (self->last_taps - self->tapList[self->tapLength - 1] + self->tapList[0]) * self->tapDur - 0.005;
2163 }
2164
2165 static void
2166 Beater_makePresetActive(Beater *self, int n)
2167 {
2168 int i, j, len;
2169
2170 self->preCall = -1;
2171 len = self->preset[n][0];
2172
2173 if (len != self->taps)
2174 {
2175 self->taps = len;
2176 Beater_makeTable(self, 0);
2177 }
2178
2179 j = 0;
2180
2181 for (i = 0; i < self->taps; i++)
2182 {
2183 self->sequence[i] = self->preset[n][i + 1];
2184
2185 if (self->sequence[i] == 1)
2186 self->tapList[j++] = i;
2187 }
2188
2189 self->tapLength = j;
2190 }
2191
2192 static void
2193 Beater_generate_i(Beater *self)
2194 {
2195 int i, j;
2196 double tm;
2197
2198 tm = PyFloat_AS_DOUBLE(self->time);
2199
2200 self->tapDur = (MYFLT)tm;
2201 Beater_calculateDurations(self);
2202
2203 if (self->currentTime == -1.0)
2204 {
2205 self->currentTime = tm;
2206 }
2207
2208 for (i = 0; i < (self->poly * self->bufsize); i++)
2209 {
2210 self->buffer_streams[i] = self->end_buffer_streams[i] = 0.0;
2211 }
2212
2213 if (self->to_stop)
2214 {
2215 PyObject_CallMethod((PyObject *)self, "stop", NULL);
2216 self->to_stop = 0;
2217 return;
2218 }
2219
2220 for (i = 0; i < self->bufsize; i++)
2221 {
2222 self->tap_buffer_streams[i + self->voiceCount * self->bufsize] = (MYFLT)self->currentTap;
2223
2224 for (j = 0; j < self->poly; j++)
2225 {
2226 self->amp_buffer_streams[i + j * self->bufsize] = self->amplitudes[j];
2227 }
2228
2229 self->dur_buffer_streams[i + self->voiceCount * self->bufsize] = self->durations[self->tapCount];
2230
2231 if (self->currentTime >= tm)
2232 {
2233 self->currentTime -= tm;
2234
2235 if (self->tapCount == (self->last_taps - 2))
2236 {
2237 self->end_buffer_streams[i + self->voiceCount * self->bufsize] = 1.0;
2238 }
2239
2240 if (self->sequence[self->tapCount] == 1)
2241 {
2242 self->currentTap = self->tapCount;
2243 self->amplitudes[self->voiceCount] = self->accentTable[self->tapCount];
2244 self->buffer_streams[i + self->voiceCount++ * self->bufsize] = 1.0;
2245
2246 if (self->voiceCount == self->poly)
2247 self->voiceCount = 0;
2248 }
2249
2250 self->tapCount++;
2251
2252 if (self->tapCount >= self->last_taps)
2253 {
2254 self->tapCount = 0;
2255
2256 if (self->fillStart == 1)
2257 {
2258 Beater_makeTable(self, 1);
2259 Beater_makeSequence(self);
2260 }
2261 else if (self->fillEnd == 1 && self->newFlag == 1)
2262 {
2263 Beater_restore(self);
2264 Beater_makeTable(self, 0);
2265 Beater_makeSequence(self);
2266 }
2267 else if (self->fillEnd == 1 && self->preCall != -1)
2268 {
2269 Beater_restore(self);
2270 Beater_makePresetActive(self, self->preCall);
2271 }
2272 else if (self->fillEnd == 1)
2273 {
2274 Beater_restore(self);
2275 }
2276 else if (self->preCall != -1)
2277 {
2278 Beater_makePresetActive(self, self->preCall);
2279 }
2280 else if (self->last_taps != self->taps || self->last_weight1 != self->weight1 ||
2281 self->last_weight2 != self->weight2 || self->last_weight3 != self->weight3 ||
2282 self->newFlag == 1)
2283 {
2284 Beater_makeTable(self, 0);
2285 Beater_makeSequence(self);
2286 }
2287
2288 if (self->onlyonce)
2289 {
2290 self->to_stop = 1;
2291 return;
2292 }
2293 }
2294 }
2295
2296 self->currentTime += self->sampleToSec;
2297 }
2298 }
2299
2300 static void
2301 Beater_generate_a(Beater *self)
2302 {
2303 double tm;
2304 int i, j;
2305
2306 MYFLT *time = Stream_getData((Stream *)self->time_stream);
2307
2308 self->tapDur = time[0];
2309 Beater_calculateDurations(self);
2310
2311 if (self->currentTime == -1.0)
2312 {
2313 self->currentTime = (double)time[0];
2314 }
2315
2316 for (i = 0; i < (self->poly * self->bufsize); i++)
2317 {
2318 self->buffer_streams[i] = self->end_buffer_streams[i] = 0.0;
2319 }
2320
2321 if (self->to_stop)
2322 {
2323 PyObject_CallMethod((PyObject *)self, "stop", NULL);
2324 self->to_stop = 0;
2325 return;
2326 }
2327
2328 for (i = 0; i < self->bufsize; i++)
2329 {
2330 tm = (double)time[i];
2331 self->tap_buffer_streams[i + self->voiceCount * self->bufsize] = (MYFLT)self->currentTap;
2332
2333 for (j = 0; j < self->poly; j++)
2334 {
2335 self->amp_buffer_streams[i + j * self->bufsize] = self->amplitudes[j];
2336 }
2337
2338 self->dur_buffer_streams[i + self->voiceCount * self->bufsize] = self->durations[self->tapCount];
2339
2340 if (self->currentTime >= tm)
2341 {
2342 self->currentTime -= tm;
2343
2344 if (self->tapCount == (self->last_taps - 2))
2345 self->end_buffer_streams[i + self->voiceCount * self->bufsize] = 1.0;
2346
2347 if (self->sequence[self->tapCount] == 1)
2348 {
2349 self->currentTap = self->tapCount;
2350 self->amplitudes[self->voiceCount] = self->accentTable[self->tapCount];
2351 self->buffer_streams[i + self->voiceCount++ * self->bufsize] = 1.0;
2352
2353 if (self->voiceCount == self->poly)
2354 self->voiceCount = 0;
2355 }
2356
2357 self->tapCount++;
2358
2359 if (self->tapCount >= self->last_taps)
2360 {
2361 self->tapCount = 0;
2362
2363 if (self->fillStart == 1)
2364 {
2365 Beater_makeTable(self, 1);
2366 Beater_makeSequence(self);
2367 }
2368 else if (self->fillEnd == 1 && self->newFlag == 1)
2369 {
2370 Beater_restore(self);
2371 Beater_makeTable(self, 0);
2372 Beater_makeSequence(self);
2373 }
2374 else if (self->fillEnd == 1 && self->preCall != -1)
2375 {
2376 Beater_restore(self);
2377 Beater_makePresetActive(self, self->preCall);
2378 }
2379 else if (self->fillEnd == 1)
2380 {
2381 Beater_restore(self);
2382 }
2383 else if (self->preCall != -1)
2384 {
2385 Beater_makePresetActive(self, self->preCall);
2386 }
2387 else if (self->last_taps != self->taps || self->last_weight1 != self->weight1 ||
2388 self->last_weight2 != self->weight2 || self->last_weight3 != self->weight3 ||
2389 self->newFlag == 1)
2390 {
2391 self->tapDur = time[i];
2392 Beater_makeTable(self, 0);
2393 Beater_makeSequence(self);
2394 }
2395
2396 if (self->onlyonce)
2397 {
2398 self->to_stop = 1;
2399 return;
2400 }
2401 }
2402 }
2403
2404 self->currentTime += self->sampleToSec;
2405 }
2406 }
2407
2408 MYFLT *
2409 Beater_getSamplesBuffer(Beater *self)
2410 {
2411 return (MYFLT *)self->buffer_streams;
2412 }
2413
2414 MYFLT *
2415 Beater_getTapBuffer(Beater *self)
2416 {
2417 return (MYFLT *)self->tap_buffer_streams;
2418 }
2419
2420 MYFLT *
2421 Beater_getAmpBuffer(Beater *self)
2422 {
2423 return (MYFLT *)self->amp_buffer_streams;
2424 }
2425
2426 MYFLT *
2427 Beater_getDurBuffer(Beater *self)
2428 {
2429 return (MYFLT *)self->dur_buffer_streams;
2430 }
2431
2432 MYFLT *
2433 Beater_getEndBuffer(Beater *self)
2434 {
2435 return (MYFLT *)self->end_buffer_streams;
2436 }
2437
2438 static void
2439 Beater_setProcMode(Beater *self)
2440 {
2441 int procmode = self->modebuffer[0];
2442
2443 switch (procmode)
2444 {
2445 case 0:
2446 self->proc_func_ptr = Beater_generate_i;
2447 break;
2448
2449 case 1:
2450 self->proc_func_ptr = Beater_generate_a;
2451 break;
2452 }
2453 }
2454
2455 static void
2456 Beater_compute_next_data_frame(Beater *self)
2457 {
2458 (*self->proc_func_ptr)(self);
2459 }
2460
2461 static int
2462 Beater_traverse(Beater *self, visitproc visit, void *arg)
2463 {
2464 pyo_VISIT
2465 Py_VISIT(self->time);
2466 return 0;
2467 }
2468
2469 static int
2470 Beater_clear(Beater *self)
2471 {
2472 pyo_CLEAR
2473 Py_CLEAR(self->time);
2474 return 0;
2475 }
2476
2477 static void
2478 Beater_dealloc(Beater* self)
2479 {
2480 pyo_DEALLOC
2481 PyMem_RawFree(self->buffer_streams);
2482 PyMem_RawFree(self->tap_buffer_streams);
2483 PyMem_RawFree(self->amp_buffer_streams);
2484 PyMem_RawFree(self->dur_buffer_streams);
2485 PyMem_RawFree(self->end_buffer_streams);
2486 PyMem_RawFree(self->amplitudes);
2487 Beater_clear(self);
2488 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
2489 Py_TYPE(self)->tp_free((PyObject*)self);
2490 }
2491
2492 static PyObject *
2493 Beater_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
2494 {
2495 int i, j;
2496 PyObject *timetmp = NULL;
2497 Beater *self;
2498 self = (Beater *)type->tp_alloc(type, 0);
2499
2500 for (i = 0; i < 32; i++)
2501 {
2502 for (j = 0; j < 64; j++)
2503 {
2504 self->preset[i][j] = 0;
2505 }
2506 }
2507
2508 self->preCall = -1;
2509 self->time = PyFloat_FromDouble(0.125);
2510 self->tapDur = 0.125;
2511 self->poly = 1;
2512 self->onlyonce = 0;
2513 self->to_stop = 0;
2514 self->voiceCount = 0;
2515 self->modebuffer[0] = 0;
2516
2517 self->taps = 16;
2518 self->tapCount = 0;
2519 self->currentTap = 0;
2520 self->weight1 = 80;
2521 self->weight2 = 50;
2522 self->weight3 = 30;
2523 self->last_taps = self->last_weight1 = self->last_weight2 = self->last_weight3 = -1;
2524 self->newFlag = self->fillStart = self->fillEnd = 0;
2525 self->tapLength = 0;
2526
2527 INIT_OBJECT_COMMON
2528 Stream_setFunctionPtr(self->stream, Beater_compute_next_data_frame);
2529 self->mode_func_ptr = Beater_setProcMode;
2530
2531 self->sampleToSec = 1. / self->sr;
2532 self->currentTime = -1.0;
2533
2534 Stream_setStreamActive(self->stream, 0);
2535
2536 static char *kwlist[] = {"time", "taps", "weight1", "weight2", "weight3", "poly", "onlyonce", NULL};
2537
2538 if (! PyArg_ParseTupleAndKeywords(args, kwds, "|Oiiiiii", kwlist, &timetmp, &self->taps, &self->weight1, &self->weight2, &self->weight3, &self->poly, &self->onlyonce))
2539 Py_RETURN_NONE;
2540
2541 if (timetmp)
2542 {
2543 PyObject_CallMethod((PyObject *)self, "setTime", "O", timetmp);
2544 }
2545
2546 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
2547
2548 (*self->mode_func_ptr)(self);
2549
2550 Server_generateSeed((Server *)self->server, BEATER_ID);
2551
2552 self->buffer_streams = (MYFLT *)PyMem_RawRealloc(self->buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
2553 self->tap_buffer_streams = (MYFLT *)PyMem_RawRealloc(self->tap_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
2554 self->amp_buffer_streams = (MYFLT *)PyMem_RawRealloc(self->amp_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
2555 self->dur_buffer_streams = (MYFLT *)PyMem_RawRealloc(self->dur_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
2556 self->end_buffer_streams = (MYFLT *)PyMem_RawRealloc(self->end_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
2557
2558 for (i = 0; i < (self->poly * self->bufsize); i++)
2559 {
2560 self->buffer_streams[i] = self->tap_buffer_streams[i] = self->amp_buffer_streams[i] = self->dur_buffer_streams[i] = self->end_buffer_streams[i] = 0.0;
2561 }
2562
2563 self->amplitudes = (MYFLT *)PyMem_RawRealloc(self->amplitudes, self->poly * sizeof(MYFLT));
2564
2565 for (i = 0; i < self->poly; i++)
2566 {
2567 self->amplitudes[i] = 0.0;
2568 }
2569
2570 Beater_makeTable(self, 0);
2571 Beater_makeSequence(self);
2572
2573 return (PyObject *)self;
2574 }
2575
2576 static PyObject * Beater_getServer(Beater* self) { GET_SERVER };
2577 static PyObject * Beater_getStream(Beater* self) { GET_STREAM };
2578
2579 static PyObject * Beater_play(Beater *self, PyObject *args, PyObject *kwds)
2580 {
2581 self->to_stop = 0;
2582 self->voiceCount = 0;
2583 self->tapCount = 0;
2584 self->currentTap = 0;
2585 self->currentTime = -1.0;
2586 PLAY
2587 };
2588 static PyObject * Beater_stop(Beater *self, PyObject *args, PyObject *kwds) { STOP };
2589
2590 static PyObject * Beater_setTime(Beater *self, PyObject *arg) { SET_PARAM(self->time, self->time_stream, 0); }
2591
2592 static PyObject *
2593 Beater_reset(Beater *self)
2594 {
2595 self->voiceCount = 0;
2596 self->tapCount = 0;
2597 self->currentTap = 0;
2598 self->currentTime = -1.0;
2599 Py_RETURN_NONE;
2600 }
2601
2602 static PyObject *
2603 Beater_setTaps(Beater *self, PyObject *arg)
2604 {
2605 if (PyLong_Check(arg))
2606 self->taps = PyLong_AsLong(arg);
2607
2608 Py_RETURN_NONE;
2609 }
2610
2611 static PyObject *
2612 Beater_setWeights(Beater *self, PyObject *args, PyObject *kwds)
2613 {
2614 PyObject *w1 = NULL, *w2 = NULL, *w3 = NULL;
2615
2616 static char *kwlist[] = {"weight1", "weight2", "weight3", NULL};
2617
2618 if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", kwlist, &w1, &w2, &w3))
2619 {
2620 Py_RETURN_NONE;
2621 }
2622
2623 if (PyLong_Check(w1))
2624 self->weight1 = PyLong_AsLong(w1);
2625
2626 if (PyLong_Check(w2))
2627 self->weight2 = PyLong_AsLong(w2);
2628
2629 if (PyLong_Check(w3))
2630 self->weight3 = PyLong_AsLong(w3);
2631
2632 Py_RETURN_NONE;
2633 }
2634
2635 static PyObject *
2636 Beater_newPattern(Beater *self, PyObject *arg)
2637 {
2638 if (PyLong_Check(arg))
2639 {
2640 if (PyLong_AsLong(arg))
2641 {
2642 Beater_makeTable(self, 0);
2643 Beater_makeSequence(self);
2644 }
2645 else
2646 {
2647 self->newFlag = 1;
2648 }
2649 }
2650
2651 Py_RETURN_NONE;
2652 }
2653
2654 static PyObject *
2655 Beater_fillPattern(Beater *self)
2656 {
2657 self->fillStart = 1;
2658 Py_RETURN_NONE;
2659 }
2660
2661 static PyObject *
2662 Beater_storePreset(Beater *self, PyObject *arg)
2663 {
2664 int i, n;
2665
2666 if (PyLong_Check(arg))
2667 {
2668 n = PyLong_AsLong(arg);
2669 self->preset[n][0] = self->taps;
2670
2671 for (i = 0; i < self->taps; i++)
2672 {
2673 self->preset[n][i + 1] = self->sequence[i];
2674 }
2675 }
2676
2677 Py_RETURN_NONE;
2678 }
2679
2680 static PyObject *
2681 Beater_recallPreset(Beater *self, PyObject *arg)
2682 {
2683 int x;
2684
2685 if (PyLong_Check(arg))
2686 {
2687 x = PyLong_AsLong(arg);
2688
2689 if (x >= 0 && x < 32)
2690 self->preCall = x;
2691 }
2692
2693 if (Stream_getStreamActive(self->stream) == 0)
2694 Beater_makePresetActive(self, self->preCall);
2695
2696 Py_RETURN_NONE;
2697
2698 }
2699
2700 static PyObject *
2701 Beater_getPresets(Beater *self)
2702 {
2703 int i, j;
2704 PyObject *list, *tmp;
2705
2706 list = PyList_New(0);
2707
2708 for (i = 0; i < 32; i++)
2709 {
2710 if (self->preset[i][0] != 0)
2711 {
2712 tmp = PyList_New(0);
2713 PyList_Append(tmp, PyLong_FromLong(self->preset[i][0]));
2714
2715 for (j = 0; j < self->preset[i][0]; j++)
2716 {
2717 PyList_Append(tmp, PyLong_FromLong(self->preset[i][j + 1]));
2718 }
2719
2720 PyList_Append(list, tmp);
2721 }
2722 }
2723
2724 return list;
2725 }
2726
2727 static PyObject *
2728 Beater_setPresets(Beater *self, PyObject *arg)
2729 {
2730 int i, j, len, len2;
2731 PyObject *tmp;
2732
2733 if (PyList_Check(arg))
2734 {
2735 len = PyList_Size(arg);
2736
2737 for (i = 0; i < len; i++)
2738 {
2739 tmp = PyList_GetItem(arg, i);
2740
2741 if (PyList_Check(tmp))
2742 {
2743 len2 = PyLong_AsLong(PyList_GetItem(tmp, 0));
2744 self->preset[i][0] = len2;
2745
2746 for (j = 0; j < len2; j++)
2747 {
2748 self->preset[i][j + 1] = PyLong_AsLong(PyList_GetItem(tmp, j + 1));
2749 }
2750 }
2751 }
2752 }
2753
2754 Py_RETURN_NONE;
2755 }
2756
2757 static PyObject *
2758 Beater_setOnlyonce(Beater *self, PyObject *arg)
2759 {
2760 ASSERT_ARG_NOT_NULL
2761
2762 if (PyLong_Check(arg))
2763 {
2764 self->onlyonce = PyLong_AsLong(arg);
2765 }
2766
2767 Py_RETURN_NONE;
2768 }
2769
2770 static PyMemberDef Beater_members[] =
2771 {
2772 {"server", T_OBJECT_EX, offsetof(Beater, server), 0, "Pyo server."},
2773 {"stream", T_OBJECT_EX, offsetof(Beater, stream), 0, "Stream object."},
2774 {"time", T_OBJECT_EX, offsetof(Beater, time), 0, "Tap duration."},
2775 {NULL} /* Sentinel */
2776 };
2777
2778 static PyMethodDef Beater_methods[] =
2779 {
2780 {"getServer", (PyCFunction)Beater_getServer, METH_NOARGS, "Returns server object."},
2781 {"_getStream", (PyCFunction)Beater_getStream, METH_NOARGS, "Returns stream object."},
2782 {"play", (PyCFunction)Beater_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
2783 {"stop", (PyCFunction)Beater_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
2784 {"setTime", (PyCFunction)Beater_setTime, METH_O, "Sets tap duration."},
2785 {"setTaps", (PyCFunction)Beater_setTaps, METH_O, "Sets number of taps in the pattern."},
2786 {"setWeights", (PyCFunction)Beater_setWeights, METH_VARARGS | METH_KEYWORDS, "Sets probabilities for time accents in the pattern."},
2787 {"new", (PyCFunction)Beater_newPattern, METH_O, "Generates a new pattern."},
2788 {"fill", (PyCFunction)Beater_fillPattern, METH_NOARGS, "Generates a fillin pattern and then restore the current pattern."},
2789 {"store", (PyCFunction)Beater_storePreset, METH_O, "Store the current pattern in a memory slot."},
2790 {"recall", (PyCFunction)Beater_recallPreset, METH_O, "Recall a pattern previously stored in a memory slot."},
2791 {"getPresets", (PyCFunction)Beater_getPresets, METH_NOARGS, "Returns the list of stored presets."},
2792 {"setPresets", (PyCFunction)Beater_setPresets, METH_O, "Store a list of presets."},
2793 {"setOnlyonce", (PyCFunction)Beater_setOnlyonce, METH_O, "Sets onlyonce attribute."},
2794 {"reset", (PyCFunction)Beater_reset, METH_NOARGS, "Resets counters to 0."},
2795 {NULL} /* Sentinel */
2796 };
2797
2798 PyTypeObject BeaterType =
2799 {
2800 PyVarObject_HEAD_INIT(NULL, 0)
2801 "_pyo.Beater_base", /*tp_name*/
2802 sizeof(Beater), /*tp_basicsize*/
2803 0, /*tp_itemsize*/
2804 (destructor)Beater_dealloc, /*tp_dealloc*/
2805 0, /*tp_print*/
2806 0, /*tp_getattr*/
2807 0, /*tp_setattr*/
2808 0, /*tp_as_async (tp_compare in Python 2)*/
2809 0, /*tp_repr*/
2810 0, /*tp_as_number*/
2811 0, /*tp_as_sequence*/
2812 0, /*tp_as_mapping*/
2813 0, /*tp_hash */
2814 0, /*tp_call*/
2815 0, /*tp_str*/
2816 0, /*tp_getattro*/
2817 0, /*tp_setattro*/
2818 0, /*tp_as_buffer*/
2819 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
2820 "Beater objects. Create an algorithmic beat sequence.", /* tp_doc */
2821 (traverseproc)Beater_traverse, /* tp_traverse */
2822 (inquiry)Beater_clear, /* tp_clear */
2823 0, /* tp_richcompare */
2824 0, /* tp_weaklistoffset */
2825 0, /* tp_iter */
2826 0, /* tp_iternext */
2827 Beater_methods, /* tp_methods */
2828 Beater_members, /* tp_members */
2829 0, /* tp_getset */
2830 0, /* tp_base */
2831 0, /* tp_dict */
2832 0, /* tp_descr_get */
2833 0, /* tp_descr_set */
2834 0, /* tp_dictoffset */
2835 0, /* tp_init */
2836 0, /* tp_alloc */
2837 Beater_new, /* tp_new */
2838 };
2839
2840 /************************************************************************************************/
2841 /* Beat streamer object per channel */
2842 /************************************************************************************************/
2843 typedef struct
2844 {
2845 pyo_audio_HEAD
2846 Beater *mainPlayer;
2847 int chnl;
2848 int modebuffer[2];
2849 } Beat;
2850
2851 static void Beat_postprocessing_ii(Beat *self) { POST_PROCESSING_II };
2852 static void Beat_postprocessing_ai(Beat *self) { POST_PROCESSING_AI };
2853 static void Beat_postprocessing_ia(Beat *self) { POST_PROCESSING_IA };
2854 static void Beat_postprocessing_aa(Beat *self) { POST_PROCESSING_AA };
2855 static void Beat_postprocessing_ireva(Beat *self) { POST_PROCESSING_IREVA };
2856 static void Beat_postprocessing_areva(Beat *self) { POST_PROCESSING_AREVA };
2857 static void Beat_postprocessing_revai(Beat *self) { POST_PROCESSING_REVAI };
2858 static void Beat_postprocessing_revaa(Beat *self) { POST_PROCESSING_REVAA };
2859 static void Beat_postprocessing_revareva(Beat *self) { POST_PROCESSING_REVAREVA };
2860
2861 static void
2862 Beat_setProcMode(Beat *self)
2863 {
2864 int muladdmode;
2865 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
2866
2867 switch (muladdmode)
2868 {
2869 case 0:
2870 self->muladd_func_ptr = Beat_postprocessing_ii;
2871 break;
2872
2873 case 1:
2874 self->muladd_func_ptr = Beat_postprocessing_ai;
2875 break;
2876
2877 case 2:
2878 self->muladd_func_ptr = Beat_postprocessing_revai;
2879 break;
2880
2881 case 10:
2882 self->muladd_func_ptr = Beat_postprocessing_ia;
2883 break;
2884
2885 case 11:
2886 self->muladd_func_ptr = Beat_postprocessing_aa;
2887 break;
2888
2889 case 12:
2890 self->muladd_func_ptr = Beat_postprocessing_revaa;
2891 break;
2892
2893 case 20:
2894 self->muladd_func_ptr = Beat_postprocessing_ireva;
2895 break;
2896
2897 case 21:
2898 self->muladd_func_ptr = Beat_postprocessing_areva;
2899 break;
2900
2901 case 22:
2902 self->muladd_func_ptr = Beat_postprocessing_revareva;
2903 break;
2904 }
2905 }
2906
2907 static void
2908 Beat_compute_next_data_frame(Beat *self)
2909 {
2910 int i;
2911 MYFLT *tmp;
2912 int offset = self->chnl * self->bufsize;
2913 tmp = Beater_getSamplesBuffer((Beater *)self->mainPlayer);
2914
2915 for (i = 0; i < self->bufsize; i++)
2916 {
2917 self->data[i] = tmp[i + offset];
2918 }
2919
2920 (*self->muladd_func_ptr)(self);
2921 }
2922
2923 static int
2924 Beat_traverse(Beat *self, visitproc visit, void *arg)
2925 {
2926 pyo_VISIT
2927 Py_VISIT(self->mainPlayer);
2928 return 0;
2929 }
2930
2931 static int
2932 Beat_clear(Beat *self)
2933 {
2934 pyo_CLEAR
2935 Py_CLEAR(self->mainPlayer);
2936 return 0;
2937 }
2938
2939 static void
2940 Beat_dealloc(Beat* self)
2941 {
2942 pyo_DEALLOC
2943 Beat_clear(self);
2944 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
2945 Py_TYPE(self)->tp_free((PyObject*)self);
2946 }
2947
2948 static PyObject *
2949 Beat_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
2950 {
2951 int i;
2952 PyObject *maintmp = NULL;
2953 Beat *self;
2954 self = (Beat *)type->tp_alloc(type, 0);
2955
2956 self->chnl = 0;
2957 self->modebuffer[0] = 0;
2958 self->modebuffer[1] = 0;
2959
2960 INIT_OBJECT_COMMON
2961 Stream_setFunctionPtr(self->stream, Beat_compute_next_data_frame);
2962 self->mode_func_ptr = Beat_setProcMode;
2963
2964 static char *kwlist[] = {"mainPlayer", "chnl", NULL};
2965
2966 if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
2967 Py_RETURN_NONE;
2968
2969 self->mainPlayer = (Beater *)maintmp;
2970 Py_INCREF(self->mainPlayer);
2971
2972 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
2973
2974 (*self->mode_func_ptr)(self);
2975
2976 return (PyObject *)self;
2977 }
2978
2979 static PyObject * Beat_getServer(Beat* self) { GET_SERVER };
2980 static PyObject * Beat_getStream(Beat* self) { GET_STREAM };
2981 static PyObject * Beat_setMul(Beat *self, PyObject *arg) { SET_MUL };
2982 static PyObject * Beat_setAdd(Beat *self, PyObject *arg) { SET_ADD };
2983 static PyObject * Beat_setSub(Beat *self, PyObject *arg) { SET_SUB };
2984 static PyObject * Beat_setDiv(Beat *self, PyObject *arg) { SET_DIV };
2985
2986 static PyObject * Beat_play(Beat *self, PyObject *args, PyObject *kwds) { PLAY };
2987 static PyObject * Beat_out(Beat *self, PyObject *args, PyObject *kwds) { OUT };
2988 static PyObject * Beat_stop(Beat *self, PyObject *args, PyObject *kwds) { STOP };
2989
2990 static PyObject * Beat_multiply(Beat *self, PyObject *arg) { MULTIPLY };
2991 static PyObject * Beat_inplace_multiply(Beat *self, PyObject *arg) { INPLACE_MULTIPLY };
2992 static PyObject * Beat_add(Beat *self, PyObject *arg) { ADD };
2993 static PyObject * Beat_inplace_add(Beat *self, PyObject *arg) { INPLACE_ADD };
2994 static PyObject * Beat_sub(Beat *self, PyObject *arg) { SUB };
2995 static PyObject * Beat_inplace_sub(Beat *self, PyObject *arg) { INPLACE_SUB };
2996 static PyObject * Beat_div(Beat *self, PyObject *arg) { DIV };
2997 static PyObject * Beat_inplace_div(Beat *self, PyObject *arg) { INPLACE_DIV };
2998
2999 static PyMemberDef Beat_members[] =
3000 {
3001 {"server", T_OBJECT_EX, offsetof(Beat, server), 0, "Pyo server."},
3002 {"stream", T_OBJECT_EX, offsetof(Beat, stream), 0, "Stream object."},
3003 {"mul", T_OBJECT_EX, offsetof(Beat, mul), 0, "Mul factor."},
3004 {"add", T_OBJECT_EX, offsetof(Beat, add), 0, "Add factor."},
3005 {NULL} /* Sentinel */
3006 };
3007
3008 static PyMethodDef Beat_methods[] =
3009 {
3010 {"getServer", (PyCFunction)Beat_getServer, METH_NOARGS, "Returns server object."},
3011 {"_getStream", (PyCFunction)Beat_getStream, METH_NOARGS, "Returns stream object."},
3012 {"play", (PyCFunction)Beat_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
3013 {"out", (PyCFunction)Beat_out, METH_VARARGS | METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
3014 {"stop", (PyCFunction)Beat_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
3015 {"setMul", (PyCFunction)Beat_setMul, METH_O, "Sets oscillator mul factor."},
3016 {"setAdd", (PyCFunction)Beat_setAdd, METH_O, "Sets oscillator add factor."},
3017 {"setSub", (PyCFunction)Beat_setSub, METH_O, "Sets inverse add factor."},
3018 {"setDiv", (PyCFunction)Beat_setDiv, METH_O, "Sets inverse mul factor."},
3019 {NULL} /* Sentinel */
3020 };
3021
3022 static PyNumberMethods Beat_as_number =
3023 {
3024 (binaryfunc)Beat_add, /*nb_add*/
3025 (binaryfunc)Beat_sub, /*nb_subtract*/
3026 (binaryfunc)Beat_multiply, /*nb_multiply*/
3027 0, /*nb_remainder*/
3028 0, /*nb_divmod*/
3029 0, /*nb_power*/
3030 0, /*nb_neg*/
3031 0, /*nb_pos*/
3032 0, /*(unaryfunc)array_abs,*/
3033 0, /*nb_nonzero*/
3034 0, /*nb_invert*/
3035 0, /*nb_lshift*/
3036 0, /*nb_rshift*/
3037 0, /*nb_and*/
3038 0, /*nb_xor*/
3039 0, /*nb_or*/
3040 0, /*nb_int*/
3041 0, /*nb_long*/
3042 0, /*nb_float*/
3043 (binaryfunc)Beat_inplace_add, /*inplace_add*/
3044 (binaryfunc)Beat_inplace_sub, /*inplace_subtract*/
3045 (binaryfunc)Beat_inplace_multiply, /*inplace_multiply*/
3046 0, /*inplace_remainder*/
3047 0, /*inplace_power*/
3048 0, /*inplace_lshift*/
3049 0, /*inplace_rshift*/
3050 0, /*inplace_and*/
3051 0, /*inplace_xor*/
3052 0, /*inplace_or*/
3053 0, /*nb_floor_divide*/
3054 (binaryfunc)Beat_div, /*nb_true_divide*/
3055 0, /*nb_inplace_floor_divide*/
3056 (binaryfunc)Beat_inplace_div, /*nb_inplace_true_divide*/
3057 0, /* nb_index */
3058 };
3059
3060 PyTypeObject BeatType =
3061 {
3062 PyVarObject_HEAD_INIT(NULL, 0)
3063 "_pyo.Beat_base", /*tp_name*/
3064 sizeof(Beat), /*tp_basicsize*/
3065 0, /*tp_itemsize*/
3066 (destructor)Beat_dealloc, /*tp_dealloc*/
3067 0, /*tp_print*/
3068 0, /*tp_getattr*/
3069 0, /*tp_setattr*/
3070 0, /*tp_as_async (tp_compare in Python 2)*/
3071 0, /*tp_repr*/
3072 &Beat_as_number, /*tp_as_number*/
3073 0, /*tp_as_sequence*/
3074 0, /*tp_as_mapping*/
3075 0, /*tp_hash */
3076 0, /*tp_call*/
3077 0, /*tp_str*/
3078 0, /*tp_getattro*/
3079 0, /*tp_setattro*/
3080 0, /*tp_as_buffer*/
3081 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
3082 "Beat objects. Reads a channel from a Beater.", /* tp_doc */
3083 (traverseproc)Beat_traverse, /* tp_traverse */
3084 (inquiry)Beat_clear, /* tp_clear */
3085 0, /* tp_richcompare */
3086 0, /* tp_weaklistoffset */
3087 0, /* tp_iter */
3088 0, /* tp_iternext */
3089 Beat_methods, /* tp_methods */
3090 Beat_members, /* tp_members */
3091 0, /* tp_getset */
3092 0, /* tp_base */
3093 0, /* tp_dict */
3094 0, /* tp_descr_get */
3095 0, /* tp_descr_set */
3096 0, /* tp_dictoffset */
3097 0, /* tp_init */
3098 0, /* tp_alloc */
3099 Beat_new, /* tp_new */
3100 };
3101
3102 /************************************************************************************************/
3103 /* BeatTapStream object per channel */
3104 /************************************************************************************************/
3105 typedef struct
3106 {
3107 pyo_audio_HEAD
3108 Beater *mainPlayer;
3109 int chnl;
3110 int modebuffer[2];
3111 } BeatTapStream;
3112
3113 static void BeatTapStream_postprocessing_ii(BeatTapStream *self) { POST_PROCESSING_II };
3114 static void BeatTapStream_postprocessing_ai(BeatTapStream *self) { POST_PROCESSING_AI };
3115 static void BeatTapStream_postprocessing_ia(BeatTapStream *self) { POST_PROCESSING_IA };
3116 static void BeatTapStream_postprocessing_aa(BeatTapStream *self) { POST_PROCESSING_AA };
3117 static void BeatTapStream_postprocessing_ireva(BeatTapStream *self) { POST_PROCESSING_IREVA };
3118 static void BeatTapStream_postprocessing_areva(BeatTapStream *self) { POST_PROCESSING_AREVA };
3119 static void BeatTapStream_postprocessing_revai(BeatTapStream *self) { POST_PROCESSING_REVAI };
3120 static void BeatTapStream_postprocessing_revaa(BeatTapStream *self) { POST_PROCESSING_REVAA };
3121 static void BeatTapStream_postprocessing_revareva(BeatTapStream *self) { POST_PROCESSING_REVAREVA };
3122
3123 static void
3124 BeatTapStream_setProcMode(BeatTapStream *self)
3125 {
3126 int muladdmode;
3127 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
3128
3129 switch (muladdmode)
3130 {
3131 case 0:
3132 self->muladd_func_ptr = BeatTapStream_postprocessing_ii;
3133 break;
3134
3135 case 1:
3136 self->muladd_func_ptr = BeatTapStream_postprocessing_ai;
3137 break;
3138
3139 case 2:
3140 self->muladd_func_ptr = BeatTapStream_postprocessing_revai;
3141 break;
3142
3143 case 10:
3144 self->muladd_func_ptr = BeatTapStream_postprocessing_ia;
3145 break;
3146
3147 case 11:
3148 self->muladd_func_ptr = BeatTapStream_postprocessing_aa;
3149 break;
3150
3151 case 12:
3152 self->muladd_func_ptr = BeatTapStream_postprocessing_revaa;
3153 break;
3154
3155 case 20:
3156 self->muladd_func_ptr = BeatTapStream_postprocessing_ireva;
3157 break;
3158
3159 case 21:
3160 self->muladd_func_ptr = BeatTapStream_postprocessing_areva;
3161 break;
3162
3163 case 22:
3164 self->muladd_func_ptr = BeatTapStream_postprocessing_revareva;
3165 break;
3166 }
3167 }
3168
3169 static void
3170 BeatTapStream_compute_next_data_frame(BeatTapStream *self)
3171 {
3172 int i;
3173 MYFLT *tmp;
3174 int offset = self->chnl * self->bufsize;
3175 tmp = Beater_getTapBuffer((Beater *)self->mainPlayer);
3176
3177 for (i = 0; i < self->bufsize; i++)
3178 {
3179 self->data[i] = tmp[i + offset];
3180 }
3181
3182 (*self->muladd_func_ptr)(self);
3183 }
3184
3185 static int
3186 BeatTapStream_traverse(BeatTapStream *self, visitproc visit, void *arg)
3187 {
3188 pyo_VISIT
3189 Py_VISIT(self->mainPlayer);
3190 return 0;
3191 }
3192
3193 static int
3194 BeatTapStream_clear(BeatTapStream *self)
3195 {
3196 pyo_CLEAR
3197 Py_CLEAR(self->mainPlayer);
3198 return 0;
3199 }
3200
3201 static void
3202 BeatTapStream_dealloc(BeatTapStream* self)
3203 {
3204 pyo_DEALLOC
3205 BeatTapStream_clear(self);
3206 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
3207 Py_TYPE(self)->tp_free((PyObject*)self);
3208 }
3209
3210 static PyObject *
3211 BeatTapStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
3212 {
3213 int i;
3214 PyObject *maintmp = NULL;
3215 BeatTapStream *self;
3216 self = (BeatTapStream *)type->tp_alloc(type, 0);
3217
3218 self->chnl = 0;
3219 self->modebuffer[0] = 0;
3220 self->modebuffer[1] = 0;
3221
3222 INIT_OBJECT_COMMON
3223 Stream_setFunctionPtr(self->stream, BeatTapStream_compute_next_data_frame);
3224 self->mode_func_ptr = BeatTapStream_setProcMode;
3225
3226 static char *kwlist[] = {"mainPlayer", "chnl", NULL};
3227
3228 if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
3229 Py_RETURN_NONE;
3230
3231 self->mainPlayer = (Beater *)maintmp;
3232 Py_INCREF(self->mainPlayer);
3233
3234 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
3235
3236 (*self->mode_func_ptr)(self);
3237
3238 return (PyObject *)self;
3239 }
3240
3241 static PyObject * BeatTapStream_getServer(BeatTapStream* self) { GET_SERVER };
3242 static PyObject * BeatTapStream_getStream(BeatTapStream* self) { GET_STREAM };
3243 static PyObject * BeatTapStream_setMul(BeatTapStream *self, PyObject *arg) { SET_MUL };
3244 static PyObject * BeatTapStream_setAdd(BeatTapStream *self, PyObject *arg) { SET_ADD };
3245 static PyObject * BeatTapStream_setSub(BeatTapStream *self, PyObject *arg) { SET_SUB };
3246 static PyObject * BeatTapStream_setDiv(BeatTapStream *self, PyObject *arg) { SET_DIV };
3247
3248 static PyObject * BeatTapStream_play(BeatTapStream *self, PyObject *args, PyObject *kwds) { PLAY };
3249 static PyObject * BeatTapStream_out(BeatTapStream *self, PyObject *args, PyObject *kwds) { OUT };
3250 static PyObject * BeatTapStream_stop(BeatTapStream *self, PyObject *args, PyObject *kwds) { STOP };
3251
3252 static PyObject * BeatTapStream_multiply(BeatTapStream *self, PyObject *arg) { MULTIPLY };
3253 static PyObject * BeatTapStream_inplace_multiply(BeatTapStream *self, PyObject *arg) { INPLACE_MULTIPLY };
3254 static PyObject * BeatTapStream_add(BeatTapStream *self, PyObject *arg) { ADD };
3255 static PyObject * BeatTapStream_inplace_add(BeatTapStream *self, PyObject *arg) { INPLACE_ADD };
3256 static PyObject * BeatTapStream_sub(BeatTapStream *self, PyObject *arg) { SUB };
3257 static PyObject * BeatTapStream_inplace_sub(BeatTapStream *self, PyObject *arg) { INPLACE_SUB };
3258 static PyObject * BeatTapStream_div(BeatTapStream *self, PyObject *arg) { DIV };
3259 static PyObject * BeatTapStream_inplace_div(BeatTapStream *self, PyObject *arg) { INPLACE_DIV };
3260
3261 static PyMemberDef BeatTapStream_members[] =
3262 {
3263 {"server", T_OBJECT_EX, offsetof(BeatTapStream, server), 0, "Pyo server."},
3264 {"stream", T_OBJECT_EX, offsetof(BeatTapStream, stream), 0, "Stream object."},
3265 {"mul", T_OBJECT_EX, offsetof(BeatTapStream, mul), 0, "Mul factor."},
3266 {"add", T_OBJECT_EX, offsetof(BeatTapStream, add), 0, "Add factor."},
3267 {NULL} /* Sentinel */
3268 };
3269
3270 static PyMethodDef BeatTapStream_methods[] =
3271 {
3272 {"getServer", (PyCFunction)BeatTapStream_getServer, METH_NOARGS, "Returns server object."},
3273 {"_getStream", (PyCFunction)BeatTapStream_getStream, METH_NOARGS, "Returns stream object."},
3274 {"play", (PyCFunction)BeatTapStream_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
3275 {"out", (PyCFunction)BeatTapStream_out, METH_VARARGS | METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
3276 {"stop", (PyCFunction)BeatTapStream_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
3277 {"setMul", (PyCFunction)BeatTapStream_setMul, METH_O, "Sets oscillator mul factor."},
3278 {"setAdd", (PyCFunction)BeatTapStream_setAdd, METH_O, "Sets oscillator add factor."},
3279 {"setSub", (PyCFunction)BeatTapStream_setSub, METH_O, "Sets inverse add factor."},
3280 {"setDiv", (PyCFunction)BeatTapStream_setDiv, METH_O, "Sets inverse mul factor."},
3281 {NULL} /* Sentinel */
3282 };
3283
3284 static PyNumberMethods BeatTapStream_as_number =
3285 {
3286 (binaryfunc)BeatTapStream_add, /*nb_add*/
3287 (binaryfunc)BeatTapStream_sub, /*nb_subtract*/
3288 (binaryfunc)BeatTapStream_multiply, /*nb_multiply*/
3289 0, /*nb_remainder*/
3290 0, /*nb_divmod*/
3291 0, /*nb_power*/
3292 0, /*nb_neg*/
3293 0, /*nb_pos*/
3294 0, /*(unaryfunc)array_abs,*/
3295 0, /*nb_nonzero*/
3296 0, /*nb_invert*/
3297 0, /*nb_lshift*/
3298 0, /*nb_rshift*/
3299 0, /*nb_and*/
3300 0, /*nb_xor*/
3301 0, /*nb_or*/
3302 0, /*nb_int*/
3303 0, /*nb_long*/
3304 0, /*nb_float*/
3305 (binaryfunc)BeatTapStream_inplace_add, /*inplace_add*/
3306 (binaryfunc)BeatTapStream_inplace_sub, /*inplace_subtract*/
3307 (binaryfunc)BeatTapStream_inplace_multiply, /*inplace_multiply*/
3308 0, /*inplace_remainder*/
3309 0, /*inplace_power*/
3310 0, /*inplace_lshift*/
3311 0, /*inplace_rshift*/
3312 0, /*inplace_and*/
3313 0, /*inplace_xor*/
3314 0, /*inplace_or*/
3315 0, /*nb_floor_divide*/
3316 (binaryfunc)BeatTapStream_div, /*nb_true_divide*/
3317 0, /*nb_inplace_floor_divide*/
3318 (binaryfunc)BeatTapStream_inplace_div, /*nb_inplace_true_divide*/
3319 0, /* nb_index */
3320 };
3321
3322 PyTypeObject BeatTapStreamType =
3323 {
3324 PyVarObject_HEAD_INIT(NULL, 0)
3325 "_pyo.BeatTapStream_base", /*tp_name*/
3326 sizeof(BeatTapStream), /*tp_basicsize*/
3327 0, /*tp_itemsize*/
3328 (destructor)BeatTapStream_dealloc, /*tp_dealloc*/
3329 0, /*tp_print*/
3330 0, /*tp_getattr*/
3331 0, /*tp_setattr*/
3332 0, /*tp_as_async (tp_compare in Python 2)*/
3333 0, /*tp_repr*/
3334 &BeatTapStream_as_number, /*tp_as_number*/
3335 0, /*tp_as_sequence*/
3336 0, /*tp_as_mapping*/
3337 0, /*tp_hash */
3338 0, /*tp_call*/
3339 0, /*tp_str*/
3340 0, /*tp_getattro*/
3341 0, /*tp_setattro*/
3342 0, /*tp_as_buffer*/
3343 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
3344 "BeatTapStream objects. Reads the current tap from a Beater object.", /* tp_doc */
3345 (traverseproc)BeatTapStream_traverse, /* tp_traverse */
3346 (inquiry)BeatTapStream_clear, /* tp_clear */
3347 0, /* tp_richcompare */
3348 0, /* tp_weaklistoffset */
3349 0, /* tp_iter */
3350 0, /* tp_iternext */
3351 BeatTapStream_methods, /* tp_methods */
3352 BeatTapStream_members, /* tp_members */
3353 0, /* tp_getset */
3354 0, /* tp_base */
3355 0, /* tp_dict */
3356 0, /* tp_descr_get */
3357 0, /* tp_descr_set */
3358 0, /* tp_dictoffset */
3359 0, /* tp_init */
3360 0, /* tp_alloc */
3361 BeatTapStream_new, /* tp_new */
3362 };
3363
3364 /************************************************************************************************/
3365 /* BeatAmpStream object per channel */
3366 /************************************************************************************************/
3367 typedef struct
3368 {
3369 pyo_audio_HEAD
3370 Beater *mainPlayer;
3371 int chnl;
3372 int modebuffer[2];
3373 } BeatAmpStream;
3374
3375 static void BeatAmpStream_postprocessing_ii(BeatAmpStream *self) { POST_PROCESSING_II };
3376 static void BeatAmpStream_postprocessing_ai(BeatAmpStream *self) { POST_PROCESSING_AI };
3377 static void BeatAmpStream_postprocessing_ia(BeatAmpStream *self) { POST_PROCESSING_IA };
3378 static void BeatAmpStream_postprocessing_aa(BeatAmpStream *self) { POST_PROCESSING_AA };
3379 static void BeatAmpStream_postprocessing_ireva(BeatAmpStream *self) { POST_PROCESSING_IREVA };
3380 static void BeatAmpStream_postprocessing_areva(BeatAmpStream *self) { POST_PROCESSING_AREVA };
3381 static void BeatAmpStream_postprocessing_revai(BeatAmpStream *self) { POST_PROCESSING_REVAI };
3382 static void BeatAmpStream_postprocessing_revaa(BeatAmpStream *self) { POST_PROCESSING_REVAA };
3383 static void BeatAmpStream_postprocessing_revareva(BeatAmpStream *self) { POST_PROCESSING_REVAREVA };
3384
3385 static void
3386 BeatAmpStream_setProcMode(BeatAmpStream *self)
3387 {
3388 int muladdmode;
3389 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
3390
3391 switch (muladdmode)
3392 {
3393 case 0:
3394 self->muladd_func_ptr = BeatAmpStream_postprocessing_ii;
3395 break;
3396
3397 case 1:
3398 self->muladd_func_ptr = BeatAmpStream_postprocessing_ai;
3399 break;
3400
3401 case 2:
3402 self->muladd_func_ptr = BeatAmpStream_postprocessing_revai;
3403 break;
3404
3405 case 10:
3406 self->muladd_func_ptr = BeatAmpStream_postprocessing_ia;
3407 break;
3408
3409 case 11:
3410 self->muladd_func_ptr = BeatAmpStream_postprocessing_aa;
3411 break;
3412
3413 case 12:
3414 self->muladd_func_ptr = BeatAmpStream_postprocessing_revaa;
3415 break;
3416
3417 case 20:
3418 self->muladd_func_ptr = BeatAmpStream_postprocessing_ireva;
3419 break;
3420
3421 case 21:
3422 self->muladd_func_ptr = BeatAmpStream_postprocessing_areva;
3423 break;
3424
3425 case 22:
3426 self->muladd_func_ptr = BeatAmpStream_postprocessing_revareva;
3427 break;
3428 }
3429 }
3430
3431 static void
3432 BeatAmpStream_compute_next_data_frame(BeatAmpStream *self)
3433 {
3434 int i;
3435 MYFLT *tmp;
3436 int offset = self->chnl * self->bufsize;
3437 tmp = Beater_getAmpBuffer((Beater *)self->mainPlayer);
3438
3439 for (i = 0; i < self->bufsize; i++)
3440 {
3441 self->data[i] = tmp[i + offset];
3442 }
3443
3444 (*self->muladd_func_ptr)(self);
3445 }
3446
3447 static int
3448 BeatAmpStream_traverse(BeatAmpStream *self, visitproc visit, void *arg)
3449 {
3450 pyo_VISIT
3451 Py_VISIT(self->mainPlayer);
3452 return 0;
3453 }
3454
3455 static int
3456 BeatAmpStream_clear(BeatAmpStream *self)
3457 {
3458 pyo_CLEAR
3459 Py_CLEAR(self->mainPlayer);
3460 return 0;
3461 }
3462
3463 static void
3464 BeatAmpStream_dealloc(BeatAmpStream* self)
3465 {
3466 pyo_DEALLOC
3467 BeatAmpStream_clear(self);
3468 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
3469 Py_TYPE(self)->tp_free((PyObject*)self);
3470 }
3471
3472 static PyObject *
3473 BeatAmpStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
3474 {
3475 int i;
3476 PyObject *maintmp = NULL;
3477 BeatAmpStream *self;
3478 self = (BeatAmpStream *)type->tp_alloc(type, 0);
3479
3480 self->chnl = 0;
3481 self->modebuffer[0] = 0;
3482 self->modebuffer[1] = 0;
3483
3484 INIT_OBJECT_COMMON
3485 Stream_setFunctionPtr(self->stream, BeatAmpStream_compute_next_data_frame);
3486 self->mode_func_ptr = BeatAmpStream_setProcMode;
3487
3488 static char *kwlist[] = {"mainPlayer", "chnl", NULL};
3489
3490 if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
3491 Py_RETURN_NONE;
3492
3493 self->mainPlayer = (Beater *)maintmp;
3494 Py_INCREF(self->mainPlayer);
3495
3496 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
3497
3498 (*self->mode_func_ptr)(self);
3499
3500 return (PyObject *)self;
3501 }
3502
3503 static PyObject * BeatAmpStream_getServer(BeatAmpStream* self) { GET_SERVER };
3504 static PyObject * BeatAmpStream_getStream(BeatAmpStream* self) { GET_STREAM };
3505 static PyObject * BeatAmpStream_setMul(BeatAmpStream *self, PyObject *arg) { SET_MUL };
3506 static PyObject * BeatAmpStream_setAdd(BeatAmpStream *self, PyObject *arg) { SET_ADD };
3507 static PyObject * BeatAmpStream_setSub(BeatAmpStream *self, PyObject *arg) { SET_SUB };
3508 static PyObject * BeatAmpStream_setDiv(BeatAmpStream *self, PyObject *arg) { SET_DIV };
3509
3510 static PyObject * BeatAmpStream_play(BeatAmpStream *self, PyObject *args, PyObject *kwds) { PLAY };
3511 static PyObject * BeatAmpStream_out(BeatAmpStream *self, PyObject *args, PyObject *kwds) { OUT };
3512 static PyObject * BeatAmpStream_stop(BeatAmpStream *self, PyObject *args, PyObject *kwds) { STOP };
3513
3514 static PyObject * BeatAmpStream_multiply(BeatAmpStream *self, PyObject *arg) { MULTIPLY };
3515 static PyObject * BeatAmpStream_inplace_multiply(BeatAmpStream *self, PyObject *arg) { INPLACE_MULTIPLY };
3516 static PyObject * BeatAmpStream_add(BeatAmpStream *self, PyObject *arg) { ADD };
3517 static PyObject * BeatAmpStream_inplace_add(BeatAmpStream *self, PyObject *arg) { INPLACE_ADD };
3518 static PyObject * BeatAmpStream_sub(BeatAmpStream *self, PyObject *arg) { SUB };
3519 static PyObject * BeatAmpStream_inplace_sub(BeatAmpStream *self, PyObject *arg) { INPLACE_SUB };
3520 static PyObject * BeatAmpStream_div(BeatAmpStream *self, PyObject *arg) { DIV };
3521 static PyObject * BeatAmpStream_inplace_div(BeatAmpStream *self, PyObject *arg) { INPLACE_DIV };
3522
3523 static PyMemberDef BeatAmpStream_members[] =
3524 {
3525 {"server", T_OBJECT_EX, offsetof(BeatAmpStream, server), 0, "Pyo server."},
3526 {"stream", T_OBJECT_EX, offsetof(BeatAmpStream, stream), 0, "Stream object."},
3527 {"mul", T_OBJECT_EX, offsetof(BeatAmpStream, mul), 0, "Mul factor."},
3528 {"add", T_OBJECT_EX, offsetof(BeatAmpStream, add), 0, "Add factor."},
3529 {NULL} /* Sentinel */
3530 };
3531
3532 static PyMethodDef BeatAmpStream_methods[] =
3533 {
3534 {"getServer", (PyCFunction)BeatAmpStream_getServer, METH_NOARGS, "Returns server object."},
3535 {"_getStream", (PyCFunction)BeatAmpStream_getStream, METH_NOARGS, "Returns stream object."},
3536 {"play", (PyCFunction)BeatAmpStream_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
3537 {"out", (PyCFunction)BeatAmpStream_out, METH_VARARGS | METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
3538 {"stop", (PyCFunction)BeatAmpStream_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
3539 {"setMul", (PyCFunction)BeatAmpStream_setMul, METH_O, "Sets oscillator mul factor."},
3540 {"setAdd", (PyCFunction)BeatAmpStream_setAdd, METH_O, "Sets oscillator add factor."},
3541 {"setSub", (PyCFunction)BeatAmpStream_setSub, METH_O, "Sets inverse add factor."},
3542 {"setDiv", (PyCFunction)BeatAmpStream_setDiv, METH_O, "Sets inverse mul factor."},
3543 {NULL} /* Sentinel */
3544 };
3545
3546 static PyNumberMethods BeatAmpStream_as_number =
3547 {
3548 (binaryfunc)BeatAmpStream_add, /*nb_add*/
3549 (binaryfunc)BeatAmpStream_sub, /*nb_subtract*/
3550 (binaryfunc)BeatAmpStream_multiply, /*nb_multiply*/
3551 0, /*nb_remainder*/
3552 0, /*nb_divmod*/
3553 0, /*nb_power*/
3554 0, /*nb_neg*/
3555 0, /*nb_pos*/
3556 0, /*(unaryfunc)array_abs,*/
3557 0, /*nb_nonzero*/
3558 0, /*nb_invert*/
3559 0, /*nb_lshift*/
3560 0, /*nb_rshift*/
3561 0, /*nb_and*/
3562 0, /*nb_xor*/
3563 0, /*nb_or*/
3564 0, /*nb_int*/
3565 0, /*nb_long*/
3566 0, /*nb_float*/
3567 (binaryfunc)BeatAmpStream_inplace_add, /*inplace_add*/
3568 (binaryfunc)BeatAmpStream_inplace_sub, /*inplace_subtract*/
3569 (binaryfunc)BeatAmpStream_inplace_multiply, /*inplace_multiply*/
3570 0, /*inplace_remainder*/
3571 0, /*inplace_power*/
3572 0, /*inplace_lshift*/
3573 0, /*inplace_rshift*/
3574 0, /*inplace_and*/
3575 0, /*inplace_xor*/
3576 0, /*inplace_or*/
3577 0, /*nb_floor_divide*/
3578 (binaryfunc)BeatAmpStream_div, /*nb_true_divide*/
3579 0, /*nb_inplace_floor_divide*/
3580 (binaryfunc)BeatAmpStream_inplace_div, /*nb_inplace_true_divide*/
3581 0, /* nb_index */
3582 };
3583
3584 PyTypeObject BeatAmpStreamType =
3585 {
3586 PyVarObject_HEAD_INIT(NULL, 0)
3587 "_pyo.BeatAmpStream_base", /*tp_name*/
3588 sizeof(BeatAmpStream), /*tp_basicsize*/
3589 0, /*tp_itemsize*/
3590 (destructor)BeatAmpStream_dealloc, /*tp_dealloc*/
3591 0, /*tp_print*/
3592 0, /*tp_getattr*/
3593 0, /*tp_setattr*/
3594 0, /*tp_as_async (tp_compare in Python 2)*/
3595 0, /*tp_repr*/
3596 &BeatAmpStream_as_number, /*tp_as_number*/
3597 0, /*tp_as_sequence*/
3598 0, /*tp_as_mapping*/
3599 0, /*tp_hash */
3600 0, /*tp_call*/
3601 0, /*tp_str*/
3602 0, /*tp_getattro*/
3603 0, /*tp_setattro*/
3604 0, /*tp_as_buffer*/
3605 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
3606 "BeatAmpStream objects. Reads a amplitude channel from a Beater object.", /* tp_doc */
3607 (traverseproc)BeatAmpStream_traverse, /* tp_traverse */
3608 (inquiry)BeatAmpStream_clear, /* tp_clear */
3609 0, /* tp_richcompare */
3610 0, /* tp_weaklistoffset */
3611 0, /* tp_iter */
3612 0, /* tp_iternext */
3613 BeatAmpStream_methods, /* tp_methods */
3614 BeatAmpStream_members, /* tp_members */
3615 0, /* tp_getset */
3616 0, /* tp_base */
3617 0, /* tp_dict */
3618 0, /* tp_descr_get */
3619 0, /* tp_descr_set */
3620 0, /* tp_dictoffset */
3621 0, /* tp_init */
3622 0, /* tp_alloc */
3623 BeatAmpStream_new, /* tp_new */
3624 };
3625
3626 /************************************************************************************************/
3627 /* BeatDurStream object per channel */
3628 /************************************************************************************************/
3629 typedef struct
3630 {
3631 pyo_audio_HEAD
3632 Beater *mainPlayer;
3633 int chnl;
3634 int modebuffer[2];
3635 } BeatDurStream;
3636
3637 static void BeatDurStream_postprocessing_ii(BeatDurStream *self) { POST_PROCESSING_II };
3638 static void BeatDurStream_postprocessing_ai(BeatDurStream *self) { POST_PROCESSING_AI };
3639 static void BeatDurStream_postprocessing_ia(BeatDurStream *self) { POST_PROCESSING_IA };
3640 static void BeatDurStream_postprocessing_aa(BeatDurStream *self) { POST_PROCESSING_AA };
3641 static void BeatDurStream_postprocessing_ireva(BeatDurStream *self) { POST_PROCESSING_IREVA };
3642 static void BeatDurStream_postprocessing_areva(BeatDurStream *self) { POST_PROCESSING_AREVA };
3643 static void BeatDurStream_postprocessing_revai(BeatDurStream *self) { POST_PROCESSING_REVAI };
3644 static void BeatDurStream_postprocessing_revaa(BeatDurStream *self) { POST_PROCESSING_REVAA };
3645 static void BeatDurStream_postprocessing_revareva(BeatDurStream *self) { POST_PROCESSING_REVAREVA };
3646
3647 static void
3648 BeatDurStream_setProcMode(BeatDurStream *self)
3649 {
3650 int muladdmode;
3651 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
3652
3653 switch (muladdmode)
3654 {
3655 case 0:
3656 self->muladd_func_ptr = BeatDurStream_postprocessing_ii;
3657 break;
3658
3659 case 1:
3660 self->muladd_func_ptr = BeatDurStream_postprocessing_ai;
3661 break;
3662
3663 case 2:
3664 self->muladd_func_ptr = BeatDurStream_postprocessing_revai;
3665 break;
3666
3667 case 10:
3668 self->muladd_func_ptr = BeatDurStream_postprocessing_ia;
3669 break;
3670
3671 case 11:
3672 self->muladd_func_ptr = BeatDurStream_postprocessing_aa;
3673 break;
3674
3675 case 12:
3676 self->muladd_func_ptr = BeatDurStream_postprocessing_revaa;
3677 break;
3678
3679 case 20:
3680 self->muladd_func_ptr = BeatDurStream_postprocessing_ireva;
3681 break;
3682
3683 case 21:
3684 self->muladd_func_ptr = BeatDurStream_postprocessing_areva;
3685 break;
3686
3687 case 22:
3688 self->muladd_func_ptr = BeatDurStream_postprocessing_revareva;
3689 break;
3690 }
3691 }
3692
3693 static void
3694 BeatDurStream_compute_next_data_frame(BeatDurStream *self)
3695 {
3696 int i;
3697 MYFLT *tmp;
3698 int offset = self->chnl * self->bufsize;
3699 tmp = Beater_getDurBuffer((Beater *)self->mainPlayer);
3700
3701 for (i = 0; i < self->bufsize; i++)
3702 {
3703 self->data[i] = tmp[i + offset];
3704 }
3705
3706 (*self->muladd_func_ptr)(self);
3707 }
3708
3709 static int
3710 BeatDurStream_traverse(BeatDurStream *self, visitproc visit, void *arg)
3711 {
3712 pyo_VISIT
3713 Py_VISIT(self->mainPlayer);
3714 return 0;
3715 }
3716
3717 static int
3718 BeatDurStream_clear(BeatDurStream *self)
3719 {
3720 pyo_CLEAR
3721 Py_CLEAR(self->mainPlayer);
3722 return 0;
3723 }
3724
3725 static void
3726 BeatDurStream_dealloc(BeatDurStream* self)
3727 {
3728 pyo_DEALLOC
3729 BeatDurStream_clear(self);
3730 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
3731 Py_TYPE(self)->tp_free((PyObject*)self);
3732 }
3733
3734 static PyObject *
3735 BeatDurStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
3736 {
3737 int i;
3738 PyObject *maintmp = NULL;
3739 BeatDurStream *self;
3740 self = (BeatDurStream *)type->tp_alloc(type, 0);
3741
3742 self->chnl = 0;
3743 self->modebuffer[0] = 0;
3744 self->modebuffer[1] = 0;
3745
3746 INIT_OBJECT_COMMON
3747 Stream_setFunctionPtr(self->stream, BeatDurStream_compute_next_data_frame);
3748 self->mode_func_ptr = BeatDurStream_setProcMode;
3749
3750 static char *kwlist[] = {"mainPlayer", "chnl", NULL};
3751
3752 if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
3753 Py_RETURN_NONE;
3754
3755 self->mainPlayer = (Beater *)maintmp;
3756 Py_INCREF(self->mainPlayer);
3757
3758 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
3759
3760 (*self->mode_func_ptr)(self);
3761
3762 return (PyObject *)self;
3763 }
3764
3765 static PyObject * BeatDurStream_getServer(BeatDurStream* self) { GET_SERVER };
3766 static PyObject * BeatDurStream_getStream(BeatDurStream* self) { GET_STREAM };
3767 static PyObject * BeatDurStream_setMul(BeatDurStream *self, PyObject *arg) { SET_MUL };
3768 static PyObject * BeatDurStream_setAdd(BeatDurStream *self, PyObject *arg) { SET_ADD };
3769 static PyObject * BeatDurStream_setSub(BeatDurStream *self, PyObject *arg) { SET_SUB };
3770 static PyObject * BeatDurStream_setDiv(BeatDurStream *self, PyObject *arg) { SET_DIV };
3771
3772 static PyObject * BeatDurStream_play(BeatDurStream *self, PyObject *args, PyObject *kwds) { PLAY };
3773 static PyObject * BeatDurStream_out(BeatDurStream *self, PyObject *args, PyObject *kwds) { OUT };
3774 static PyObject * BeatDurStream_stop(BeatDurStream *self, PyObject *args, PyObject *kwds) { STOP };
3775
3776 static PyObject * BeatDurStream_multiply(BeatDurStream *self, PyObject *arg) { MULTIPLY };
3777 static PyObject * BeatDurStream_inplace_multiply(BeatDurStream *self, PyObject *arg) { INPLACE_MULTIPLY };
3778 static PyObject * BeatDurStream_add(BeatDurStream *self, PyObject *arg) { ADD };
3779 static PyObject * BeatDurStream_inplace_add(BeatDurStream *self, PyObject *arg) { INPLACE_ADD };
3780 static PyObject * BeatDurStream_sub(BeatDurStream *self, PyObject *arg) { SUB };
3781 static PyObject * BeatDurStream_inplace_sub(BeatDurStream *self, PyObject *arg) { INPLACE_SUB };
3782 static PyObject * BeatDurStream_div(BeatDurStream *self, PyObject *arg) { DIV };
3783 static PyObject * BeatDurStream_inplace_div(BeatDurStream *self, PyObject *arg) { INPLACE_DIV };
3784
3785 static PyMemberDef BeatDurStream_members[] =
3786 {
3787 {"server", T_OBJECT_EX, offsetof(BeatDurStream, server), 0, "Pyo server."},
3788 {"stream", T_OBJECT_EX, offsetof(BeatDurStream, stream), 0, "Stream object."},
3789 {"mul", T_OBJECT_EX, offsetof(BeatDurStream, mul), 0, "Mul factor."},
3790 {"add", T_OBJECT_EX, offsetof(BeatDurStream, add), 0, "Add factor."},
3791 {NULL} /* Sentinel */
3792 };
3793
3794 static PyMethodDef BeatDurStream_methods[] =
3795 {
3796 {"getServer", (PyCFunction)BeatDurStream_getServer, METH_NOARGS, "Returns server object."},
3797 {"_getStream", (PyCFunction)BeatDurStream_getStream, METH_NOARGS, "Returns stream object."},
3798 {"play", (PyCFunction)BeatDurStream_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
3799 {"out", (PyCFunction)BeatDurStream_out, METH_VARARGS | METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
3800 {"stop", (PyCFunction)BeatDurStream_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
3801 {"setMul", (PyCFunction)BeatDurStream_setMul, METH_O, "Sets oscillator mul factor."},
3802 {"setAdd", (PyCFunction)BeatDurStream_setAdd, METH_O, "Sets oscillator add factor."},
3803 {"setSub", (PyCFunction)BeatDurStream_setSub, METH_O, "Sets inverse add factor."},
3804 {"setDiv", (PyCFunction)BeatDurStream_setDiv, METH_O, "Sets inverse mul factor."},
3805 {NULL} /* Sentinel */
3806 };
3807
3808 static PyNumberMethods BeatDurStream_as_number =
3809 {
3810 (binaryfunc)BeatDurStream_add, /*nb_add*/
3811 (binaryfunc)BeatDurStream_sub, /*nb_subtract*/
3812 (binaryfunc)BeatDurStream_multiply, /*nb_multiply*/
3813 0, /*nb_remainder*/
3814 0, /*nb_divmod*/
3815 0, /*nb_power*/
3816 0, /*nb_neg*/
3817 0, /*nb_pos*/
3818 0, /*(unaryfunc)array_abs,*/
3819 0, /*nb_nonzero*/
3820 0, /*nb_invert*/
3821 0, /*nb_lshift*/
3822 0, /*nb_rshift*/
3823 0, /*nb_and*/
3824 0, /*nb_xor*/
3825 0, /*nb_or*/
3826 0, /*nb_int*/
3827 0, /*nb_long*/
3828 0, /*nb_float*/
3829 (binaryfunc)BeatDurStream_inplace_add, /*inplace_add*/
3830 (binaryfunc)BeatDurStream_inplace_sub, /*inplace_subtract*/
3831 (binaryfunc)BeatDurStream_inplace_multiply, /*inplace_multiply*/
3832 0, /*inplace_remainder*/
3833 0, /*inplace_power*/
3834 0, /*inplace_lshift*/
3835 0, /*inplace_rshift*/
3836 0, /*inplace_and*/
3837 0, /*inplace_xor*/
3838 0, /*inplace_or*/
3839 0, /*nb_floor_divide*/
3840 (binaryfunc)BeatDurStream_div, /*nb_true_divide*/
3841 0, /*nb_inplace_floor_divide*/
3842 (binaryfunc)BeatDurStream_inplace_div, /*nb_inplace_true_divide*/
3843 0, /* nb_index */
3844 };
3845
3846 PyTypeObject BeatDurStreamType =
3847 {
3848 PyVarObject_HEAD_INIT(NULL, 0)
3849 "_pyo.BeatDurStream_base", /*tp_name*/
3850 sizeof(BeatDurStream), /*tp_basicsize*/
3851 0, /*tp_itemsize*/
3852 (destructor)BeatDurStream_dealloc, /*tp_dealloc*/
3853 0, /*tp_print*/
3854 0, /*tp_getattr*/
3855 0, /*tp_setattr*/
3856 0, /*tp_as_async (tp_compare in Python 2)*/
3857 0, /*tp_repr*/
3858 &BeatDurStream_as_number, /*tp_as_number*/
3859 0, /*tp_as_sequence*/
3860 0, /*tp_as_mapping*/
3861 0, /*tp_hash */
3862 0, /*tp_call*/
3863 0, /*tp_str*/
3864 0, /*tp_getattro*/
3865 0, /*tp_setattro*/
3866 0, /*tp_as_buffer*/
3867 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
3868 "BeatDurStream objects. Reads a duration channel from a Beater object.", /* tp_doc */
3869 (traverseproc)BeatDurStream_traverse, /* tp_traverse */
3870 (inquiry)BeatDurStream_clear, /* tp_clear */
3871 0, /* tp_richcompare */
3872 0, /* tp_weaklistoffset */
3873 0, /* tp_iter */
3874 0, /* tp_iternext */
3875 BeatDurStream_methods, /* tp_methods */
3876 BeatDurStream_members, /* tp_members */
3877 0, /* tp_getset */
3878 0, /* tp_base */
3879 0, /* tp_dict */
3880 0, /* tp_descr_get */
3881 0, /* tp_descr_set */
3882 0, /* tp_dictoffset */
3883 0, /* tp_init */
3884 0, /* tp_alloc */
3885 BeatDurStream_new, /* tp_new */
3886 };
3887
3888 /************************************************************************************************/
3889 /* BeatEndStream object per channel */
3890 /************************************************************************************************/
3891 typedef struct
3892 {
3893 pyo_audio_HEAD
3894 Beater *mainPlayer;
3895 int chnl;
3896 int modebuffer[2];
3897 } BeatEndStream;
3898
3899 static void BeatEndStream_postprocessing_ii(BeatEndStream *self) { POST_PROCESSING_II };
3900 static void BeatEndStream_postprocessing_ai(BeatEndStream *self) { POST_PROCESSING_AI };
3901 static void BeatEndStream_postprocessing_ia(BeatEndStream *self) { POST_PROCESSING_IA };
3902 static void BeatEndStream_postprocessing_aa(BeatEndStream *self) { POST_PROCESSING_AA };
3903 static void BeatEndStream_postprocessing_ireva(BeatEndStream *self) { POST_PROCESSING_IREVA };
3904 static void BeatEndStream_postprocessing_areva(BeatEndStream *self) { POST_PROCESSING_AREVA };
3905 static void BeatEndStream_postprocessing_revai(BeatEndStream *self) { POST_PROCESSING_REVAI };
3906 static void BeatEndStream_postprocessing_revaa(BeatEndStream *self) { POST_PROCESSING_REVAA };
3907 static void BeatEndStream_postprocessing_revareva(BeatEndStream *self) { POST_PROCESSING_REVAREVA };
3908
3909 static void
3910 BeatEndStream_setProcMode(BeatEndStream *self)
3911 {
3912 int muladdmode;
3913 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
3914
3915 switch (muladdmode)
3916 {
3917 case 0:
3918 self->muladd_func_ptr = BeatEndStream_postprocessing_ii;
3919 break;
3920
3921 case 1:
3922 self->muladd_func_ptr = BeatEndStream_postprocessing_ai;
3923 break;
3924
3925 case 2:
3926 self->muladd_func_ptr = BeatEndStream_postprocessing_revai;
3927 break;
3928
3929 case 10:
3930 self->muladd_func_ptr = BeatEndStream_postprocessing_ia;
3931 break;
3932
3933 case 11:
3934 self->muladd_func_ptr = BeatEndStream_postprocessing_aa;
3935 break;
3936
3937 case 12:
3938 self->muladd_func_ptr = BeatEndStream_postprocessing_revaa;
3939 break;
3940
3941 case 20:
3942 self->muladd_func_ptr = BeatEndStream_postprocessing_ireva;
3943 break;
3944
3945 case 21:
3946 self->muladd_func_ptr = BeatEndStream_postprocessing_areva;
3947 break;
3948
3949 case 22:
3950 self->muladd_func_ptr = BeatEndStream_postprocessing_revareva;
3951 break;
3952 }
3953 }
3954
3955 static void
3956 BeatEndStream_compute_next_data_frame(BeatEndStream *self)
3957 {
3958 int i;
3959 MYFLT *tmp;
3960 int offset = self->chnl * self->bufsize;
3961 tmp = Beater_getEndBuffer((Beater *)self->mainPlayer);
3962
3963 for (i = 0; i < self->bufsize; i++)
3964 {
3965 self->data[i] = tmp[i + offset];
3966 }
3967
3968 (*self->muladd_func_ptr)(self);
3969 }
3970
3971 static int
3972 BeatEndStream_traverse(BeatEndStream *self, visitproc visit, void *arg)
3973 {
3974 pyo_VISIT
3975 Py_VISIT(self->mainPlayer);
3976 return 0;
3977 }
3978
3979 static int
3980 BeatEndStream_clear(BeatEndStream *self)
3981 {
3982 pyo_CLEAR
3983 Py_CLEAR(self->mainPlayer);
3984 return 0;
3985 }
3986
3987 static void
3988 BeatEndStream_dealloc(BeatEndStream* self)
3989 {
3990 pyo_DEALLOC
3991 BeatEndStream_clear(self);
3992 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
3993 Py_TYPE(self)->tp_free((PyObject*)self);
3994 }
3995
3996 static PyObject *
3997 BeatEndStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
3998 {
3999 int i;
4000 PyObject *maintmp = NULL;
4001 BeatEndStream *self;
4002 self = (BeatEndStream *)type->tp_alloc(type, 0);
4003
4004 self->chnl = 0;
4005 self->modebuffer[0] = 0;
4006 self->modebuffer[1] = 0;
4007
4008 INIT_OBJECT_COMMON
4009 Stream_setFunctionPtr(self->stream, BeatEndStream_compute_next_data_frame);
4010 self->mode_func_ptr = BeatEndStream_setProcMode;
4011
4012 static char *kwlist[] = {"mainPlayer", "chnl", NULL};
4013
4014 if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
4015 Py_RETURN_NONE;
4016
4017 self->mainPlayer = (Beater *)maintmp;
4018 Py_INCREF(self->mainPlayer);
4019
4020 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
4021
4022 (*self->mode_func_ptr)(self);
4023
4024 return (PyObject *)self;
4025 }
4026
4027 static PyObject * BeatEndStream_getServer(BeatEndStream* self) { GET_SERVER };
4028 static PyObject * BeatEndStream_getStream(BeatEndStream* self) { GET_STREAM };
4029 static PyObject * BeatEndStream_setMul(BeatEndStream *self, PyObject *arg) { SET_MUL };
4030 static PyObject * BeatEndStream_setAdd(BeatEndStream *self, PyObject *arg) { SET_ADD };
4031 static PyObject * BeatEndStream_setSub(BeatEndStream *self, PyObject *arg) { SET_SUB };
4032 static PyObject * BeatEndStream_setDiv(BeatEndStream *self, PyObject *arg) { SET_DIV };
4033
4034 static PyObject * BeatEndStream_play(BeatEndStream *self, PyObject *args, PyObject *kwds) { PLAY };
4035 static PyObject * BeatEndStream_out(BeatEndStream *self, PyObject *args, PyObject *kwds) { OUT };
4036 static PyObject * BeatEndStream_stop(BeatEndStream *self, PyObject *args, PyObject *kwds) { STOP };
4037
4038 static PyObject * BeatEndStream_multiply(BeatEndStream *self, PyObject *arg) { MULTIPLY };
4039 static PyObject * BeatEndStream_inplace_multiply(BeatEndStream *self, PyObject *arg) { INPLACE_MULTIPLY };
4040 static PyObject * BeatEndStream_add(BeatEndStream *self, PyObject *arg) { ADD };
4041 static PyObject * BeatEndStream_inplace_add(BeatEndStream *self, PyObject *arg) { INPLACE_ADD };
4042 static PyObject * BeatEndStream_sub(BeatEndStream *self, PyObject *arg) { SUB };
4043 static PyObject * BeatEndStream_inplace_sub(BeatEndStream *self, PyObject *arg) { INPLACE_SUB };
4044 static PyObject * BeatEndStream_div(BeatEndStream *self, PyObject *arg) { DIV };
4045 static PyObject * BeatEndStream_inplace_div(BeatEndStream *self, PyObject *arg) { INPLACE_DIV };
4046
4047 static PyMemberDef BeatEndStream_members[] =
4048 {
4049 {"server", T_OBJECT_EX, offsetof(BeatEndStream, server), 0, "Pyo server."},
4050 {"stream", T_OBJECT_EX, offsetof(BeatEndStream, stream), 0, "Stream object."},
4051 {"mul", T_OBJECT_EX, offsetof(BeatEndStream, mul), 0, "Mul factor."},
4052 {"add", T_OBJECT_EX, offsetof(BeatEndStream, add), 0, "Add factor."},
4053 {NULL} /* Sentinel */
4054 };
4055
4056 static PyMethodDef BeatEndStream_methods[] =
4057 {
4058 {"getServer", (PyCFunction)BeatEndStream_getServer, METH_NOARGS, "Returns server object."},
4059 {"_getStream", (PyCFunction)BeatEndStream_getStream, METH_NOARGS, "Returns stream object."},
4060 {"play", (PyCFunction)BeatEndStream_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
4061 {"out", (PyCFunction)BeatEndStream_out, METH_VARARGS | METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
4062 {"stop", (PyCFunction)BeatEndStream_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
4063 {"setMul", (PyCFunction)BeatEndStream_setMul, METH_O, "Sets oscillator mul factor."},
4064 {"setAdd", (PyCFunction)BeatEndStream_setAdd, METH_O, "Sets oscillator add factor."},
4065 {"setSub", (PyCFunction)BeatEndStream_setSub, METH_O, "Sets inverse add factor."},
4066 {"setDiv", (PyCFunction)BeatEndStream_setDiv, METH_O, "Sets inverse mul factor."},
4067 {NULL} /* Sentinel */
4068 };
4069
4070 static PyNumberMethods BeatEndStream_as_number =
4071 {
4072 (binaryfunc)BeatEndStream_add, /*nb_add*/
4073 (binaryfunc)BeatEndStream_sub, /*nb_subtract*/
4074 (binaryfunc)BeatEndStream_multiply, /*nb_multiply*/
4075 0, /*nb_remainder*/
4076 0, /*nb_divmod*/
4077 0, /*nb_power*/
4078 0, /*nb_neg*/
4079 0, /*nb_pos*/
4080 0, /*(unaryfunc)array_abs,*/
4081 0, /*nb_nonzero*/
4082 0, /*nb_invert*/
4083 0, /*nb_lshift*/
4084 0, /*nb_rshift*/
4085 0, /*nb_and*/
4086 0, /*nb_xor*/
4087 0, /*nb_or*/
4088 0, /*nb_int*/
4089 0, /*nb_long*/
4090 0, /*nb_float*/
4091 (binaryfunc)BeatEndStream_inplace_add, /*inplace_add*/
4092 (binaryfunc)BeatEndStream_inplace_sub, /*inplace_subtract*/
4093 (binaryfunc)BeatEndStream_inplace_multiply, /*inplace_multiply*/
4094 0, /*inplace_remainder*/
4095 0, /*inplace_power*/
4096 0, /*inplace_lshift*/
4097 0, /*inplace_rshift*/
4098 0, /*inplace_and*/
4099 0, /*inplace_xor*/
4100 0, /*inplace_or*/
4101 0, /*nb_floor_divide*/
4102 (binaryfunc)BeatEndStream_div, /*nb_true_divide*/
4103 0, /*nb_inplace_floor_divide*/
4104 (binaryfunc)BeatEndStream_inplace_div, /*nb_inplace_true_divide*/
4105 0, /* nb_index */
4106 };
4107
4108 PyTypeObject BeatEndStreamType =
4109 {
4110 PyVarObject_HEAD_INIT(NULL, 0)
4111 "_pyo.BeatEndStream_base", /*tp_name*/
4112 sizeof(BeatEndStream), /*tp_basicsize*/
4113 0, /*tp_itemsize*/
4114 (destructor)BeatEndStream_dealloc, /*tp_dealloc*/
4115 0, /*tp_print*/
4116 0, /*tp_getattr*/
4117 0, /*tp_setattr*/
4118 0, /*tp_as_async (tp_compare in Python 2)*/
4119 0, /*tp_repr*/
4120 &BeatEndStream_as_number, /*tp_as_number*/
4121 0, /*tp_as_sequence*/
4122 0, /*tp_as_mapping*/
4123 0, /*tp_hash */
4124 0, /*tp_call*/
4125 0, /*tp_str*/
4126 0, /*tp_getattro*/
4127 0, /*tp_setattro*/
4128 0, /*tp_as_buffer*/
4129 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
4130 "BeatEndStream objects. Reads a duration channel from a Beater object.", /* tp_doc */
4131 (traverseproc)BeatEndStream_traverse, /* tp_traverse */
4132 (inquiry)BeatEndStream_clear, /* tp_clear */
4133 0, /* tp_richcompare */
4134 0, /* tp_weaklistoffset */
4135 0, /* tp_iter */
4136 0, /* tp_iternext */
4137 BeatEndStream_methods, /* tp_methods */
4138 BeatEndStream_members, /* tp_members */
4139 0, /* tp_getset */
4140 0, /* tp_base */
4141 0, /* tp_dict */
4142 0, /* tp_descr_get */
4143 0, /* tp_descr_set */
4144 0, /* tp_dictoffset */
4145 0, /* tp_init */
4146 0, /* tp_alloc */
4147 BeatEndStream_new, /* tp_new */
4148 };
4149
4150 /****************/
4151 /**** TrigBurster *****/
4152 /****************/
4153 typedef struct
4154 {
4155 pyo_audio_HEAD
4156 PyObject *input;
4157 Stream *input_stream;
4158 int modebuffer[1];
4159 int poly;
4160 int voiceCount;
4161 MYFLT time;
4162 MYFLT a_time;
4163 int count;
4164 int a_count;
4165 MYFLT expand;
4166 MYFLT a_expand;
4167 MYFLT ampfade;
4168 MYFLT a_ampfade;
4169 int flag;
4170 double sampleToSec;
4171 double currentTime;
4172 double targetTime;
4173 int currentCount;
4174 int *currentTap;
4175 MYFLT *currentAmp;
4176 MYFLT *currentDur;
4177 MYFLT *buffer_streams;
4178 MYFLT *tap_buffer_streams;
4179 MYFLT *amp_buffer_streams;
4180 MYFLT *dur_buffer_streams;
4181 MYFLT *end_buffer_streams;
4182 } TrigBurster;
4183
4184 static void
4185 TrigBurster_generate_i(TrigBurster *self)
4186 {
4187 int i, j;
4188
4189 MYFLT *in = Stream_getData((Stream *)self->input_stream);
4190
4191 for (i = 0; i < (self->poly * self->bufsize); i++)
4192 {
4193 self->buffer_streams[i] = self->end_buffer_streams[i] = 0.0;
4194 }
4195
4196 for (i = 0; i < self->bufsize; i++)
4197 {
4198 if (in[i] == 1.0)
4199 {
4200 self->flag = 1;
4201 self->currentCount = 0;
4202 self->a_time = self->targetTime = self->currentTime = self->time;
4203 self->a_count = self->count;
4204 self->a_expand = self->expand;
4205 self->a_ampfade = self->ampfade;
4206 }
4207
4208 if (self->flag == 1)
4209 {
4210 if (self->currentTime >= self->targetTime)
4211 {
4212 self->currentTime -= self->targetTime;
4213 self->targetTime = self->a_time * MYPOW(self->a_expand, self->currentCount);
4214 self->currentTap[self->voiceCount] = self->currentCount;
4215 self->currentAmp[self->voiceCount] = MYPOW(self->a_ampfade, self->currentCount);
4216 self->currentDur[self->voiceCount] = self->targetTime;
4217 self->buffer_streams[i + self->voiceCount * self->bufsize] = 1.0;
4218 self->currentCount++;
4219
4220 if (self->currentCount == (self->a_count - 1))
4221 self->end_buffer_streams[i + self->voiceCount * self->bufsize] = 1.0;
4222
4223 if (self->currentCount == self->a_count)
4224 self->flag = 0;
4225
4226 self->voiceCount++;
4227
4228 if (self->voiceCount == self->poly)
4229 self->voiceCount = 0;
4230 }
4231
4232 self->currentTime += self->sampleToSec;
4233 }
4234
4235 for (j = 0; j < self->poly; j++)
4236 {
4237 self->tap_buffer_streams[i + j * self->bufsize] = (MYFLT)self->currentTap[j];
4238 self->amp_buffer_streams[i + j * self->bufsize] = self->currentAmp[j];
4239 self->dur_buffer_streams[i + j * self->bufsize] = self->currentDur[j];
4240 }
4241 }
4242 }
4243
4244 MYFLT *
4245 TrigBurster_getSamplesBuffer(TrigBurster *self)
4246 {
4247 return (MYFLT *)self->buffer_streams;
4248 }
4249
4250 MYFLT *
4251 TrigBurster_getTapBuffer(TrigBurster *self)
4252 {
4253 return (MYFLT *)self->tap_buffer_streams;
4254 }
4255
4256 MYFLT *
4257 TrigBurster_getAmpBuffer(TrigBurster *self)
4258 {
4259 return (MYFLT *)self->amp_buffer_streams;
4260 }
4261
4262 MYFLT *
4263 TrigBurster_getDurBuffer(TrigBurster *self)
4264 {
4265 return (MYFLT *)self->dur_buffer_streams;
4266 }
4267
4268 MYFLT *
4269 TrigBurster_getEndBuffer(TrigBurster *self)
4270 {
4271 return (MYFLT *)self->end_buffer_streams;
4272 }
4273
4274 static void
4275 TrigBurster_setProcMode(TrigBurster *self)
4276 {
4277 self->proc_func_ptr = TrigBurster_generate_i;
4278 }
4279
4280 static void
4281 TrigBurster_compute_next_data_frame(TrigBurster *self)
4282 {
4283 (*self->proc_func_ptr)(self);
4284 }
4285
4286 static int
4287 TrigBurster_traverse(TrigBurster *self, visitproc visit, void *arg)
4288 {
4289 pyo_VISIT
4290 Py_VISIT(self->input);
4291 return 0;
4292 }
4293
4294 static int
4295 TrigBurster_clear(TrigBurster *self)
4296 {
4297 pyo_CLEAR
4298 Py_CLEAR(self->input);
4299 return 0;
4300 }
4301
4302 static void
4303 TrigBurster_dealloc(TrigBurster* self)
4304 {
4305 pyo_DEALLOC
4306 PyMem_RawFree(self->buffer_streams);
4307 PyMem_RawFree(self->tap_buffer_streams);
4308 PyMem_RawFree(self->amp_buffer_streams);
4309 PyMem_RawFree(self->dur_buffer_streams);
4310 PyMem_RawFree(self->end_buffer_streams);
4311 PyMem_RawFree(self->currentTap);
4312 PyMem_RawFree(self->currentAmp);
4313 PyMem_RawFree(self->currentDur);
4314 TrigBurster_clear(self);
4315 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
4316 Py_TYPE(self)->tp_free((PyObject*)self);
4317 }
4318
4319 static PyObject *
4320 TrigBurster_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
4321 {
4322 int i;
4323 PyObject *inputtmp, *input_streamtmp;
4324 TrigBurster *self;
4325 self = (TrigBurster *)type->tp_alloc(type, 0);
4326
4327
4328 self->poly = 1;
4329 self->voiceCount = 0;
4330 self->time = self->a_time = 0.25;
4331 self->count = self->a_count = 10;
4332 self->expand = self->a_expand = 1.0;
4333 self->ampfade = self->a_ampfade = 1.0;
4334 self->currentCount = 0;
4335 self->targetTime = 0.0;
4336 self->currentTime = -1.0;
4337 self->flag = 0;
4338
4339 INIT_OBJECT_COMMON
4340 Stream_setFunctionPtr(self->stream, TrigBurster_compute_next_data_frame);
4341 self->mode_func_ptr = TrigBurster_setProcMode;
4342
4343 self->sampleToSec = 1. / self->sr;
4344
4345 Stream_setStreamActive(self->stream, 1);
4346
4347 static char *kwlist[] = {"input", "time", "count", "expand", "ampfade", "poly", NULL};
4348
4349 if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_O_FIFFI, kwlist, &inputtmp, &self->time, &self->count, &self->expand, &self->ampfade, &self->poly))
4350 Py_RETURN_NONE;
4351
4352 INIT_INPUT_STREAM
4353
4354 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
4355
4356 (*self->mode_func_ptr)(self);
4357
4358 self->buffer_streams = (MYFLT *)PyMem_RawRealloc(self->buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
4359 self->tap_buffer_streams = (MYFLT *)PyMem_RawRealloc(self->tap_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
4360 self->amp_buffer_streams = (MYFLT *)PyMem_RawRealloc(self->amp_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
4361 self->dur_buffer_streams = (MYFLT *)PyMem_RawRealloc(self->dur_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
4362 self->end_buffer_streams = (MYFLT *)PyMem_RawRealloc(self->end_buffer_streams, self->poly * self->bufsize * sizeof(MYFLT));
4363
4364 for (i = 0; i < (self->poly * self->bufsize); i++)
4365 {
4366 self->buffer_streams[i] = self->tap_buffer_streams[i] = self->amp_buffer_streams[i] = self->dur_buffer_streams[i] = self->end_buffer_streams[i] = 0.0;
4367 }
4368
4369 self->currentTap = (int *)PyMem_RawRealloc(self->currentTap, self->poly * sizeof(int));
4370 self->currentAmp = (MYFLT *)PyMem_RawRealloc(self->currentAmp, self->poly * sizeof(MYFLT));
4371 self->currentDur = (MYFLT *)PyMem_RawRealloc(self->currentDur, self->poly * sizeof(MYFLT));
4372
4373 for (i = 0; i < (self->poly); i++)
4374 {
4375 self->currentTap[i] = 0;
4376 self->currentAmp[i] = self->currentDur[i] = 0.0;
4377 }
4378
4379 return (PyObject *)self;
4380 }
4381
4382 static PyObject * TrigBurster_getServer(TrigBurster* self) { GET_SERVER };
4383 static PyObject * TrigBurster_getStream(TrigBurster* self) { GET_STREAM };
4384
4385 static PyObject * TrigBurster_play(TrigBurster *self, PyObject *args, PyObject *kwds) { PLAY };
4386 static PyObject * TrigBurster_stop(TrigBurster *self, PyObject *args, PyObject *kwds) { STOP };
4387
4388 static PyObject *
4389 TrigBurster_setTime(TrigBurster *self, PyObject *arg)
4390 {
4391 if (PyNumber_Check(arg))
4392 self->time = PyFloat_AsDouble(arg);
4393
4394 if (self->time <= 0.01)
4395 self->time = 0.01;
4396
4397 Py_RETURN_NONE;
4398 }
4399
4400 static PyObject *
4401 TrigBurster_setCount(TrigBurster *self, PyObject *arg)
4402 {
4403 if (PyLong_Check(arg))
4404 self->count = PyLong_AsLong(arg);
4405
4406 if (self->count < 1)
4407 self->count = 1;
4408
4409 Py_RETURN_NONE;
4410 }
4411
4412 static PyObject *
4413 TrigBurster_setExpand(TrigBurster *self, PyObject *arg)
4414 {
4415 if (PyNumber_Check(arg))
4416 self->expand = PyFloat_AsDouble(arg);
4417
4418 if (self->expand <= 0.1)
4419 self->expand = 0.1;
4420
4421 Py_RETURN_NONE;
4422 }
4423
4424 static PyObject *
4425 TrigBurster_setAmpfade(TrigBurster *self, PyObject *arg)
4426 {
4427 if (PyNumber_Check(arg))
4428 self->ampfade = PyFloat_AsDouble(arg);
4429
4430 if (self->ampfade <= 0.1)
4431 self->ampfade = 0.1;
4432
4433 Py_RETURN_NONE;
4434 }
4435
4436 static PyMemberDef TrigBurster_members[] =
4437 {
4438 {"server", T_OBJECT_EX, offsetof(TrigBurster, server), 0, "Pyo server."},
4439 {"stream", T_OBJECT_EX, offsetof(TrigBurster, stream), 0, "Stream object."},
4440 {"input", T_OBJECT_EX, offsetof(TrigBurster, input), 0, "Input sound object."},
4441 {NULL} /* Sentinel */
4442 };
4443
4444 static PyMethodDef TrigBurster_methods[] =
4445 {
4446 {"getServer", (PyCFunction)TrigBurster_getServer, METH_NOARGS, "Returns server object."},
4447 {"_getStream", (PyCFunction)TrigBurster_getStream, METH_NOARGS, "Returns stream object."},
4448 {"play", (PyCFunction)TrigBurster_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
4449 {"stop", (PyCFunction)TrigBurster_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
4450 {"setTime", (PyCFunction)TrigBurster_setTime, METH_O, "Sets the base time of the serie."},
4451 {"setCount", (PyCFunction)TrigBurster_setCount, METH_O, "Sets the number of trigs in the serie."},
4452 {"setExpand", (PyCFunction)TrigBurster_setExpand, METH_O, "Sets the time's expansion factor of the serie."},
4453 {"setAmpfade", (PyCFunction)TrigBurster_setAmpfade, METH_O, "Sets the amplitude's expansion factor of the serie."},
4454 {NULL} /* Sentinel */
4455 };
4456
4457 PyTypeObject TrigBursterType =
4458 {
4459 PyVarObject_HEAD_INIT(NULL, 0)
4460 "_pyo.TrigBurster_base", /*tp_name*/
4461 sizeof(TrigBurster), /*tp_basicsize*/
4462 0, /*tp_itemsize*/
4463 (destructor)TrigBurster_dealloc, /*tp_dealloc*/
4464 0, /*tp_print*/
4465 0, /*tp_getattr*/
4466 0, /*tp_setattr*/
4467 0, /*tp_as_async (tp_compare in Python 2)*/
4468 0, /*tp_repr*/
4469 0, /*tp_as_number*/
4470 0, /*tp_as_sequence*/
4471 0, /*tp_as_mapping*/
4472 0, /*tp_hash */
4473 0, /*tp_call*/
4474 0, /*tp_str*/
4475 0, /*tp_getattro*/
4476 0, /*tp_setattro*/
4477 0, /*tp_as_buffer*/
4478 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
4479 "TrigBurster objects. Create an algorithmic beat sequence.", /* tp_doc */
4480 (traverseproc)TrigBurster_traverse, /* tp_traverse */
4481 (inquiry)TrigBurster_clear, /* tp_clear */
4482 0, /* tp_richcompare */
4483 0, /* tp_weaklistoffset */
4484 0, /* tp_iter */
4485 0, /* tp_iternext */
4486 TrigBurster_methods, /* tp_methods */
4487 TrigBurster_members, /* tp_members */
4488 0, /* tp_getset */
4489 0, /* tp_base */
4490 0, /* tp_dict */
4491 0, /* tp_descr_get */
4492 0, /* tp_descr_set */
4493 0, /* tp_dictoffset */
4494 0, /* tp_init */
4495 0, /* tp_alloc */
4496 TrigBurster_new, /* tp_new */
4497 };
4498
4499 /************************************************************************************************/
4500 /* TrigBurst streamer object per channel */
4501 /************************************************************************************************/
4502 typedef struct
4503 {
4504 pyo_audio_HEAD
4505 TrigBurster *mainPlayer;
4506 int chnl;
4507 int modebuffer[2];
4508 } TrigBurst;
4509
4510 static void TrigBurst_postprocessing_ii(TrigBurst *self) { POST_PROCESSING_II };
4511 static void TrigBurst_postprocessing_ai(TrigBurst *self) { POST_PROCESSING_AI };
4512 static void TrigBurst_postprocessing_ia(TrigBurst *self) { POST_PROCESSING_IA };
4513 static void TrigBurst_postprocessing_aa(TrigBurst *self) { POST_PROCESSING_AA };
4514 static void TrigBurst_postprocessing_ireva(TrigBurst *self) { POST_PROCESSING_IREVA };
4515 static void TrigBurst_postprocessing_areva(TrigBurst *self) { POST_PROCESSING_AREVA };
4516 static void TrigBurst_postprocessing_revai(TrigBurst *self) { POST_PROCESSING_REVAI };
4517 static void TrigBurst_postprocessing_revaa(TrigBurst *self) { POST_PROCESSING_REVAA };
4518 static void TrigBurst_postprocessing_revareva(TrigBurst *self) { POST_PROCESSING_REVAREVA };
4519
4520 static void
4521 TrigBurst_setProcMode(TrigBurst *self)
4522 {
4523 int muladdmode;
4524 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
4525
4526 switch (muladdmode)
4527 {
4528 case 0:
4529 self->muladd_func_ptr = TrigBurst_postprocessing_ii;
4530 break;
4531
4532 case 1:
4533 self->muladd_func_ptr = TrigBurst_postprocessing_ai;
4534 break;
4535
4536 case 2:
4537 self->muladd_func_ptr = TrigBurst_postprocessing_revai;
4538 break;
4539
4540 case 10:
4541 self->muladd_func_ptr = TrigBurst_postprocessing_ia;
4542 break;
4543
4544 case 11:
4545 self->muladd_func_ptr = TrigBurst_postprocessing_aa;
4546 break;
4547
4548 case 12:
4549 self->muladd_func_ptr = TrigBurst_postprocessing_revaa;
4550 break;
4551
4552 case 20:
4553 self->muladd_func_ptr = TrigBurst_postprocessing_ireva;
4554 break;
4555
4556 case 21:
4557 self->muladd_func_ptr = TrigBurst_postprocessing_areva;
4558 break;
4559
4560 case 22:
4561 self->muladd_func_ptr = TrigBurst_postprocessing_revareva;
4562 break;
4563 }
4564 }
4565
4566 static void
4567 TrigBurst_compute_next_data_frame(TrigBurst *self)
4568 {
4569 int i;
4570 MYFLT *tmp;
4571 int offset = self->chnl * self->bufsize;
4572 tmp = TrigBurster_getSamplesBuffer((TrigBurster *)self->mainPlayer);
4573
4574 for (i = 0; i < self->bufsize; i++)
4575 {
4576 self->data[i] = tmp[i + offset];
4577 }
4578
4579 (*self->muladd_func_ptr)(self);
4580 }
4581
4582 static int
4583 TrigBurst_traverse(TrigBurst *self, visitproc visit, void *arg)
4584 {
4585 pyo_VISIT
4586 Py_VISIT(self->mainPlayer);
4587 return 0;
4588 }
4589
4590 static int
4591 TrigBurst_clear(TrigBurst *self)
4592 {
4593 pyo_CLEAR
4594 Py_CLEAR(self->mainPlayer);
4595 return 0;
4596 }
4597
4598 static void
4599 TrigBurst_dealloc(TrigBurst* self)
4600 {
4601 pyo_DEALLOC
4602 TrigBurst_clear(self);
4603 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
4604 Py_TYPE(self)->tp_free((PyObject*)self);
4605 }
4606
4607 static PyObject *
4608 TrigBurst_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
4609 {
4610 int i;
4611 PyObject *maintmp = NULL;
4612 TrigBurst *self;
4613 self = (TrigBurst *)type->tp_alloc(type, 0);
4614
4615 self->chnl = 0;
4616 self->modebuffer[0] = 0;
4617 self->modebuffer[1] = 0;
4618
4619 INIT_OBJECT_COMMON
4620 Stream_setFunctionPtr(self->stream, TrigBurst_compute_next_data_frame);
4621 self->mode_func_ptr = TrigBurst_setProcMode;
4622
4623 static char *kwlist[] = {"mainPlayer", "chnl", NULL};
4624
4625 if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
4626 Py_RETURN_NONE;
4627
4628 self->mainPlayer = (TrigBurster *)maintmp;
4629 Py_INCREF(self->mainPlayer);
4630
4631 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
4632
4633 (*self->mode_func_ptr)(self);
4634
4635 return (PyObject *)self;
4636 }
4637
4638 static PyObject * TrigBurst_getServer(TrigBurst* self) { GET_SERVER };
4639 static PyObject * TrigBurst_getStream(TrigBurst* self) { GET_STREAM };
4640 static PyObject * TrigBurst_setMul(TrigBurst *self, PyObject *arg) { SET_MUL };
4641 static PyObject * TrigBurst_setAdd(TrigBurst *self, PyObject *arg) { SET_ADD };
4642 static PyObject * TrigBurst_setSub(TrigBurst *self, PyObject *arg) { SET_SUB };
4643 static PyObject * TrigBurst_setDiv(TrigBurst *self, PyObject *arg) { SET_DIV };
4644
4645 static PyObject * TrigBurst_play(TrigBurst *self, PyObject *args, PyObject *kwds) { PLAY };
4646 static PyObject * TrigBurst_out(TrigBurst *self, PyObject *args, PyObject *kwds) { OUT };
4647 static PyObject * TrigBurst_stop(TrigBurst *self, PyObject *args, PyObject *kwds) { STOP };
4648
4649 static PyObject * TrigBurst_multiply(TrigBurst *self, PyObject *arg) { MULTIPLY };
4650 static PyObject * TrigBurst_inplace_multiply(TrigBurst *self, PyObject *arg) { INPLACE_MULTIPLY };
4651 static PyObject * TrigBurst_add(TrigBurst *self, PyObject *arg) { ADD };
4652 static PyObject * TrigBurst_inplace_add(TrigBurst *self, PyObject *arg) { INPLACE_ADD };
4653 static PyObject * TrigBurst_sub(TrigBurst *self, PyObject *arg) { SUB };
4654 static PyObject * TrigBurst_inplace_sub(TrigBurst *self, PyObject *arg) { INPLACE_SUB };
4655 static PyObject * TrigBurst_div(TrigBurst *self, PyObject *arg) { DIV };
4656 static PyObject * TrigBurst_inplace_div(TrigBurst *self, PyObject *arg) { INPLACE_DIV };
4657
4658 static PyMemberDef TrigBurst_members[] =
4659 {
4660 {"server", T_OBJECT_EX, offsetof(TrigBurst, server), 0, "Pyo server."},
4661 {"stream", T_OBJECT_EX, offsetof(TrigBurst, stream), 0, "Stream object."},
4662 {"mul", T_OBJECT_EX, offsetof(TrigBurst, mul), 0, "Mul factor."},
4663 {"add", T_OBJECT_EX, offsetof(TrigBurst, add), 0, "Add factor."},
4664 {NULL} /* Sentinel */
4665 };
4666
4667 static PyMethodDef TrigBurst_methods[] =
4668 {
4669 {"getServer", (PyCFunction)TrigBurst_getServer, METH_NOARGS, "Returns server object."},
4670 {"_getStream", (PyCFunction)TrigBurst_getStream, METH_NOARGS, "Returns stream object."},
4671 {"play", (PyCFunction)TrigBurst_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
4672 {"out", (PyCFunction)TrigBurst_out, METH_VARARGS | METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
4673 {"stop", (PyCFunction)TrigBurst_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
4674 {"setMul", (PyCFunction)TrigBurst_setMul, METH_O, "Sets oscillator mul factor."},
4675 {"setAdd", (PyCFunction)TrigBurst_setAdd, METH_O, "Sets oscillator add factor."},
4676 {"setSub", (PyCFunction)TrigBurst_setSub, METH_O, "Sets inverse add factor."},
4677 {"setDiv", (PyCFunction)TrigBurst_setDiv, METH_O, "Sets inverse mul factor."},
4678 {NULL} /* Sentinel */
4679 };
4680
4681 static PyNumberMethods TrigBurst_as_number =
4682 {
4683 (binaryfunc)TrigBurst_add, /*nb_add*/
4684 (binaryfunc)TrigBurst_sub, /*nb_subtract*/
4685 (binaryfunc)TrigBurst_multiply, /*nb_multiply*/
4686 0, /*nb_remainder*/
4687 0, /*nb_divmod*/
4688 0, /*nb_power*/
4689 0, /*nb_neg*/
4690 0, /*nb_pos*/
4691 0, /*(unaryfunc)array_abs,*/
4692 0, /*nb_nonzero*/
4693 0, /*nb_invert*/
4694 0, /*nb_lshift*/
4695 0, /*nb_rshift*/
4696 0, /*nb_and*/
4697 0, /*nb_xor*/
4698 0, /*nb_or*/
4699 0, /*nb_int*/
4700 0, /*nb_long*/
4701 0, /*nb_float*/
4702 (binaryfunc)TrigBurst_inplace_add, /*inplace_add*/
4703 (binaryfunc)TrigBurst_inplace_sub, /*inplace_subtract*/
4704 (binaryfunc)TrigBurst_inplace_multiply, /*inplace_multiply*/
4705 0, /*inplace_remainder*/
4706 0, /*inplace_power*/
4707 0, /*inplace_lshift*/
4708 0, /*inplace_rshift*/
4709 0, /*inplace_and*/
4710 0, /*inplace_xor*/
4711 0, /*inplace_or*/
4712 0, /*nb_floor_divide*/
4713 (binaryfunc)TrigBurst_div, /*nb_true_divide*/
4714 0, /*nb_inplace_floor_divide*/
4715 (binaryfunc)TrigBurst_inplace_div, /*nb_inplace_true_divide*/
4716 0, /* nb_index */
4717 };
4718
4719 PyTypeObject TrigBurstType =
4720 {
4721 PyVarObject_HEAD_INIT(NULL, 0)
4722 "_pyo.TrigBurst_base", /*tp_name*/
4723 sizeof(TrigBurst), /*tp_basicsize*/
4724 0, /*tp_itemsize*/
4725 (destructor)TrigBurst_dealloc, /*tp_dealloc*/
4726 0, /*tp_print*/
4727 0, /*tp_getattr*/
4728 0, /*tp_setattr*/
4729 0, /*tp_as_async (tp_compare in Python 2)*/
4730 0, /*tp_repr*/
4731 &TrigBurst_as_number, /*tp_as_number*/
4732 0, /*tp_as_sequence*/
4733 0, /*tp_as_mapping*/
4734 0, /*tp_hash */
4735 0, /*tp_call*/
4736 0, /*tp_str*/
4737 0, /*tp_getattro*/
4738 0, /*tp_setattro*/
4739 0, /*tp_as_buffer*/
4740 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
4741 "TrigBurst objects. Reads a channel from a TrigBurster.", /* tp_doc */
4742 (traverseproc)TrigBurst_traverse, /* tp_traverse */
4743 (inquiry)TrigBurst_clear, /* tp_clear */
4744 0, /* tp_richcompare */
4745 0, /* tp_weaklistoffset */
4746 0, /* tp_iter */
4747 0, /* tp_iternext */
4748 TrigBurst_methods, /* tp_methods */
4749 TrigBurst_members, /* tp_members */
4750 0, /* tp_getset */
4751 0, /* tp_base */
4752 0, /* tp_dict */
4753 0, /* tp_descr_get */
4754 0, /* tp_descr_set */
4755 0, /* tp_dictoffset */
4756 0, /* tp_init */
4757 0, /* tp_alloc */
4758 TrigBurst_new, /* tp_new */
4759 };
4760
4761 /************************************************************************************************/
4762 /* TrigBurstTapStream object per channel */
4763 /************************************************************************************************/
4764 typedef struct
4765 {
4766 pyo_audio_HEAD
4767 TrigBurster *mainPlayer;
4768 int chnl;
4769 int modebuffer[2];
4770 } TrigBurstTapStream;
4771
4772 static void TrigBurstTapStream_postprocessing_ii(TrigBurstTapStream *self) { POST_PROCESSING_II };
4773 static void TrigBurstTapStream_postprocessing_ai(TrigBurstTapStream *self) { POST_PROCESSING_AI };
4774 static void TrigBurstTapStream_postprocessing_ia(TrigBurstTapStream *self) { POST_PROCESSING_IA };
4775 static void TrigBurstTapStream_postprocessing_aa(TrigBurstTapStream *self) { POST_PROCESSING_AA };
4776 static void TrigBurstTapStream_postprocessing_ireva(TrigBurstTapStream *self) { POST_PROCESSING_IREVA };
4777 static void TrigBurstTapStream_postprocessing_areva(TrigBurstTapStream *self) { POST_PROCESSING_AREVA };
4778 static void TrigBurstTapStream_postprocessing_revai(TrigBurstTapStream *self) { POST_PROCESSING_REVAI };
4779 static void TrigBurstTapStream_postprocessing_revaa(TrigBurstTapStream *self) { POST_PROCESSING_REVAA };
4780 static void TrigBurstTapStream_postprocessing_revareva(TrigBurstTapStream *self) { POST_PROCESSING_REVAREVA };
4781
4782 static void
4783 TrigBurstTapStream_setProcMode(TrigBurstTapStream *self)
4784 {
4785 int muladdmode;
4786 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
4787
4788 switch (muladdmode)
4789 {
4790 case 0:
4791 self->muladd_func_ptr = TrigBurstTapStream_postprocessing_ii;
4792 break;
4793
4794 case 1:
4795 self->muladd_func_ptr = TrigBurstTapStream_postprocessing_ai;
4796 break;
4797
4798 case 2:
4799 self->muladd_func_ptr = TrigBurstTapStream_postprocessing_revai;
4800 break;
4801
4802 case 10:
4803 self->muladd_func_ptr = TrigBurstTapStream_postprocessing_ia;
4804 break;
4805
4806 case 11:
4807 self->muladd_func_ptr = TrigBurstTapStream_postprocessing_aa;
4808 break;
4809
4810 case 12:
4811 self->muladd_func_ptr = TrigBurstTapStream_postprocessing_revaa;
4812 break;
4813
4814 case 20:
4815 self->muladd_func_ptr = TrigBurstTapStream_postprocessing_ireva;
4816 break;
4817
4818 case 21:
4819 self->muladd_func_ptr = TrigBurstTapStream_postprocessing_areva;
4820 break;
4821
4822 case 22:
4823 self->muladd_func_ptr = TrigBurstTapStream_postprocessing_revareva;
4824 break;
4825 }
4826 }
4827
4828 static void
4829 TrigBurstTapStream_compute_next_data_frame(TrigBurstTapStream *self)
4830 {
4831 int i;
4832 MYFLT *tmp;
4833 int offset = self->chnl * self->bufsize;
4834 tmp = TrigBurster_getTapBuffer((TrigBurster *)self->mainPlayer);
4835
4836 for (i = 0; i < self->bufsize; i++)
4837 {
4838 self->data[i] = tmp[i + offset];
4839 }
4840
4841 (*self->muladd_func_ptr)(self);
4842 }
4843
4844 static int
4845 TrigBurstTapStream_traverse(TrigBurstTapStream *self, visitproc visit, void *arg)
4846 {
4847 pyo_VISIT
4848 Py_VISIT(self->mainPlayer);
4849 return 0;
4850 }
4851
4852 static int
4853 TrigBurstTapStream_clear(TrigBurstTapStream *self)
4854 {
4855 pyo_CLEAR
4856 Py_CLEAR(self->mainPlayer);
4857 return 0;
4858 }
4859
4860 static void
4861 TrigBurstTapStream_dealloc(TrigBurstTapStream* self)
4862 {
4863 pyo_DEALLOC
4864 TrigBurstTapStream_clear(self);
4865 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
4866 Py_TYPE(self)->tp_free((PyObject*)self);
4867 }
4868
4869 static PyObject *
4870 TrigBurstTapStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
4871 {
4872 int i;
4873 PyObject *maintmp = NULL;
4874 TrigBurstTapStream *self;
4875 self = (TrigBurstTapStream *)type->tp_alloc(type, 0);
4876
4877 self->chnl = 0;
4878 self->modebuffer[0] = 0;
4879 self->modebuffer[1] = 0;
4880
4881 INIT_OBJECT_COMMON
4882 Stream_setFunctionPtr(self->stream, TrigBurstTapStream_compute_next_data_frame);
4883 self->mode_func_ptr = TrigBurstTapStream_setProcMode;
4884
4885 static char *kwlist[] = {"mainPlayer", "chnl", NULL};
4886
4887 if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
4888 Py_RETURN_NONE;
4889
4890 self->mainPlayer = (TrigBurster *)maintmp;
4891 Py_INCREF(self->mainPlayer);
4892
4893 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
4894
4895 (*self->mode_func_ptr)(self);
4896
4897 return (PyObject *)self;
4898 }
4899
4900 static PyObject * TrigBurstTapStream_getServer(TrigBurstTapStream* self) { GET_SERVER };
4901 static PyObject * TrigBurstTapStream_getStream(TrigBurstTapStream* self) { GET_STREAM };
4902 static PyObject * TrigBurstTapStream_setMul(TrigBurstTapStream *self, PyObject *arg) { SET_MUL };
4903 static PyObject * TrigBurstTapStream_setAdd(TrigBurstTapStream *self, PyObject *arg) { SET_ADD };
4904 static PyObject * TrigBurstTapStream_setSub(TrigBurstTapStream *self, PyObject *arg) { SET_SUB };
4905 static PyObject * TrigBurstTapStream_setDiv(TrigBurstTapStream *self, PyObject *arg) { SET_DIV };
4906
4907 static PyObject * TrigBurstTapStream_play(TrigBurstTapStream *self, PyObject *args, PyObject *kwds) { PLAY };
4908 static PyObject * TrigBurstTapStream_out(TrigBurstTapStream *self, PyObject *args, PyObject *kwds) { OUT };
4909 static PyObject * TrigBurstTapStream_stop(TrigBurstTapStream *self, PyObject *args, PyObject *kwds) { STOP };
4910
4911 static PyObject * TrigBurstTapStream_multiply(TrigBurstTapStream *self, PyObject *arg) { MULTIPLY };
4912 static PyObject * TrigBurstTapStream_inplace_multiply(TrigBurstTapStream *self, PyObject *arg) { INPLACE_MULTIPLY };
4913 static PyObject * TrigBurstTapStream_add(TrigBurstTapStream *self, PyObject *arg) { ADD };
4914 static PyObject * TrigBurstTapStream_inplace_add(TrigBurstTapStream *self, PyObject *arg) { INPLACE_ADD };
4915 static PyObject * TrigBurstTapStream_sub(TrigBurstTapStream *self, PyObject *arg) { SUB };
4916 static PyObject * TrigBurstTapStream_inplace_sub(TrigBurstTapStream *self, PyObject *arg) { INPLACE_SUB };
4917 static PyObject * TrigBurstTapStream_div(TrigBurstTapStream *self, PyObject *arg) { DIV };
4918 static PyObject * TrigBurstTapStream_inplace_div(TrigBurstTapStream *self, PyObject *arg) { INPLACE_DIV };
4919
4920 static PyMemberDef TrigBurstTapStream_members[] =
4921 {
4922 {"server", T_OBJECT_EX, offsetof(TrigBurstTapStream, server), 0, "Pyo server."},
4923 {"stream", T_OBJECT_EX, offsetof(TrigBurstTapStream, stream), 0, "Stream object."},
4924 {"mul", T_OBJECT_EX, offsetof(TrigBurstTapStream, mul), 0, "Mul factor."},
4925 {"add", T_OBJECT_EX, offsetof(TrigBurstTapStream, add), 0, "Add factor."},
4926 {NULL} /* Sentinel */
4927 };
4928
4929 static PyMethodDef TrigBurstTapStream_methods[] =
4930 {
4931 {"getServer", (PyCFunction)TrigBurstTapStream_getServer, METH_NOARGS, "Returns server object."},
4932 {"_getStream", (PyCFunction)TrigBurstTapStream_getStream, METH_NOARGS, "Returns stream object."},
4933 {"play", (PyCFunction)TrigBurstTapStream_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
4934 {"out", (PyCFunction)TrigBurstTapStream_out, METH_VARARGS | METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
4935 {"stop", (PyCFunction)TrigBurstTapStream_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
4936 {"setMul", (PyCFunction)TrigBurstTapStream_setMul, METH_O, "Sets oscillator mul factor."},
4937 {"setAdd", (PyCFunction)TrigBurstTapStream_setAdd, METH_O, "Sets oscillator add factor."},
4938 {"setSub", (PyCFunction)TrigBurstTapStream_setSub, METH_O, "Sets inverse add factor."},
4939 {"setDiv", (PyCFunction)TrigBurstTapStream_setDiv, METH_O, "Sets inverse mul factor."},
4940 {NULL} /* Sentinel */
4941 };
4942
4943 static PyNumberMethods TrigBurstTapStream_as_number =
4944 {
4945 (binaryfunc)TrigBurstTapStream_add, /*nb_add*/
4946 (binaryfunc)TrigBurstTapStream_sub, /*nb_subtract*/
4947 (binaryfunc)TrigBurstTapStream_multiply, /*nb_multiply*/
4948 0, /*nb_remainder*/
4949 0, /*nb_divmod*/
4950 0, /*nb_power*/
4951 0, /*nb_neg*/
4952 0, /*nb_pos*/
4953 0, /*(unaryfunc)array_abs,*/
4954 0, /*nb_nonzero*/
4955 0, /*nb_invert*/
4956 0, /*nb_lshift*/
4957 0, /*nb_rshift*/
4958 0, /*nb_and*/
4959 0, /*nb_xor*/
4960 0, /*nb_or*/
4961 0, /*nb_int*/
4962 0, /*nb_long*/
4963 0, /*nb_float*/
4964 (binaryfunc)TrigBurstTapStream_inplace_add, /*inplace_add*/
4965 (binaryfunc)TrigBurstTapStream_inplace_sub, /*inplace_subtract*/
4966 (binaryfunc)TrigBurstTapStream_inplace_multiply, /*inplace_multiply*/
4967 0, /*inplace_remainder*/
4968 0, /*inplace_power*/
4969 0, /*inplace_lshift*/
4970 0, /*inplace_rshift*/
4971 0, /*inplace_and*/
4972 0, /*inplace_xor*/
4973 0, /*inplace_or*/
4974 0, /*nb_floor_divide*/
4975 (binaryfunc)TrigBurstTapStream_div, /*nb_true_divide*/
4976 0, /*nb_inplace_floor_divide*/
4977 (binaryfunc)TrigBurstTapStream_inplace_div, /*nb_inplace_true_divide*/
4978 0, /* nb_index */
4979 };
4980
4981 PyTypeObject TrigBurstTapStreamType =
4982 {
4983 PyVarObject_HEAD_INIT(NULL, 0)
4984 "_pyo.TrigBurstTapStream_base", /*tp_name*/
4985 sizeof(TrigBurstTapStream), /*tp_basicsize*/
4986 0, /*tp_itemsize*/
4987 (destructor)TrigBurstTapStream_dealloc, /*tp_dealloc*/
4988 0, /*tp_print*/
4989 0, /*tp_getattr*/
4990 0, /*tp_setattr*/
4991 0, /*tp_as_async (tp_compare in Python 2)*/
4992 0, /*tp_repr*/
4993 &TrigBurstTapStream_as_number, /*tp_as_number*/
4994 0, /*tp_as_sequence*/
4995 0, /*tp_as_mapping*/
4996 0, /*tp_hash */
4997 0, /*tp_call*/
4998 0, /*tp_str*/
4999 0, /*tp_getattro*/
5000 0, /*tp_setattro*/
5001 0, /*tp_as_buffer*/
5002 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
5003 "TrigBurstTapStream objects. Reads the current tap from a TrigBurster object.", /* tp_doc */
5004 (traverseproc)TrigBurstTapStream_traverse, /* tp_traverse */
5005 (inquiry)TrigBurstTapStream_clear, /* tp_clear */
5006 0, /* tp_richcompare */
5007 0, /* tp_weaklistoffset */
5008 0, /* tp_iter */
5009 0, /* tp_iternext */
5010 TrigBurstTapStream_methods, /* tp_methods */
5011 TrigBurstTapStream_members, /* tp_members */
5012 0, /* tp_getset */
5013 0, /* tp_base */
5014 0, /* tp_dict */
5015 0, /* tp_descr_get */
5016 0, /* tp_descr_set */
5017 0, /* tp_dictoffset */
5018 0, /* tp_init */
5019 0, /* tp_alloc */
5020 TrigBurstTapStream_new, /* tp_new */
5021 };
5022
5023 /************************************************************************************************/
5024 /* TrigBurstAmpStream object per channel */
5025 /************************************************************************************************/
5026 typedef struct
5027 {
5028 pyo_audio_HEAD
5029 TrigBurster *mainPlayer;
5030 int chnl;
5031 int modebuffer[2];
5032 } TrigBurstAmpStream;
5033
5034 static void TrigBurstAmpStream_postprocessing_ii(TrigBurstAmpStream *self) { POST_PROCESSING_II };
5035 static void TrigBurstAmpStream_postprocessing_ai(TrigBurstAmpStream *self) { POST_PROCESSING_AI };
5036 static void TrigBurstAmpStream_postprocessing_ia(TrigBurstAmpStream *self) { POST_PROCESSING_IA };
5037 static void TrigBurstAmpStream_postprocessing_aa(TrigBurstAmpStream *self) { POST_PROCESSING_AA };
5038 static void TrigBurstAmpStream_postprocessing_ireva(TrigBurstAmpStream *self) { POST_PROCESSING_IREVA };
5039 static void TrigBurstAmpStream_postprocessing_areva(TrigBurstAmpStream *self) { POST_PROCESSING_AREVA };
5040 static void TrigBurstAmpStream_postprocessing_revai(TrigBurstAmpStream *self) { POST_PROCESSING_REVAI };
5041 static void TrigBurstAmpStream_postprocessing_revaa(TrigBurstAmpStream *self) { POST_PROCESSING_REVAA };
5042 static void TrigBurstAmpStream_postprocessing_revareva(TrigBurstAmpStream *self) { POST_PROCESSING_REVAREVA };
5043
5044 static void
5045 TrigBurstAmpStream_setProcMode(TrigBurstAmpStream *self)
5046 {
5047 int muladdmode;
5048 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
5049
5050 switch (muladdmode)
5051 {
5052 case 0:
5053 self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_ii;
5054 break;
5055
5056 case 1:
5057 self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_ai;
5058 break;
5059
5060 case 2:
5061 self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_revai;
5062 break;
5063
5064 case 10:
5065 self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_ia;
5066 break;
5067
5068 case 11:
5069 self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_aa;
5070 break;
5071
5072 case 12:
5073 self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_revaa;
5074 break;
5075
5076 case 20:
5077 self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_ireva;
5078 break;
5079
5080 case 21:
5081 self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_areva;
5082 break;
5083
5084 case 22:
5085 self->muladd_func_ptr = TrigBurstAmpStream_postprocessing_revareva;
5086 break;
5087 }
5088 }
5089
5090 static void
5091 TrigBurstAmpStream_compute_next_data_frame(TrigBurstAmpStream *self)
5092 {
5093 int i;
5094 MYFLT *tmp;
5095 int offset = self->chnl * self->bufsize;
5096 tmp = TrigBurster_getAmpBuffer((TrigBurster *)self->mainPlayer);
5097
5098 for (i = 0; i < self->bufsize; i++)
5099 {
5100 self->data[i] = tmp[i + offset];
5101 }
5102
5103 (*self->muladd_func_ptr)(self);
5104 }
5105
5106 static int
5107 TrigBurstAmpStream_traverse(TrigBurstAmpStream *self, visitproc visit, void *arg)
5108 {
5109 pyo_VISIT
5110 Py_VISIT(self->mainPlayer);
5111 return 0;
5112 }
5113
5114 static int
5115 TrigBurstAmpStream_clear(TrigBurstAmpStream *self)
5116 {
5117 pyo_CLEAR
5118 Py_CLEAR(self->mainPlayer);
5119 return 0;
5120 }
5121
5122 static void
5123 TrigBurstAmpStream_dealloc(TrigBurstAmpStream* self)
5124 {
5125 pyo_DEALLOC
5126 TrigBurstAmpStream_clear(self);
5127 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
5128 Py_TYPE(self)->tp_free((PyObject*)self);
5129 }
5130
5131 static PyObject *
5132 TrigBurstAmpStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
5133 {
5134 int i;
5135 PyObject *maintmp = NULL;
5136 TrigBurstAmpStream *self;
5137 self = (TrigBurstAmpStream *)type->tp_alloc(type, 0);
5138
5139 self->chnl = 0;
5140 self->modebuffer[0] = 0;
5141 self->modebuffer[1] = 0;
5142
5143 INIT_OBJECT_COMMON
5144 Stream_setFunctionPtr(self->stream, TrigBurstAmpStream_compute_next_data_frame);
5145 self->mode_func_ptr = TrigBurstAmpStream_setProcMode;
5146
5147 static char *kwlist[] = {"mainPlayer", "chnl", NULL};
5148
5149 if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
5150 Py_RETURN_NONE;
5151
5152 self->mainPlayer = (TrigBurster *)maintmp;
5153 Py_INCREF(self->mainPlayer);
5154
5155 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
5156
5157 (*self->mode_func_ptr)(self);
5158
5159 return (PyObject *)self;
5160 }
5161
5162 static PyObject * TrigBurstAmpStream_getServer(TrigBurstAmpStream* self) { GET_SERVER };
5163 static PyObject * TrigBurstAmpStream_getStream(TrigBurstAmpStream* self) { GET_STREAM };
5164 static PyObject * TrigBurstAmpStream_setMul(TrigBurstAmpStream *self, PyObject *arg) { SET_MUL };
5165 static PyObject * TrigBurstAmpStream_setAdd(TrigBurstAmpStream *self, PyObject *arg) { SET_ADD };
5166 static PyObject * TrigBurstAmpStream_setSub(TrigBurstAmpStream *self, PyObject *arg) { SET_SUB };
5167 static PyObject * TrigBurstAmpStream_setDiv(TrigBurstAmpStream *self, PyObject *arg) { SET_DIV };
5168
5169 static PyObject * TrigBurstAmpStream_play(TrigBurstAmpStream *self, PyObject *args, PyObject *kwds) { PLAY };
5170 static PyObject * TrigBurstAmpStream_out(TrigBurstAmpStream *self, PyObject *args, PyObject *kwds) { OUT };
5171 static PyObject * TrigBurstAmpStream_stop(TrigBurstAmpStream *self, PyObject *args, PyObject *kwds) { STOP };
5172
5173 static PyObject * TrigBurstAmpStream_multiply(TrigBurstAmpStream *self, PyObject *arg) { MULTIPLY };
5174 static PyObject * TrigBurstAmpStream_inplace_multiply(TrigBurstAmpStream *self, PyObject *arg) { INPLACE_MULTIPLY };
5175 static PyObject * TrigBurstAmpStream_add(TrigBurstAmpStream *self, PyObject *arg) { ADD };
5176 static PyObject * TrigBurstAmpStream_inplace_add(TrigBurstAmpStream *self, PyObject *arg) { INPLACE_ADD };
5177 static PyObject * TrigBurstAmpStream_sub(TrigBurstAmpStream *self, PyObject *arg) { SUB };
5178 static PyObject * TrigBurstAmpStream_inplace_sub(TrigBurstAmpStream *self, PyObject *arg) { INPLACE_SUB };
5179 static PyObject * TrigBurstAmpStream_div(TrigBurstAmpStream *self, PyObject *arg) { DIV };
5180 static PyObject * TrigBurstAmpStream_inplace_div(TrigBurstAmpStream *self, PyObject *arg) { INPLACE_DIV };
5181
5182 static PyMemberDef TrigBurstAmpStream_members[] =
5183 {
5184 {"server", T_OBJECT_EX, offsetof(TrigBurstAmpStream, server), 0, "Pyo server."},
5185 {"stream", T_OBJECT_EX, offsetof(TrigBurstAmpStream, stream), 0, "Stream object."},
5186 {"mul", T_OBJECT_EX, offsetof(TrigBurstAmpStream, mul), 0, "Mul factor."},
5187 {"add", T_OBJECT_EX, offsetof(TrigBurstAmpStream, add), 0, "Add factor."},
5188 {NULL} /* Sentinel */
5189 };
5190
5191 static PyMethodDef TrigBurstAmpStream_methods[] =
5192 {
5193 {"getServer", (PyCFunction)TrigBurstAmpStream_getServer, METH_NOARGS, "Returns server object."},
5194 {"_getStream", (PyCFunction)TrigBurstAmpStream_getStream, METH_NOARGS, "Returns stream object."},
5195 {"play", (PyCFunction)TrigBurstAmpStream_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
5196 {"out", (PyCFunction)TrigBurstAmpStream_out, METH_VARARGS | METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
5197 {"stop", (PyCFunction)TrigBurstAmpStream_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
5198 {"setMul", (PyCFunction)TrigBurstAmpStream_setMul, METH_O, "Sets oscillator mul factor."},
5199 {"setAdd", (PyCFunction)TrigBurstAmpStream_setAdd, METH_O, "Sets oscillator add factor."},
5200 {"setSub", (PyCFunction)TrigBurstAmpStream_setSub, METH_O, "Sets inverse add factor."},
5201 {"setDiv", (PyCFunction)TrigBurstAmpStream_setDiv, METH_O, "Sets inverse mul factor."},
5202 {NULL} /* Sentinel */
5203 };
5204
5205 static PyNumberMethods TrigBurstAmpStream_as_number =
5206 {
5207 (binaryfunc)TrigBurstAmpStream_add, /*nb_add*/
5208 (binaryfunc)TrigBurstAmpStream_sub, /*nb_subtract*/
5209 (binaryfunc)TrigBurstAmpStream_multiply, /*nb_multiply*/
5210 0, /*nb_remainder*/
5211 0, /*nb_divmod*/
5212 0, /*nb_power*/
5213 0, /*nb_neg*/
5214 0, /*nb_pos*/
5215 0, /*(unaryfunc)array_abs,*/
5216 0, /*nb_nonzero*/
5217 0, /*nb_invert*/
5218 0, /*nb_lshift*/
5219 0, /*nb_rshift*/
5220 0, /*nb_and*/
5221 0, /*nb_xor*/
5222 0, /*nb_or*/
5223 0, /*nb_int*/
5224 0, /*nb_long*/
5225 0, /*nb_float*/
5226 (binaryfunc)TrigBurstAmpStream_inplace_add, /*inplace_add*/
5227 (binaryfunc)TrigBurstAmpStream_inplace_sub, /*inplace_subtract*/
5228 (binaryfunc)TrigBurstAmpStream_inplace_multiply, /*inplace_multiply*/
5229 0, /*inplace_remainder*/
5230 0, /*inplace_power*/
5231 0, /*inplace_lshift*/
5232 0, /*inplace_rshift*/
5233 0, /*inplace_and*/
5234 0, /*inplace_xor*/
5235 0, /*inplace_or*/
5236 0, /*nb_floor_divide*/
5237 (binaryfunc)TrigBurstAmpStream_div, /*nb_true_divide*/
5238 0, /*nb_inplace_floor_divide*/
5239 (binaryfunc)TrigBurstAmpStream_inplace_div, /*nb_inplace_true_divide*/
5240 0, /* nb_index */
5241 };
5242
5243 PyTypeObject TrigBurstAmpStreamType =
5244 {
5245 PyVarObject_HEAD_INIT(NULL, 0)
5246 "_pyo.TrigBurstAmpStream_base", /*tp_name*/
5247 sizeof(TrigBurstAmpStream), /*tp_basicsize*/
5248 0, /*tp_itemsize*/
5249 (destructor)TrigBurstAmpStream_dealloc, /*tp_dealloc*/
5250 0, /*tp_print*/
5251 0, /*tp_getattr*/
5252 0, /*tp_setattr*/
5253 0, /*tp_as_async (tp_compare in Python 2)*/
5254 0, /*tp_repr*/
5255 &TrigBurstAmpStream_as_number, /*tp_as_number*/
5256 0, /*tp_as_sequence*/
5257 0, /*tp_as_mapping*/
5258 0, /*tp_hash */
5259 0, /*tp_call*/
5260 0, /*tp_str*/
5261 0, /*tp_getattro*/
5262 0, /*tp_setattro*/
5263 0, /*tp_as_buffer*/
5264 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
5265 "TrigBurstAmpStream objects. Reads a amplitude channel from a TrigBurster object.", /* tp_doc */
5266 (traverseproc)TrigBurstAmpStream_traverse, /* tp_traverse */
5267 (inquiry)TrigBurstAmpStream_clear, /* tp_clear */
5268 0, /* tp_richcompare */
5269 0, /* tp_weaklistoffset */
5270 0, /* tp_iter */
5271 0, /* tp_iternext */
5272 TrigBurstAmpStream_methods, /* tp_methods */
5273 TrigBurstAmpStream_members, /* tp_members */
5274 0, /* tp_getset */
5275 0, /* tp_base */
5276 0, /* tp_dict */
5277 0, /* tp_descr_get */
5278 0, /* tp_descr_set */
5279 0, /* tp_dictoffset */
5280 0, /* tp_init */
5281 0, /* tp_alloc */
5282 TrigBurstAmpStream_new, /* tp_new */
5283 };
5284
5285 /************************************************************************************************/
5286 /* TrigBurstDurStream object per channel */
5287 /************************************************************************************************/
5288 typedef struct
5289 {
5290 pyo_audio_HEAD
5291 TrigBurster *mainPlayer;
5292 int chnl;
5293 int modebuffer[2];
5294 } TrigBurstDurStream;
5295
5296 static void TrigBurstDurStream_postprocessing_ii(TrigBurstDurStream *self) { POST_PROCESSING_II };
5297 static void TrigBurstDurStream_postprocessing_ai(TrigBurstDurStream *self) { POST_PROCESSING_AI };
5298 static void TrigBurstDurStream_postprocessing_ia(TrigBurstDurStream *self) { POST_PROCESSING_IA };
5299 static void TrigBurstDurStream_postprocessing_aa(TrigBurstDurStream *self) { POST_PROCESSING_AA };
5300 static void TrigBurstDurStream_postprocessing_ireva(TrigBurstDurStream *self) { POST_PROCESSING_IREVA };
5301 static void TrigBurstDurStream_postprocessing_areva(TrigBurstDurStream *self) { POST_PROCESSING_AREVA };
5302 static void TrigBurstDurStream_postprocessing_revai(TrigBurstDurStream *self) { POST_PROCESSING_REVAI };
5303 static void TrigBurstDurStream_postprocessing_revaa(TrigBurstDurStream *self) { POST_PROCESSING_REVAA };
5304 static void TrigBurstDurStream_postprocessing_revareva(TrigBurstDurStream *self) { POST_PROCESSING_REVAREVA };
5305
5306 static void
5307 TrigBurstDurStream_setProcMode(TrigBurstDurStream *self)
5308 {
5309 int muladdmode;
5310 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
5311
5312 switch (muladdmode)
5313 {
5314 case 0:
5315 self->muladd_func_ptr = TrigBurstDurStream_postprocessing_ii;
5316 break;
5317
5318 case 1:
5319 self->muladd_func_ptr = TrigBurstDurStream_postprocessing_ai;
5320 break;
5321
5322 case 2:
5323 self->muladd_func_ptr = TrigBurstDurStream_postprocessing_revai;
5324 break;
5325
5326 case 10:
5327 self->muladd_func_ptr = TrigBurstDurStream_postprocessing_ia;
5328 break;
5329
5330 case 11:
5331 self->muladd_func_ptr = TrigBurstDurStream_postprocessing_aa;
5332 break;
5333
5334 case 12:
5335 self->muladd_func_ptr = TrigBurstDurStream_postprocessing_revaa;
5336 break;
5337
5338 case 20:
5339 self->muladd_func_ptr = TrigBurstDurStream_postprocessing_ireva;
5340 break;
5341
5342 case 21:
5343 self->muladd_func_ptr = TrigBurstDurStream_postprocessing_areva;
5344 break;
5345
5346 case 22:
5347 self->muladd_func_ptr = TrigBurstDurStream_postprocessing_revareva;
5348 break;
5349 }
5350 }
5351
5352 static void
5353 TrigBurstDurStream_compute_next_data_frame(TrigBurstDurStream *self)
5354 {
5355 int i;
5356 MYFLT *tmp;
5357 int offset = self->chnl * self->bufsize;
5358 tmp = TrigBurster_getDurBuffer((TrigBurster *)self->mainPlayer);
5359
5360 for (i = 0; i < self->bufsize; i++)
5361 {
5362 self->data[i] = tmp[i + offset];
5363 }
5364
5365 (*self->muladd_func_ptr)(self);
5366 }
5367
5368 static int
5369 TrigBurstDurStream_traverse(TrigBurstDurStream *self, visitproc visit, void *arg)
5370 {
5371 pyo_VISIT
5372 Py_VISIT(self->mainPlayer);
5373 return 0;
5374 }
5375
5376 static int
5377 TrigBurstDurStream_clear(TrigBurstDurStream *self)
5378 {
5379 pyo_CLEAR
5380 Py_CLEAR(self->mainPlayer);
5381 return 0;
5382 }
5383
5384 static void
5385 TrigBurstDurStream_dealloc(TrigBurstDurStream* self)
5386 {
5387 pyo_DEALLOC
5388 TrigBurstDurStream_clear(self);
5389 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
5390 Py_TYPE(self)->tp_free((PyObject*)self);
5391 }
5392
5393 static PyObject *
5394 TrigBurstDurStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
5395 {
5396 int i;
5397 PyObject *maintmp = NULL;
5398 TrigBurstDurStream *self;
5399 self = (TrigBurstDurStream *)type->tp_alloc(type, 0);
5400
5401 self->chnl = 0;
5402 self->modebuffer[0] = 0;
5403 self->modebuffer[1] = 0;
5404
5405 INIT_OBJECT_COMMON
5406 Stream_setFunctionPtr(self->stream, TrigBurstDurStream_compute_next_data_frame);
5407 self->mode_func_ptr = TrigBurstDurStream_setProcMode;
5408
5409 static char *kwlist[] = {"mainPlayer", "chnl", NULL};
5410
5411 if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
5412 Py_RETURN_NONE;
5413
5414 self->mainPlayer = (TrigBurster *)maintmp;
5415 Py_INCREF(self->mainPlayer);
5416
5417 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
5418
5419 (*self->mode_func_ptr)(self);
5420
5421 return (PyObject *)self;
5422 }
5423
5424 static PyObject * TrigBurstDurStream_getServer(TrigBurstDurStream* self) { GET_SERVER };
5425 static PyObject * TrigBurstDurStream_getStream(TrigBurstDurStream* self) { GET_STREAM };
5426 static PyObject * TrigBurstDurStream_setMul(TrigBurstDurStream *self, PyObject *arg) { SET_MUL };
5427 static PyObject * TrigBurstDurStream_setAdd(TrigBurstDurStream *self, PyObject *arg) { SET_ADD };
5428 static PyObject * TrigBurstDurStream_setSub(TrigBurstDurStream *self, PyObject *arg) { SET_SUB };
5429 static PyObject * TrigBurstDurStream_setDiv(TrigBurstDurStream *self, PyObject *arg) { SET_DIV };
5430
5431 static PyObject * TrigBurstDurStream_play(TrigBurstDurStream *self, PyObject *args, PyObject *kwds) { PLAY };
5432 static PyObject * TrigBurstDurStream_out(TrigBurstDurStream *self, PyObject *args, PyObject *kwds) { OUT };
5433 static PyObject * TrigBurstDurStream_stop(TrigBurstDurStream *self, PyObject *args, PyObject *kwds) { STOP };
5434
5435 static PyObject * TrigBurstDurStream_multiply(TrigBurstDurStream *self, PyObject *arg) { MULTIPLY };
5436 static PyObject * TrigBurstDurStream_inplace_multiply(TrigBurstDurStream *self, PyObject *arg) { INPLACE_MULTIPLY };
5437 static PyObject * TrigBurstDurStream_add(TrigBurstDurStream *self, PyObject *arg) { ADD };
5438 static PyObject * TrigBurstDurStream_inplace_add(TrigBurstDurStream *self, PyObject *arg) { INPLACE_ADD };
5439 static PyObject * TrigBurstDurStream_sub(TrigBurstDurStream *self, PyObject *arg) { SUB };
5440 static PyObject * TrigBurstDurStream_inplace_sub(TrigBurstDurStream *self, PyObject *arg) { INPLACE_SUB };
5441 static PyObject * TrigBurstDurStream_div(TrigBurstDurStream *self, PyObject *arg) { DIV };
5442 static PyObject * TrigBurstDurStream_inplace_div(TrigBurstDurStream *self, PyObject *arg) { INPLACE_DIV };
5443
5444 static PyMemberDef TrigBurstDurStream_members[] =
5445 {
5446 {"server", T_OBJECT_EX, offsetof(TrigBurstDurStream, server), 0, "Pyo server."},
5447 {"stream", T_OBJECT_EX, offsetof(TrigBurstDurStream, stream), 0, "Stream object."},
5448 {"mul", T_OBJECT_EX, offsetof(TrigBurstDurStream, mul), 0, "Mul factor."},
5449 {"add", T_OBJECT_EX, offsetof(TrigBurstDurStream, add), 0, "Add factor."},
5450 {NULL} /* Sentinel */
5451 };
5452
5453 static PyMethodDef TrigBurstDurStream_methods[] =
5454 {
5455 {"getServer", (PyCFunction)TrigBurstDurStream_getServer, METH_NOARGS, "Returns server object."},
5456 {"_getStream", (PyCFunction)TrigBurstDurStream_getStream, METH_NOARGS, "Returns stream object."},
5457 {"play", (PyCFunction)TrigBurstDurStream_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
5458 {"out", (PyCFunction)TrigBurstDurStream_out, METH_VARARGS | METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
5459 {"stop", (PyCFunction)TrigBurstDurStream_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
5460 {"setMul", (PyCFunction)TrigBurstDurStream_setMul, METH_O, "Sets oscillator mul factor."},
5461 {"setAdd", (PyCFunction)TrigBurstDurStream_setAdd, METH_O, "Sets oscillator add factor."},
5462 {"setSub", (PyCFunction)TrigBurstDurStream_setSub, METH_O, "Sets inverse add factor."},
5463 {"setDiv", (PyCFunction)TrigBurstDurStream_setDiv, METH_O, "Sets inverse mul factor."},
5464 {NULL} /* Sentinel */
5465 };
5466
5467 static PyNumberMethods TrigBurstDurStream_as_number =
5468 {
5469 (binaryfunc)TrigBurstDurStream_add, /*nb_add*/
5470 (binaryfunc)TrigBurstDurStream_sub, /*nb_subtract*/
5471 (binaryfunc)TrigBurstDurStream_multiply, /*nb_multiply*/
5472 0, /*nb_remainder*/
5473 0, /*nb_divmod*/
5474 0, /*nb_power*/
5475 0, /*nb_neg*/
5476 0, /*nb_pos*/
5477 0, /*(unaryfunc)array_abs,*/
5478 0, /*nb_nonzero*/
5479 0, /*nb_invert*/
5480 0, /*nb_lshift*/
5481 0, /*nb_rshift*/
5482 0, /*nb_and*/
5483 0, /*nb_xor*/
5484 0, /*nb_or*/
5485 0, /*nb_int*/
5486 0, /*nb_long*/
5487 0, /*nb_float*/
5488 (binaryfunc)TrigBurstDurStream_inplace_add, /*inplace_add*/
5489 (binaryfunc)TrigBurstDurStream_inplace_sub, /*inplace_subtract*/
5490 (binaryfunc)TrigBurstDurStream_inplace_multiply, /*inplace_multiply*/
5491 0, /*inplace_remainder*/
5492 0, /*inplace_power*/
5493 0, /*inplace_lshift*/
5494 0, /*inplace_rshift*/
5495 0, /*inplace_and*/
5496 0, /*inplace_xor*/
5497 0, /*inplace_or*/
5498 0, /*nb_floor_divide*/
5499 (binaryfunc)TrigBurstDurStream_div, /*nb_true_divide*/
5500 0, /*nb_inplace_floor_divide*/
5501 (binaryfunc)TrigBurstDurStream_inplace_div, /*nb_inplace_true_divide*/
5502 0, /* nb_index */
5503 };
5504
5505 PyTypeObject TrigBurstDurStreamType =
5506 {
5507 PyVarObject_HEAD_INIT(NULL, 0)
5508 "_pyo.TrigBurstDurStream_base", /*tp_name*/
5509 sizeof(TrigBurstDurStream), /*tp_basicsize*/
5510 0, /*tp_itemsize*/
5511 (destructor)TrigBurstDurStream_dealloc, /*tp_dealloc*/
5512 0, /*tp_print*/
5513 0, /*tp_getattr*/
5514 0, /*tp_setattr*/
5515 0, /*tp_as_async (tp_compare in Python 2)*/
5516 0, /*tp_repr*/
5517 &TrigBurstDurStream_as_number, /*tp_as_number*/
5518 0, /*tp_as_sequence*/
5519 0, /*tp_as_mapping*/
5520 0, /*tp_hash */
5521 0, /*tp_call*/
5522 0, /*tp_str*/
5523 0, /*tp_getattro*/
5524 0, /*tp_setattro*/
5525 0, /*tp_as_buffer*/
5526 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
5527 "TrigBurstDurStream objects. Reads a duration channel from a TrigBurster object.", /* tp_doc */
5528 (traverseproc)TrigBurstDurStream_traverse, /* tp_traverse */
5529 (inquiry)TrigBurstDurStream_clear, /* tp_clear */
5530 0, /* tp_richcompare */
5531 0, /* tp_weaklistoffset */
5532 0, /* tp_iter */
5533 0, /* tp_iternext */
5534 TrigBurstDurStream_methods, /* tp_methods */
5535 TrigBurstDurStream_members, /* tp_members */
5536 0, /* tp_getset */
5537 0, /* tp_base */
5538 0, /* tp_dict */
5539 0, /* tp_descr_get */
5540 0, /* tp_descr_set */
5541 0, /* tp_dictoffset */
5542 0, /* tp_init */
5543 0, /* tp_alloc */
5544 TrigBurstDurStream_new, /* tp_new */
5545 };
5546
5547 /************************************************************************************************/
5548 /* TrigBurstEndStream object per channel */
5549 /************************************************************************************************/
5550 typedef struct
5551 {
5552 pyo_audio_HEAD
5553 TrigBurster *mainPlayer;
5554 int chnl;
5555 int modebuffer[2];
5556 } TrigBurstEndStream;
5557
5558 static void TrigBurstEndStream_postprocessing_ii(TrigBurstEndStream *self) { POST_PROCESSING_II };
5559 static void TrigBurstEndStream_postprocessing_ai(TrigBurstEndStream *self) { POST_PROCESSING_AI };
5560 static void TrigBurstEndStream_postprocessing_ia(TrigBurstEndStream *self) { POST_PROCESSING_IA };
5561 static void TrigBurstEndStream_postprocessing_aa(TrigBurstEndStream *self) { POST_PROCESSING_AA };
5562 static void TrigBurstEndStream_postprocessing_ireva(TrigBurstEndStream *self) { POST_PROCESSING_IREVA };
5563 static void TrigBurstEndStream_postprocessing_areva(TrigBurstEndStream *self) { POST_PROCESSING_AREVA };
5564 static void TrigBurstEndStream_postprocessing_revai(TrigBurstEndStream *self) { POST_PROCESSING_REVAI };
5565 static void TrigBurstEndStream_postprocessing_revaa(TrigBurstEndStream *self) { POST_PROCESSING_REVAA };
5566 static void TrigBurstEndStream_postprocessing_revareva(TrigBurstEndStream *self) { POST_PROCESSING_REVAREVA };
5567
5568 static void
5569 TrigBurstEndStream_setProcMode(TrigBurstEndStream *self)
5570 {
5571 int muladdmode;
5572 muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
5573
5574 switch (muladdmode)
5575 {
5576 case 0:
5577 self->muladd_func_ptr = TrigBurstEndStream_postprocessing_ii;
5578 break;
5579
5580 case 1:
5581 self->muladd_func_ptr = TrigBurstEndStream_postprocessing_ai;
5582 break;
5583
5584 case 2:
5585 self->muladd_func_ptr = TrigBurstEndStream_postprocessing_revai;
5586 break;
5587
5588 case 10:
5589 self->muladd_func_ptr = TrigBurstEndStream_postprocessing_ia;
5590 break;
5591
5592 case 11:
5593 self->muladd_func_ptr = TrigBurstEndStream_postprocessing_aa;
5594 break;
5595
5596 case 12:
5597 self->muladd_func_ptr = TrigBurstEndStream_postprocessing_revaa;
5598 break;
5599
5600 case 20:
5601 self->muladd_func_ptr = TrigBurstEndStream_postprocessing_ireva;
5602 break;
5603
5604 case 21:
5605 self->muladd_func_ptr = TrigBurstEndStream_postprocessing_areva;
5606 break;
5607
5608 case 22:
5609 self->muladd_func_ptr = TrigBurstEndStream_postprocessing_revareva;
5610 break;
5611 }
5612 }
5613
5614 static void
5615 TrigBurstEndStream_compute_next_data_frame(TrigBurstEndStream *self)
5616 {
5617 int i;
5618 MYFLT *tmp;
5619 int offset = self->chnl * self->bufsize;
5620 tmp = TrigBurster_getEndBuffer((TrigBurster *)self->mainPlayer);
5621
5622 for (i = 0; i < self->bufsize; i++)
5623 {
5624 self->data[i] = tmp[i + offset];
5625 }
5626
5627 (*self->muladd_func_ptr)(self);
5628 }
5629
5630 static int
5631 TrigBurstEndStream_traverse(TrigBurstEndStream *self, visitproc visit, void *arg)
5632 {
5633 pyo_VISIT
5634 Py_VISIT(self->mainPlayer);
5635 return 0;
5636 }
5637
5638 static int
5639 TrigBurstEndStream_clear(TrigBurstEndStream *self)
5640 {
5641 pyo_CLEAR
5642 Py_CLEAR(self->mainPlayer);
5643 return 0;
5644 }
5645
5646 static void
5647 TrigBurstEndStream_dealloc(TrigBurstEndStream* self)
5648 {
5649 pyo_DEALLOC
5650 TrigBurstEndStream_clear(self);
5651 Py_TYPE(self->stream)->tp_free((PyObject*)self->stream);
5652 Py_TYPE(self)->tp_free((PyObject*)self);
5653 }
5654
5655 static PyObject *
5656 TrigBurstEndStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
5657 {
5658 int i;
5659 PyObject *maintmp = NULL;
5660 TrigBurstEndStream *self;
5661 self = (TrigBurstEndStream *)type->tp_alloc(type, 0);
5662
5663 self->chnl = 0;
5664 self->modebuffer[0] = 0;
5665 self->modebuffer[1] = 0;
5666
5667 INIT_OBJECT_COMMON
5668 Stream_setFunctionPtr(self->stream, TrigBurstEndStream_compute_next_data_frame);
5669 self->mode_func_ptr = TrigBurstEndStream_setProcMode;
5670
5671 static char *kwlist[] = {"mainPlayer", "chnl", NULL};
5672
5673 if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist, &maintmp, &self->chnl))
5674 Py_RETURN_NONE;
5675
5676 self->mainPlayer = (TrigBurster *)maintmp;
5677 Py_INCREF(self->mainPlayer);
5678
5679 PyObject_CallMethod(self->server, "addStream", "O", self->stream);
5680
5681 (*self->mode_func_ptr)(self);
5682
5683 return (PyObject *)self;
5684 }
5685
5686 static PyObject * TrigBurstEndStream_getServer(TrigBurstEndStream* self) { GET_SERVER };
5687 static PyObject * TrigBurstEndStream_getStream(TrigBurstEndStream* self) { GET_STREAM };
5688 static PyObject * TrigBurstEndStream_setMul(TrigBurstEndStream *self, PyObject *arg) { SET_MUL };
5689 static PyObject * TrigBurstEndStream_setAdd(TrigBurstEndStream *self, PyObject *arg) { SET_ADD };
5690 static PyObject * TrigBurstEndStream_setSub(TrigBurstEndStream *self, PyObject *arg) { SET_SUB };
5691 static PyObject * TrigBurstEndStream_setDiv(TrigBurstEndStream *self, PyObject *arg) { SET_DIV };
5692
5693 static PyObject * TrigBurstEndStream_play(TrigBurstEndStream *self, PyObject *args, PyObject *kwds) { PLAY };
5694 static PyObject * TrigBurstEndStream_out(TrigBurstEndStream *self, PyObject *args, PyObject *kwds) { OUT };
5695 static PyObject * TrigBurstEndStream_stop(TrigBurstEndStream *self, PyObject *args, PyObject *kwds) { STOP };
5696
5697 static PyObject * TrigBurstEndStream_multiply(TrigBurstEndStream *self, PyObject *arg) { MULTIPLY };
5698 static PyObject * TrigBurstEndStream_inplace_multiply(TrigBurstEndStream *self, PyObject *arg) { INPLACE_MULTIPLY };
5699 static PyObject * TrigBurstEndStream_add(TrigBurstEndStream *self, PyObject *arg) { ADD };
5700 static PyObject * TrigBurstEndStream_inplace_add(TrigBurstEndStream *self, PyObject *arg) { INPLACE_ADD };
5701 static PyObject * TrigBurstEndStream_sub(TrigBurstEndStream *self, PyObject *arg) { SUB };
5702 static PyObject * TrigBurstEndStream_inplace_sub(TrigBurstEndStream *self, PyObject *arg) { INPLACE_SUB };
5703 static PyObject * TrigBurstEndStream_div(TrigBurstEndStream *self, PyObject *arg) { DIV };
5704 static PyObject * TrigBurstEndStream_inplace_div(TrigBurstEndStream *self, PyObject *arg) { INPLACE_DIV };
5705
5706 static PyMemberDef TrigBurstEndStream_members[] =
5707 {
5708 {"server", T_OBJECT_EX, offsetof(TrigBurstEndStream, server), 0, "Pyo server."},
5709 {"stream", T_OBJECT_EX, offsetof(TrigBurstEndStream, stream), 0, "Stream object."},
5710 {"mul", T_OBJECT_EX, offsetof(TrigBurstEndStream, mul), 0, "Mul factor."},
5711 {"add", T_OBJECT_EX, offsetof(TrigBurstEndStream, add), 0, "Add factor."},
5712 {NULL} /* Sentinel */
5713 };
5714
5715 static PyMethodDef TrigBurstEndStream_methods[] =
5716 {
5717 {"getServer", (PyCFunction)TrigBurstEndStream_getServer, METH_NOARGS, "Returns server object."},
5718 {"_getStream", (PyCFunction)TrigBurstEndStream_getStream, METH_NOARGS, "Returns stream object."},
5719 {"play", (PyCFunction)TrigBurstEndStream_play, METH_VARARGS | METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
5720 {"out", (PyCFunction)TrigBurstEndStream_out, METH_VARARGS | METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
5721 {"stop", (PyCFunction)TrigBurstEndStream_stop, METH_VARARGS | METH_KEYWORDS, "Stops computing."},
5722 {"setMul", (PyCFunction)TrigBurstEndStream_setMul, METH_O, "Sets oscillator mul factor."},
5723 {"setAdd", (PyCFunction)TrigBurstEndStream_setAdd, METH_O, "Sets oscillator add factor."},
5724 {"setSub", (PyCFunction)TrigBurstEndStream_setSub, METH_O, "Sets inverse add factor."},
5725 {"setDiv", (PyCFunction)TrigBurstEndStream_setDiv, METH_O, "Sets inverse mul factor."},
5726 {NULL} /* Sentinel */
5727 };
5728
5729 static PyNumberMethods TrigBurstEndStream_as_number =
5730 {
5731 (binaryfunc)TrigBurstEndStream_add, /*nb_add*/
5732 (binaryfunc)TrigBurstEndStream_sub, /*nb_subtract*/
5733 (binaryfunc)TrigBurstEndStream_multiply, /*nb_multiply*/
5734 0, /*nb_remainder*/
5735 0, /*nb_divmod*/
5736 0, /*nb_power*/
5737 0, /*nb_neg*/
5738 0, /*nb_pos*/
5739 0, /*(unaryfunc)array_abs,*/
5740 0, /*nb_nonzero*/
5741 0, /*nb_invert*/
5742 0, /*nb_lshift*/
5743 0, /*nb_rshift*/
5744 0, /*nb_and*/
5745 0, /*nb_xor*/
5746 0, /*nb_or*/
5747 0, /*nb_int*/
5748 0, /*nb_long*/
5749 0, /*nb_float*/
5750 (binaryfunc)TrigBurstEndStream_inplace_add, /*inplace_add*/
5751 (binaryfunc)TrigBurstEndStream_inplace_sub, /*inplace_subtract*/
5752 (binaryfunc)TrigBurstEndStream_inplace_multiply, /*inplace_multiply*/
5753 0, /*inplace_remainder*/
5754 0, /*inplace_power*/
5755 0, /*inplace_lshift*/
5756 0, /*inplace_rshift*/
5757 0, /*inplace_and*/
5758 0, /*inplace_xor*/
5759 0, /*inplace_or*/
5760 0, /*nb_floor_divide*/
5761 (binaryfunc)TrigBurstEndStream_div, /*nb_true_divide*/
5762 0, /*nb_inplace_floor_divide*/
5763 (binaryfunc)TrigBurstEndStream_inplace_div, /*nb_inplace_true_divide*/
5764 0, /* nb_index */
5765 };
5766
5767 PyTypeObject TrigBurstEndStreamType =
5768 {
5769 PyVarObject_HEAD_INIT(NULL, 0)
5770 "_pyo.TrigBurstEndStream_base", /*tp_name*/
5771 sizeof(TrigBurstEndStream), /*tp_basicsize*/
5772 0, /*tp_itemsize*/
5773 (destructor)TrigBurstEndStream_dealloc, /*tp_dealloc*/
5774 0, /*tp_print*/
5775 0, /*tp_getattr*/
5776 0, /*tp_setattr*/
5777 0, /*tp_as_async (tp_compare in Python 2)*/
5778 0, /*tp_repr*/
5779 &TrigBurstEndStream_as_number, /*tp_as_number*/
5780 0, /*tp_as_sequence*/
5781 0, /*tp_as_mapping*/
5782 0, /*tp_hash */
5783 0, /*tp_call*/
5784 0, /*tp_str*/
5785 0, /*tp_getattro*/
5786 0, /*tp_setattro*/
5787 0, /*tp_as_buffer*/
5788 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
5789 "TrigBurstEndStream objects. Reads a duration channel from a TrigBurster object.", /* tp_doc */
5790 (traverseproc)TrigBurstEndStream_traverse, /* tp_traverse */
5791 (inquiry)TrigBurstEndStream_clear, /* tp_clear */
5792 0, /* tp_richcompare */
5793 0, /* tp_weaklistoffset */
5794 0, /* tp_iter */
5795 0, /* tp_iternext */
5796 TrigBurstEndStream_methods, /* tp_methods */
5797 TrigBurstEndStream_members, /* tp_members */
5798 0, /* tp_getset */
5799 0, /* tp_base */
5800 0, /* tp_dict */
5801 0, /* tp_descr_get */
5802 0, /* tp_descr_set */
5803 0, /* tp_dictoffset */
5804 0, /* tp_init */
5805 0, /* tp_alloc */
5806 TrigBurstEndStream_new, /* tp_new */
5807 };