forked from MircoL/steinberg-cc121-bitwig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SteinbergCC121.channel.js
executable file
·117 lines (107 loc) · 3.84 KB
/
SteinbergCC121.channel.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
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
// Factor to speed up panning by with job button
var JOGFACTOR_PANNING = 4;
function initChannel() {
// Creating views
trackBank = host.createMainTrackBank(1, 1, 1);
arrangerCursorTrack = host.createArrangerCursorTrack(1, 1);
trackBank.followCursorTrack(arrangerCursorTrack);
transport = host.createTransport();
application = host.createApplication();
// Publishing observers
trackBank.getChannel(0).mute().addValueObserver(function(isMuted) {
if (isMuted) {
sendMidi(144, NOTE.MUTE, LIGHT_ON);
} else {
sendMidi(144, NOTE.MUTE, LIGHT_OFF);
}
});
trackBank.getChannel(0).solo().addValueObserver(function(isSolo) {
if (isSolo) {
sendMidi(144, NOTE.SOLO, LIGHT_ON);
} else {
sendMidi(144, NOTE.SOLO, LIGHT_OFF);
}
});
transport.isArrangerAutomationWriteEnabled().addValueObserver(function(isAutomationWrite) {
if (isAutomationWrite) {
sendMidi(144, NOTE.AUTOMATIONWRITE, LIGHT_ON);
} else {
sendMidi(144, NOTE.AUTOMATIONWRITE, LIGHT_OFF);
}
});
transport.isAutomationOverrideActive().addValueObserver(function(isAutomationOverride) {
if (isAutomationOverride) {
sendMidi(144, NOTE.AUTOMATIONREAD, LIGHT_ON);
} else {
sendMidi(144, NOTE.AUTOMATIONREAD, LIGHT_OFF);
}
});
trackBank.getTrack(0).arm().addValueObserver(function(isArmed) {
if (isArmed) {
sendMidi(144, NOTE.RECORDARM, LIGHT_ON);
} else {
sendMidi(144, NOTE.RECORDARM, LIGHT_OFF);
}
});
trackBank.getTrack(0).monitor().addValueObserver(function(isMonitored) {
if (isMonitored) {
sendMidi(144, NOTE.INPUTMONITOR, LIGHT_ON);
} else {
sendMidi(144, NOTE.INPUTMONITOR, LIGHT_OFF);
}
});
trackBank.getChannel(0).volume().value().addValueObserver(function(volumeValue) {
var LSB = (volumeValue * 16383) % 128;
var MSB = (volumeValue * 16383) / 128;
sendMidi(224, LSB, MSB);
});
return onMidiChannel;
}
function onMidiChannel(status, data1, data2) {
// Check if message is MIDI CC
if (isChannelController(status)) {
var changeValue = midiCcValueToInteger(data2);
if (isJogActive)
changeValue = JOGFACTOR_PANNING * changeValue;
switch (data1) {
case CC.PAN:
trackBank.getChannel(0).pan().value().inc(changeValue, ENCODER_RESOLUTION);
break;
}
} else if (isNoteOn(status) && data2 > 0) {
switch (data1) {
case NOTE.CHANNELSELECTRIGHT:
arrangerCursorTrack.selectNext();
break;
case NOTE.CHANNELSELECTLEFT:
arrangerCursorTrack.selectPrevious();
break;
case NOTE.MUTE:
trackBank.getChannel(0).mute().toggle();
break;
case NOTE.SOLO:
trackBank.getChannel(0).solo().toggle();
break;
case NOTE.AUTOMATIONWRITE:
transport.isArrangerAutomationWriteEnabled().toggle();
break;
case NOTE.AUTOMATIONREAD:
transport.resetAutomationOverrides();
break;
case NOTE.RECORDARM:
trackBank.getTrack(0).arm().toggle();
break;
case NOTE.INPUTMONITOR:
trackBank.getTrack(0).monitor().toggle();
break;
case NOTE.EBUTTON:
application.toggleInspector();
break;
case NOTE.OPENVSTI:
application.toggleDevices();
break;
}
} else if (status == 224) {
trackBank.getChannel(0).volume().value().set(data2 * 128 + data1, 16383);
}
}