1
/*************************************************************************
2
* Copyright 2010 Olivier Belanger *
1
/**************************************************************************
2
* Copyright 2009-2015 Olivier Belanger *
4
4
* This file is part of pyo, a python module to help digital signal *
5
* processing script creation. *
5
* processing script creation. *
7
7
* pyo is free software: you can redistribute it and/or modify *
8
* it under the terms of the GNU General Public License as published by *
9
* the Free Software Foundation, either version 3 of the License, or *
10
* (at your option) any later version. *
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. *
12
12
* pyo is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
15
* GNU Lesser General Public License for more details. *
17
* You should have received a copy of the GNU General Public License *
18
* along with pyo. If not, see <http://www.gnu.org/licenses/>. *
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
19
*************************************************************************/
21
21
#include <Python.h>
78
78
switch (muladdmode) {
80
80
self->muladd_func_ptr = Noise_postprocessing_ii;
83
83
self->muladd_func_ptr = Noise_postprocessing_ai;
86
86
self->muladd_func_ptr = Noise_postprocessing_revai;
89
89
self->muladd_func_ptr = Noise_postprocessing_ia;
92
92
self->muladd_func_ptr = Noise_postprocessing_aa;
95
95
self->muladd_func_ptr = Noise_postprocessing_revaa;
98
98
self->muladd_func_ptr = Noise_postprocessing_ireva;
101
101
self->muladd_func_ptr = Noise_postprocessing_areva;
104
104
self->muladd_func_ptr = Noise_postprocessing_revareva;
152
152
self->mode_func_ptr = Noise_setProcMode;
154
154
static char *kwlist[] = {"mul", "add", NULL};
156
156
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OO", kwlist, &multmp, &addtmp))
160
160
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
164
164
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
167
167
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
169
169
Server_generateSeed((Server *)self->server, NOISE_ID);
171
171
self->seed = rand();
173
173
(*self->mode_func_ptr)(self);
175
175
return (PyObject *)self;
178
178
static PyObject * Noise_getServer(Noise* self) { GET_SERVER };
179
179
static PyObject * Noise_getStream(Noise* self) { GET_STREAM };
180
static PyObject * Noise_setMul(Noise *self, PyObject *arg) { SET_MUL };
181
static PyObject * Noise_setAdd(Noise *self, PyObject *arg) { SET_ADD };
182
static PyObject * Noise_setSub(Noise *self, PyObject *arg) { SET_SUB };
183
static PyObject * Noise_setDiv(Noise *self, PyObject *arg) { SET_DIV };
180
static PyObject * Noise_setMul(Noise *self, PyObject *arg) { SET_MUL };
181
static PyObject * Noise_setAdd(Noise *self, PyObject *arg) { SET_ADD };
182
static PyObject * Noise_setSub(Noise *self, PyObject *arg) { SET_SUB };
183
static PyObject * Noise_setDiv(Noise *self, PyObject *arg) { SET_DIV };
185
185
static PyObject * Noise_play(Noise *self, PyObject *args, PyObject *kwds) { PLAY };
186
186
static PyObject * Noise_out(Noise *self, PyObject *args, PyObject *kwds) { OUT };
368
368
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
370
370
switch (muladdmode) {
372
372
self->muladd_func_ptr = PinkNoise_postprocessing_ii;
375
375
self->muladd_func_ptr = PinkNoise_postprocessing_ai;
378
378
self->muladd_func_ptr = PinkNoise_postprocessing_revai;
381
381
self->muladd_func_ptr = PinkNoise_postprocessing_ia;
384
384
self->muladd_func_ptr = PinkNoise_postprocessing_aa;
387
387
self->muladd_func_ptr = PinkNoise_postprocessing_revaa;
390
390
self->muladd_func_ptr = PinkNoise_postprocessing_ireva;
393
393
self->muladd_func_ptr = PinkNoise_postprocessing_areva;
396
396
self->muladd_func_ptr = PinkNoise_postprocessing_revareva;
434
434
PyObject *multmp=NULL, *addtmp=NULL;
436
436
self = (PinkNoise *)type->tp_alloc(type, 0);
438
438
self->c0 = self->c1 = self->c2 = self->c3 = self->c4 = self->c5 = self->c6 = 0.0;
439
439
self->modebuffer[0] = 0;
440
440
self->modebuffer[1] = 0;
442
442
INIT_OBJECT_COMMON
443
443
Stream_setFunctionPtr(self->stream, PinkNoise_compute_next_data_frame);
444
444
self->mode_func_ptr = PinkNoise_setProcMode;
446
446
static char *kwlist[] = {"mul", "add", NULL};
448
448
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OO", kwlist, &multmp, &addtmp))
452
452
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
456
456
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
459
459
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
461
461
(*self->mode_func_ptr)(self);
463
463
Server_generateSeed((Server *)self->server, PINKNOISE_ID);
465
465
return (PyObject *)self;
468
468
static PyObject * PinkNoise_getServer(PinkNoise* self) { GET_SERVER };
469
469
static PyObject * PinkNoise_getStream(PinkNoise* self) { GET_STREAM };
470
static PyObject * PinkNoise_setMul(PinkNoise *self, PyObject *arg) { SET_MUL };
471
static PyObject * PinkNoise_setAdd(PinkNoise *self, PyObject *arg) { SET_ADD };
472
static PyObject * PinkNoise_setSub(PinkNoise *self, PyObject *arg) { SET_SUB };
473
static PyObject * PinkNoise_setDiv(PinkNoise *self, PyObject *arg) { SET_DIV };
470
static PyObject * PinkNoise_setMul(PinkNoise *self, PyObject *arg) { SET_MUL };
471
static PyObject * PinkNoise_setAdd(PinkNoise *self, PyObject *arg) { SET_ADD };
472
static PyObject * PinkNoise_setSub(PinkNoise *self, PyObject *arg) { SET_SUB };
473
static PyObject * PinkNoise_setDiv(PinkNoise *self, PyObject *arg) { SET_DIV };
475
475
static PyObject * PinkNoise_play(PinkNoise *self, PyObject *args, PyObject *kwds) { PLAY };
476
476
static PyObject * PinkNoise_out(PinkNoise *self, PyObject *args, PyObject *kwds) { OUT };
628
628
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
630
630
switch (muladdmode) {
632
632
self->muladd_func_ptr = BrownNoise_postprocessing_ii;
635
635
self->muladd_func_ptr = BrownNoise_postprocessing_ai;
638
638
self->muladd_func_ptr = BrownNoise_postprocessing_revai;
641
641
self->muladd_func_ptr = BrownNoise_postprocessing_ia;
644
644
self->muladd_func_ptr = BrownNoise_postprocessing_aa;
647
647
self->muladd_func_ptr = BrownNoise_postprocessing_revaa;
650
650
self->muladd_func_ptr = BrownNoise_postprocessing_ireva;
653
653
self->muladd_func_ptr = BrownNoise_postprocessing_areva;
656
656
self->muladd_func_ptr = BrownNoise_postprocessing_revareva;
695
695
PyObject *multmp=NULL, *addtmp=NULL;
696
696
BrownNoise *self;
697
697
self = (BrownNoise *)type->tp_alloc(type, 0);
699
699
self->modebuffer[0] = 0;
700
700
self->modebuffer[1] = 0;
701
701
self->y1 = self->c1 = self->c2 = 0.0;
703
703
INIT_OBJECT_COMMON
704
704
Stream_setFunctionPtr(self->stream, BrownNoise_compute_next_data_frame);
705
705
self->mode_func_ptr = BrownNoise_setProcMode;
707
707
static char *kwlist[] = {"mul", "add", NULL};
709
709
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OO", kwlist, &multmp, &addtmp))
713
713
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
717
717
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
720
720
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
722
722
b = 2.0 - MYCOS(TWOPI * 20.0 / self->sr);
723
723
self->c2 = (b - MYSQRT(b * b - 1.0));
724
724
self->c1 = 1.0 - self->c2;
726
726
(*self->mode_func_ptr)(self);
728
728
Server_generateSeed((Server *)self->server, BROWNNOISE_ID);
730
730
return (PyObject *)self;
733
733
static PyObject * BrownNoise_getServer(BrownNoise* self) { GET_SERVER };
734
734
static PyObject * BrownNoise_getStream(BrownNoise* self) { GET_STREAM };
735
static PyObject * BrownNoise_setMul(BrownNoise *self, PyObject *arg) { SET_MUL };
736
static PyObject * BrownNoise_setAdd(BrownNoise *self, PyObject *arg) { SET_ADD };
737
static PyObject * BrownNoise_setSub(BrownNoise *self, PyObject *arg) { SET_SUB };
738
static PyObject * BrownNoise_setDiv(BrownNoise *self, PyObject *arg) { SET_DIV };
735
static PyObject * BrownNoise_setMul(BrownNoise *self, PyObject *arg) { SET_MUL };
736
static PyObject * BrownNoise_setAdd(BrownNoise *self, PyObject *arg) { SET_ADD };
737
static PyObject * BrownNoise_setSub(BrownNoise *self, PyObject *arg) { SET_SUB };
738
static PyObject * BrownNoise_setDiv(BrownNoise *self, PyObject *arg) { SET_DIV };
740
740
static PyObject * BrownNoise_play(BrownNoise *self, PyObject *args, PyObject *kwds) { PLAY };
741
741
static PyObject * BrownNoise_out(BrownNoise *self, PyObject *args, PyObject *kwds) { OUT };