forked from MircoL/steinberg-cc121-bitwig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SteinbergCC121.transport.js
executable file
·60 lines (54 loc) · 1.59 KB
/
SteinbergCC121.transport.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
function initTransport() {
// Creating views
transport = host.createTransport();
application = host.createApplication();
// Publishing observers
transport.isPlaying().addValueObserver(function(play) {
if (play) {
sendMidi(144, NOTE.PLAY, LIGHT_ON);
} else {
sendMidi(144, NOTE.PLAY, LIGHT_OFF);
}
});
transport.isArrangerRecordEnabled().addValueObserver(function(record) {
if (record) {
sendMidi(144, NOTE.RECORD, LIGHT_ON);
} else {
sendMidi(144, NOTE.RECORD, LIGHT_OFF);
}
})
transport.isArrangerLoopEnabled().addValueObserver(function(loop) {
if (loop) {
sendMidi(144, NOTE.LOOP, LIGHT_ON);
} else {
sendMidi(144, NOTE.LOOP, LIGHT_OFF);
}
})
return onMidiTransport;
}
function onMidiTransport(status, data1, data2) {
// Check if message is MIDI CC
if (isChannelController(status)) {
} else if (isNoteOn(status) && data2 > 0) {
switch (data1) {
case NOTE.PLAY:
transport.play(); // And Pause
break;
case NOTE.STOP:
transport.stop();
break;
case NOTE.RECORD:
transport.record();
break;
case NOTE.TOSTART:
transport.rewind();
break;
case NOTE.LOOP:
transport.toggleLoop();
break;
case NOTE.TOEND:
transport.fastForward();
break;
}
}
}