blob: ba7344521b791812a96fc0de912ef7b1e8392bd7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/*
* Base class for controller events
*/
public class GenEvent extends Event {
class Port extends Step {
fun void
update(GenEvent @ev, string control)
{
while (ev => now)
if (control => ev.isControl)
ev.getFloat(-1, 1) => next;
/* never reached */
}
}
/* symbolic control name */
string control;
/* normalized control value between [0, 1] */
float value;
fun int
isControl(string c)
{
return control == c;
}
/*
* Create and return UGen that generates a control's value,
* normalized between [-1, 1]
*/
fun Step @
getPort(string control)
{
Port p;
spork ~ p.update(this, control);
return p;
}
/*
* Getter functions to scale `value'
*/
fun float
getFloat()
{
return value;
}
fun float
getFloat(float max)
{
return max*value;
}
fun float
getFloat(float min, float max)
{
return min + (max - min)*value;
}
fun dur
getDur(dur max)
{
return max*value;
}
fun dur
getDur(dur min, dur max)
{
return min + (max - min)*value;
}
fun int
getBool()
{
return value $ int;
}
}
|