-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNK2Instrument.sc
executable file
·84 lines (73 loc) · 1.92 KB
/
NK2Instrument.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
NK2Instrument : NK2Reader {
var
<parent,
<>slots,
<>proxy_space,
<type = 'inst',
<>activate_text;
*new {
|
parent = nil,
server = nil,
proxy_space = nil,
writer = nil,
mididef = nil
|
^super.new.initNK2Instrument(parent, server, proxy_space, writer, mididef);
}
initNK2Instrument {
|
arg_parent,
arg_server,
arg_proxy_space,
arg_writer,
arg_mididef
|
var writer;
parent = arg_parent;
if (parent != nil, {
server = parent.server;
proxy_space = parent.proxy_space;
writer = parent.writer;
}, {
arg_server ?? {
Server.local ?? {
^"NK2Instrument: Si no tiene «parent» por lo menos debe tener «server»".warn;
};
arg_server = Server.local;
"NK2Instrument: No tiene «parent» usando default «server: s»".postln;
};
server = arg_server;
proxy_space = arg_proxy_space ?? ProxySpace(server, name: \ProxySpaceInstrument, clock: TempoClock.default);
writer = arg_writer ?? NK2Writer(server);
});
super.initNK2Reader(server, writer, arg_mididef);
this.initDefaultsEv();
this.nodeProxy.ar;
}
initKnobs {
knobs = Array.fill(cant_controls, { |i| NK2Knob(server, matched_led: mbuttons[i].led) });
}
initDefaultsEv {
backwards_button.press = {
parent.activate
};
}
activate {
sbuttons.do({ |button| if(button.val, { button.led.on }, { button.led.off }); });
mbuttons.do({ |button| if(button.val, { button.led.on }, { button.led.off }); });
rbuttons.do({ |button| if(button.val, { button.led.on }, { button.led.off }); });
faders.do({ |c| c.matched = false });
knobs.do({ |c| c.matched = false });
this.restartLedControlButtons();
activate_text ?? { activate_text = "Instrumento activado" };
activate_text.postln;
^super.activate;
}
nodeProxy {
^proxy_space[uid.asSymbol]
}
nodeProxy_{ |source|
proxy_space[uid.asSymbol].source = source;
}
}