-
Notifications
You must be signed in to change notification settings - Fork 1
/
DMXLight.sc
122 lines (101 loc) · 2.28 KB
/
DMXLight.sc
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
DMX framework for supercollider
(c) 2007-9 Marije Baalman (nescivi)
GNU/GPL v2.0 or later
*/
// This contains a set of higher level classes
// Classes for a specific light, or a group of lights, or a complete set
DMXSet{
var <>name;
var <groups;
*new{ |name|
^super.new.init.name_( name );
}
init{
groups = ();
}
addGroup{ |group|
groups.put( group.name, group );
}
removeGroup{ |group|
groups.removeAt( group.name );
}
}
DMXGroup{
var <>name;
var <lights;
*new{ |name|
^super.new.init.name_( name );
}
init{
lights = ();
}
addLight{ |light|
lights.put( light.name, light );
}
removeLight{ |light|
lights.removeAt( light.name );
}
}
DMXLight{
var <>name;
var <properties;
var <channels;
*new{ |name|
^super.new.init.name_( name );
}
init{
properties = ();
channels = ();
}
setStrobe{ |chans,vals|
vals = vals ? [0,0,0];
properties.put( \duration, vals[0] );
properties.put( \intensity, vals[1] );
properties.put( \rate, vals[2] );
channels.put( \duration, chans[0] );
channels.put( \intensity, chans[1] );
channels.put( \rate, chans[2] );
DMX.map.put( name++\_++\duration, chans[0] );
DMX.map.put( name++\_++\intensity, chans[1] );
DMX.map.put( name++\_++\rate, chans[2] );
}
setGob{ |chans,vals|
/* set to useful stuff here
vals = vals ? [0,0,0];
properties.put( \duration, vals[0] );
properties.put( \intensity, vals[1] );
properties.put( \rate, vals[2] );
channels.put( \duration, chans[0] );
channels.put( \intensity, chans[1] );
channels.put( \rate, chans[2] );
DMX.map.put( name++\_++\duration, chans[0] );
DMX.map.put( name++\_++\intensity, chans[1] );
DMX.map.put( name++\_++\rate, chans[2] );
*/
}
setLight{ |chans,vals|
vals = vals ? [0,0];
properties.put( \intensity, vals[0] );
properties.put( \color, vals[1] );
channels.put( \intensity, chans[0] );
channels.put( \color, chans[1] );
DMX.map.put( name++\_++\intensity, chans[0] );
DMX.map.put( name++\_++\color, chans[1] );
}
set{ |key,val|
properties.put( key, val );
}
}
// with DMXColor you can store colormaps corresponding to the needed DMX value to get the specified color
DMXColor{
classvar <>maps;
classvar <>currentMap;
*initClass{
maps = ();
currentMap = ();
}
*get{ |color|
^currentMap.at( color );
}
}