-
Notifications
You must be signed in to change notification settings - Fork 0
/
RedRobot.control.js
78 lines (55 loc) · 2.13 KB
/
RedRobot.control.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
//@ts-check
loadAPI(16);
// Remove this if you want to be able to use deprecated methods without causing script to stop.
// This is useful during development.
host.setShouldFailOnDeprecatedUse(true);
function makeIndexedFunction(index, f) {
return function (value) {
f(index, value);
}
}
const log = host.println
const MAX_TRACKS = 100;
var NUM_SCENES = 100;
host.defineController("SentinelAgency", "RedRobot", "0.1", "d6a28869-a23d-46ac-a830-52be7c79e8ff", "sphere42");
let deviceBank, cursorDevice, transport, cursorTrack;
let app;
let dev;
let basePath = "C:\\Program Files\\Bitwig Studio\\4.2.2\\Library\\devices\\";
let MassiveBasePath = "C:\\Users\\john\\Documents\\Bitwig Studio\\Library\\Presets\\Massive\\"
let clips;
let trackBank
function init() {
app = host.createApplication()
host.scheduleTask(run, 10);
cursorTrack = host.createCursorTrack('Selected Track', 'Selected Track', 1, 1, true);
clips = cursorTrack.clipLauncherSlotBank();
trackBank = host.createTrackBank(MAX_TRACKS, 0, NUM_SCENES, true);
for (let i = 0; i < MAX_TRACKS; i++) {
const replaceStot = trackBank.getItemAt(i).createDeviceBank(1).getItemAt(0).replaceDeviceInsertionPoint();
var clipNames = [];
var track = trackBank.getItemAt(i);
track.subscribe();
const clips = track.clipLauncherSlotBank()
clips.addPlaybackStateObserver((index, playback, isQueued) => {
if (playback == 1 && isQueued == true) {
log("playback: " + clipNames[index] + " " + playback + " " + isQueued);
replaceStot.insertFile(MassiveBasePath + clipNames[index] + ".bwpreset");
}
});
clips.addNameObserver((index, name) => {
clipNames[index] = name;
});
}
cursorDevice = cursorTrack.createCursorDevice("Selected Device", "Selected Device", 0, CursorDeviceFollowMode.FIRST_INSTRUMENT);
deviceBank = cursorTrack.createDeviceBank(8);
dev = deviceBank.getDevice(0);
}
function run() {
dev.replaceDeviceInsertionPoint().insertFile(basePath + "Polymer.bwdevice");
}
function flush() {
// TODO: Flush any output to your controller here.
}
function exit() {
}