2
Copyright (C) 2005 Fons Adriaensen <fons.adriaensen@skynet.be>
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
Division::Division (Asection *asect, float fsam) :
38
for (int i = 0; i < NRANKS; i++) _ranks [i] = 0;
42
Division::~Division (void)
47
void Division::process (void)
53
memset (_buff, 0, NCHANN * PERIOD * sizeof (float));
54
for (i = 0; i < _nrank; i++) _ranks [i]->play (1);
61
t = sqrtf (_c * _c + _s * _s);
64
if ((_trem == 2) && (fabsf (_s) < 0.05f))
78
d = (g - _gain) / PERIOD;
81
q = _asect->get_wptr ();
83
for (i = 0; i < PERIOD; i++)
86
q [0 * PERIOD * MIXLEN] += p [0 * PERIOD] * g;
87
q [1 * PERIOD * MIXLEN] += p [1 * PERIOD] * g;
88
q [2 * PERIOD * MIXLEN] += p [2 * PERIOD] * g;
89
q [3 * PERIOD * MIXLEN] += p [3 * PERIOD] * g;
97
void Division::set_rank (int ind, Rankwave *W, int pan, int del)
102
if (C) { W->_nmask = C->_cmask; delete C; }
106
del = (int)(1e-3f * del * _fsam / PERIOD);
107
if (del > 31) del = 31;
108
W->set_param (_buff, del, pan);
109
if (_nrank < ++ind) _nrank = ind;
113
void Division::update (int note, int mask)
118
for (r = 0; r < _nrank; r++)
123
if (mask & W->_cmask) W->note_on (note + 36);
124
else W->note_off (note + 36);
130
void Division::update (unsigned char *keys)
132
int d, r, m, n, n0, n1;
136
for (r = 0; r < _nrank; r++)
139
if ((W->_cmask ^ W->_nmask) & 127)
149
for (n = n0; n <= n1; n++)
151
if (*k++ & m) W->note_on (n);
152
else W->note_off (n);
157
W->_cmask = W->_nmask;
162
void Division::set_div_mask (int bits)
169
for (r = 0; r < _nrank; r++)
172
if (W->_nmask & 128) W->_nmask |= bits;
177
void Division::clr_div_mask (int bits)
184
for (r = 0; r < _nrank; r++)
187
if (W->_nmask & 128) W->_nmask &= ~bits;
192
void Division::set_rank_mask (int ind, int bits)
194
Rankwave *W = _ranks [ind];
196
if (bits == 128) bits |= _dmask;
201
void Division::clr_rank_mask (int ind, int bits)
203
Rankwave *W = _ranks [ind];
205
if (bits == 128) bits |= _dmask;