-
Notifications
You must be signed in to change notification settings - Fork 0
/
AIIOM.track.js
70 lines (62 loc) · 1.82 KB
/
AIIOM.track.js
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
/*
Implemented:
- Track solo
- Track mute
- Arm recording
*/
function initTrack() {
// Publishing observers
trackBank.getItemAt(0).mute().addValueObserver(function (isMuted) {
if (isMuted) {
host.getMidiOutPort(0).sendMidi(MIDI_CC, BUTTON_02_MUTE, BUTTON_ON);
} else {
host.getMidiOutPort(0).sendMidi(MIDI_CC, BUTTON_02_MUTE, BUTTON_OFF);
}
});
trackBank.getItemAt(0).solo().addValueObserver(function (isSolo) {
if (isSolo) {
host.getMidiOutPort(0).sendMidi(MIDI_CC, BUTTON_01_SOLO, BUTTON_ON);
} else {
host.getMidiOutPort(0).sendMidi(MIDI_CC, BUTTON_01_SOLO, BUTTON_OFF);
}
});
trackBank.getItemAt(0).arm().addValueObserver(function (isArmed) {
if (isArmed) {
host.getMidiOutPort(0).sendMidi(MIDI_CC, BUTTON_11_ARMREC, BUTTON_ON);
} else {
host.getMidiOutPort(0).sendMidi(MIDI_CC, BUTTON_11_ARMREC, BUTTON_OFF);
}
});
return onMidiTrack;
}
function onMidiTrack(status, data1, data2) {
// Check if message is MIDI CC
if (isChannelController(status)) {
switch (data1) {
case BUTTON_01_SOLO:
handleTrackSolo(data2);
break;
case BUTTON_02_MUTE:
handleTrackMute(data2);
break;
case BUTTON_11_ARMREC:
handleTrackArm(data2);
break;
}
}
}
function handleTrackSolo(value) {
if (buttonValueToBoolean(value)) {
trackBank.getItemAt(0).solo().toggle();
}
}
function handleTrackMute(value) {
if (buttonValueToBoolean(value)) {
trackBank.getItemAt(0).mute().toggle();
}
}
function handleTrackArm(value) {
if (buttonValueToBoolean(value)) {
trackBank.getItemAt(0).arm().toggle();
}
}