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
|
/*
* Oscilloscope (jack.scope) helpers
*/
public class Oscope {
static OscSend @jack_scope;
/*
* "signal" or "embed"
*/
fun static void
mode(string m)
{
jack_scope.startMsg("/mode", "s");
m => jack_scope.addString;
}
/*
* "dot", "fill" or "line"
*/
fun static void
style(string s)
{
jack_scope.startMsg("/style", "s");
s => jack_scope.addString;
}
fun static void
frames(dur f)
{
// <<< "set frame size:", (f / samp) $ int >>>;
jack_scope.startMsg("/frames", "i");
(f / samp) $ int => jack_scope.addInt;
}
fun static void
delay(dur d)
{
// <<< "set delay length:", d / ms >>>;
jack_scope.startMsg("/delay", "f");
d / ms => jack_scope.addFloat;
}
/*
* "sample delay" in "embed" mode
* Can this be a ChucK duration???
*/
fun static void
embed(int em)
{
jack_scope.startMsg("/embed", "i");
em => jack_scope.addInt;
}
fun static void
incr(float i)
{
jack_scope.startMsg("/incr", "f");
i => jack_scope.addFloat;
}
}
/* initialization */
new OscSend @=> Oscope.jack_scope;
Oscope.jack_scope.setHost("localhost", 57140);
"signal" => Oscope.mode;
"line" => Oscope.style;
512::samp => Oscope.frames;
100::ms => Oscope.delay;
/*
* connect oscilloscope Bus channels to dedicated output ports that are patched
* to jack.scope
*/
for (0 => int i; i < Bus.oscope.cap(); i++)
Bus.oscope[i] => dac.chan(4 + i);
/*
* jack.scope configuration
*/
"oscope" => NanoEvent.init @=> NanoEvent @nanoev;
while (nanoev => now) {
if ("modeToggle" => nanoev.isControl) {
if (nanoev.getBool())
"embed" => Oscope.mode;
else
"signal" => Oscope.mode;
} else if ("fillToggle" => nanoev.isControl) {
if (nanoev.getBool())
"fill" => Oscope.style;
else
"line" => Oscope.style;
} else if ("frameSlider" => nanoev.isControl) {
nanoev.getDur(512::samp, 2::second) => Oscope.frames;
} else if ("delayKnob" => nanoev.isControl) {
nanoev.getDur(50::ms, second) => Oscope.delay;
}
}
|