-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArc.sc
97 lines (67 loc) · 2.17 KB
/
Arc.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
Arc : MonoM {
var scaleFactor;
*new { | prefix, rot |
^super.new.initArc(prefix, rot);
}
initArc { | your_prefix, your_rotation |
prefix = your_prefix;
rot = your_rotation;
case
{ rot == 0 } { scaleFactor = 0 }
{ rot == 90 } { scaleFactor = 16 }
{ rot == 180 } { scaleFactor = 32 }
{ rot == 270 } { scaleFactor = 48 }
{ ((rot == 0) or: (rot == 90) or: (rot == 180) or: (rot == 270)).not }
{
"Did not choose valid rotation. Using default: 0".warn;
scaleFactor = 0;
rot = 0;
};
}
ringset { | enc, led, lev |
oscout.sendMsg(prefix++"/ring/set", enc,
(led + scaleFactor).wrap(0, 63),
lev);
}
ringall { | enc, lev |
oscout.sendMsg(prefix++"/ring/all", enc, lev);
}
ringmap { | enc, larr |
scaleFactor.do({
larr = larr.shift(1, larr @ (larr.size - 1));
});
oscout.sendMsg(prefix++"/ring/map", enc, *larr);
}
ringrange { | enc, led1, led2, lev |
oscout.sendMsg(prefix++"/ring/range", enc, led1+scaleFactor, led2+scaleFactor, lev);
}
// exercise caution when changing rotation
// after change, your led positions may not be desirable.
rot_ { arg degree;
rot = degree;
case
{ rot == 0 } { scaleFactor = 0 }
{ rot == 90 } { scaleFactor = 16 }
{ rot == 180 } { scaleFactor = 32 }
{ rot == 270 } { scaleFactor = 48 }
{ (rot != 0) or: (rot != 90) or: (rot != 180) or: (rot != 270) } {
"Did not choose valid rotation (0, 90, 180, 270). Using default: 0.".warn;
scaleFactor = 0;
};
// flash one LED indicating north position
for(0, 3, { arg i; this.ringall(i, 0);});
4.do({
for(0, 3, { arg i;
for(0, 30, { arg brightness;
this.ringset(i, 0, brightness.fold(0, 15));
});
});
});
}
darkness {
for(0, 3, { arg i; this.ringall(i, 0);});
discovery.free;
oscout.disconnect;
seroscnet.disconnect;
}
}