-
Notifications
You must be signed in to change notification settings - Fork 4
/
MaschineJam.control.js
746 lines (649 loc) · 21.2 KB
/
MaschineJam.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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
/**
* Remote Control Script for Maschine JAM and Bitwig Studio
*
* One main principle of this script is that it tries to stay as close as possible to
* the workflow of Maschine JAM in the Maschine Software. This also means that every label on
* the controller is assigned to an appropriate function in Bitwig.
*
* i.e. SHIFT + Group G = Save Project
* SHIFT + Button Matrix Button (1,1) = Undo etc.
*
* The REC Button is not assigned to the Arrange View Record Button but tries to emulate the way the REC Button works in Maschine.
*
* @author Eric Ahrens
*/
/**
* Added touch tracking hack: any active macro whose label ends with " TFX" will be pulled to zero upon touchstrip release.
* This more or less replicates Maschine's PERFORM effects.
* Preconfigured "Touch FX layer" preset is included.
*/
loadAPI(1);
host.defineController("Native Instruments Felix", "WIP script", "0.8", "cdbbe630-9edb-11e8-b568-0800200c9a66");
host.defineMidiPorts(1, 1);
host.addDeviceNameBasedDiscoveryPair(["Maschine Jam - 1"], ["Maschine Jam - 1"]);
host.addDeviceNameBasedDiscoveryPair(["Maschine Jam - 2"], ["Maschine Jam - 2"]);
host.addDeviceNameBasedDiscoveryPair(["Maschine Jam - 3"], ["Maschine Jam - 3"]);
host.addDeviceNameBasedDiscoveryPair(["Maschine Jam - 4"], ["Maschine Jam - 4"]);
host.addDeviceNameBasedDiscoveryPair(["Maschine Jam - 1 Input"], ["Maschine Jam - 1 Output"]);
host.addDeviceNameBasedDiscoveryPair(["Maschine Jam - 2 Input"], ["Maschine Jam - 2 Output"]);
host.addDeviceNameBasedDiscoveryPair(["Maschine Jam - 3 Input"], ["Maschine Jam - 3 Output"]);
host.addDeviceNameBasedDiscoveryPair(["Maschine Jam - 4 Input"], ["Maschine Jam - 4 Output"]);
load("Constants.js");
load("JamMode.js");
load("ClipMode.js");
load("PadMode.js");
load("StepMode.js");
load("StepView.js");
load("ModifierBank.js");
load("Button.js");
load("ButtonGrid.js");
load("Touchstrip.js");
load("StepPositionView.js");
load("ControlMapping.js");
load("ApplicationControl.js");
load("TrackHandler.js");
load("MainKnobControl.js");
load("TrackView.js");
load("SceneLaunchView.js");
load("ClipLaunchView.js");
load("NoteLayoutManager.js");
load("TransportHandler.js");
load("DrumPadView.js");
load("PatternLengthView.js");
load("TouchView.js");
/**
*
* TODO
* 1. Combine Drum Pad View to Step Mode an make it switchable
* 2. Fix Sends Assingment bug
* 3. Consider setting Selection INdex to 1 upon entering drum Mode again
**/
var updateQueue = []; //Queue for updating MIDI in batches, so controller doesn't get stuck
var shiftReceivers = [];
var shutdown = false;
var controls = new ControlMapping();
var modifiers = new ModifierBank();
/** @type {GlobalClipView} */
var globalClipView = null;
var selectAndLaunch = true;
/** @type{ApplicationControl}*/
var applicationControl = null;
var transport = null;
var gGlipOrientation = ORIENTATION.TrackBased;
function init() {
var numTracks = 8;
var numScenes = 8;
var numSends = 8;
host.getMidiInPort(0).setMidiCallback(onMidi);
host.getMidiInPort(0).setSysexCallback(onSysex);
noteInput = host.getMidiInPort(0).createNoteInput("Maschine Jam - 1", "80????", "90????");
initLeftButtons();
/** @type {Track} */
var cursorTrack = host.createArrangerCursorTrack(2, 16);
/** @type {Device} */
/** @type {CursorDevice} */
var cursorDevice = cursorTrack.createCursorDevice();
var clip = host.createCursorClip(8, 128);
applicationControl = new ApplicationControl(clip);
patternLengthView = new PatternLengthView(clip);
globalClipView = new GlobalClipView(patternLengthView, clip);
var trackHandler = new TrackHandler(cursorTrack, 16, cursorDevice); // Handler for Cursor Track
transport = new TransportHandler(trackHandler, cursorDevice);
var trackBank = host.createMainTrackBank(numTracks, numSends, numScenes);
var trackBankContainer = new TrackBankContainer(trackBank);
var efxTrackBankContainer = new EffectBankContainer(host.createEffectTrackBank(7, numScenes), host.createMasterTrack(numScenes));
var trackViewContainer = new TrackViewContainer(trackBankContainer, efxTrackBankContainer);
var sceneView = new SceneLaunchView(trackBank, numScenes, numTracks);
var noteView = gNoteViewManager.createNoteLayoutView(noteInput);
var drumpadView = new DrumPadView(noteInput, cursorTrack);
var clipView = new ClipLaunchView(trackBankContainer);
clipView.setIndication(true);
var cliplaunchMode = new ClipMode(clipView, trackViewContainer, sceneView, trackViewContainer.getMixerView().trackStates());
var padMode = new PadMode(noteView, drumpadView, trackViewContainer, sceneView, clip, cursorDevice, sceneView);
var stepMode = new StepMode(noteView, drumpadView, trackViewContainer, trackHandler, clip,cursorDevice, sceneView);
var efxClipView = new ClipLaunchView(efxTrackBankContainer);
var effectMode = new ClipMode(efxClipView, trackViewContainer, sceneView, trackViewContainer.getEffectView().trackStates());
currentMode = cliplaunchMode;
currentMode.enter();
trackBankContainer.clipView = clipView;
efxTrackBankContainer.clipView = clipView;
controls.sliderBank = new SliderModeHandler(trackBankContainer, efxTrackBankContainer, numTracks, cursorDevice, trackHandler);
var mainKnobControl = new MainKnobKontrol(cursorTrack, transport.transport(), clip, cursorDevice);
var modeHandler = new ModeHandler(cliplaunchMode, padMode, stepMode, effectMode, clip, trackHandler, trackViewContainer);
TrackModifierInit(trackViewContainer, mainKnobControl, patternLengthView);
var project = host.getProject();
var rootTrack = project.getRootTrackGroup();
initCursorTrack(cursorTrack, cursorDevice, padMode, stepMode);
controls.init();
var stopAllButton = controls.createButton(MAIN_BUTTONS.IN_BUTTON);
stopAllButton.setCallback(function (value) {
stopAllButton.sendValue(value);
if (value > 0) {
rootTrack.stop();
}
});
var primaryDevice = cursorTrack.createCursorDevice("Primary", 0);
primaryDevice.hasDrumPads().addValueObserver(function (hasPads) {
modeHandler.setCrrentHasDrumPads(hasPads);
});
shiftReceivers.push(mainKnobControl);
shiftReceivers.push(modifiers);
shiftReceivers.push(transport);
shiftReceivers.push(modeHandler);
handleblink();
host.scheduleTask(handleBatchUpdate, null, 1);
println(" #### Maschine JAM Version 0.7 ######");
notificationSettings = host.getNotificationSettings();
host.scheduleTask(function () {
var unsIsEnabeld = notificationSettings.getUserNotificationsEnabled();
unsIsEnabeld.set(false);
}, null, 100);
}
/**
* @param {PatternLengthView} patternLengthView View for showing and adjusting Pattern Length
* @param {Clip} clip
*/
function GlobalClipView(patternLengthView, clip) {
var clipSelected = false;
/** @type {Clip} */
var clipTrackType = "EMPTY";
var track = clip.getTrack();
this.duplicateContent = function () {
clip.duplicateContent();
};
track.exists().addValueObserver(function (value) {
clipSelected = value;
});
track.addTrackTypeObserver(16, "EMPTY", function (type) {
clipTrackType = type;
});
this.clipColorChanged = function (color) {
patternLengthView.setColor(color);
};
this.isClipSelected = function () {
return clipSelected;
};
this.isInstrumentTrack = function () {
return clipTrackType === "Instrument";
};
this.emptySlotSelected = function () {
return clipTrackType === "EMPTY";
};
}
/**
* @param {TrackBank} trackBank
* */
function TrackBankContainer(trackBank) {
this.bank = trackBank;
this.size = 8;
this.clipView = null;
}
TrackBankContainer.prototype.selectClipInSlot = function (trackIndex) {
if (this.clipView) {
this.clipView.selectClipInSlot(trackIndex);
}
};
TrackBankContainer.prototype.getTrack = function (index) {
return this.bank.getChannel(index);
};
TrackBankContainer.prototype.hasAuxChannel = function () {
return true;
};
/**
* @param {TrackBank} trackBank
* */
function EffectBankContainer(trackBank, masterTrack) {
TrackBankContainer.call(this, trackBank);
this.masterTrack = masterTrack;
}
EffectBankContainer.prototype.getTrack = function (index) {
return index < 7 ? this.bank.getChannel(index) : this.masterTrack;
};
EffectBankContainer.prototype.hasAuxChannel = function () {
return true;
};
EffectBankContainer.prototype.selectClipInSlot = function (trackIndex) {
if (this.clipView) {
this.clipView.selectClipInSlot(trackIndex);
}
};
/**
* @param {Track} cursorTrack
* @param {Device} cursorDevice
* @param {NoteView} noteView
*/
function initCursorTrack(cursorTrack, cursorDevice, padMode, stepMode) {
var nameMapping = {};
var nameMappingSize = 0;
cursorDevice.hasDrumPads().addValueObserver(function (hasPads) {
stepMode.setHasDrumPads(hasPads);
});
/** @type {DrumPadBank|Channel} drumPadBank */
var drumPadBank = cursorDevice.createDrumPadBank(16);
drumPadBank.setChannelScrollStepSize(4);
function DrumPad() {
/**
* @param {Channel} channel
*/
function registerDrumPadChannel(index, channel) {
channel.addColorObserver(function (red, green, blue) {
var color = convertColor(red, green, blue);
});
}
for (var i = 0; i < 16; i++) {
var channel = drumPadBank.getChannel(i);
registerDrumPadChannel(i, channel);
}
drumPadBank.addChannelScrollPositionObserver(function (pos) {
println(" DP Scroll " + pos);
}, -1);
}
// DrumPad();
cursorTrack.addNoteObserver(function (noteon, note, velocity) {
currentMode.receiveNote(noteon, note, velocity);
});
cursorTrack.addPitchNamesObserver(function (key, name) {
if (key in nameMapping) {
if (name === null) {
delete nameMapping[key];
nameMappingSize--;
} else {
nameMapping[key] = name;
nameMappingSize++;
}
} else if (name !== null) {
nameMapping[key] = name;
nameMappingSize++;
}
padMode.updatePitchNames(nameMappingSize, nameMapping, key, name);
// stepMode.updatePitchNames(nameMappingSize, nameMapping,key, name);
});
cursorTrack.addColorObserver(function (red, green, blue) {
var color = convertColor(red, green, blue);
padMode.updateTrackColor(color);
controls.sliderBank.updateTrackColor(color);
});
}
var aninamtionCycle = 0;
/**
* Task to handle Flashing
*/
function handleblink() {
currentMode.handleBlink();
host.scheduleTask(handleblink, null, 50);
}
/**
* @param {string} which
* @param {string} param
**/
function debug(which, param) {
var app = applicationControl.getApplication();
switch (which) {
case "action":
/** @type {Action} */
var actions = app.getActions();
for (i = 0; i < actions.length; i++) {
var id = actions[i].getId();
if (!param || id.match(param)) {
println(" [" + id + "]");
}
}
break;
}
}
function handleBatchUpdate() {
actions = 10;
while (updateQueue.length > 0 && actions > 0) {
if (shutdown) {
return;
}
var message = updateQueue.shift();
host.getMidiOutPort(0).sendMidi(message[0], message[1], message[2]);
actions--;
}
host.scheduleTask(handleBatchUpdate, null, 1);
}
/**
* Midi Message is stored in the queue that is then polled in handleBatchUpdate
*/
function queueMidi(status, data1, data2) {
if (data2 === undefined) {
println(" Undefined Midi Data ");
return;
}
updateQueue.push([status, data1, data2]);
}
/**
* @param {TrackView} trackView
* @param {MainKnobControl} mainKnob Main Knob Control
* @param {PatternLengthView} patternLengthView Pattern
*/
function TrackModifierInit(trackView, mainKnob, patternLengthView) {
var muteButton = controls.createButton(TRANSPORT_SECTION.MUTE);
muteButton.setCallback(function (value) {
muteButton.sendValue(value);
if (value === 0) {
trackView.toDefaultMode();
} else {
trackView.enterMuteMode();
}
});
var soloButton = controls.createButton(TRANSPORT_SECTION.SOLO);
patternLengthView.setExitCallback(function () {
mainKnob.exitPatternLenMode(soloButton);
soloButton.sendValue(0);
});
soloButton.setCallback(function (value) {
if (modifiers.isShiftDown()) {
if (value > 0 && patternLengthView.canEnter()) {
mainKnob.enterPatternLenMode(soloButton, function () {
currentMode.exitIntermediateView();
});
currentMode.switchToIntermediateView(patternLengthView);
applicationControl.showNoteEditor();
}
} else {
if (mainKnob.inPatternLenMode()) {
if (value > 0) {
mainKnob.exitPatternLenMode(soloButton);
currentMode.exitIntermediateView();
soloButton.sendValue(0);
}
} else {
if (value === 0) {
trackView.toDefaultMode();
soloButton.sendValue(value);
} else {
trackView.enterSoloMode();
soloButton.sendValue(value);
}
}
}
});
var gridButton = controls.createButton(TRANSPORT_SECTION.GRID);
gridButton.setCallback(function (value) {
if (value === 0) {
if (!trackView.inArmMode()) {
gridButton.sendValue(mainKnob.inGridMode() ? 127 : 0);
}
} else {
if (modifiers.isShiftDown()) {
if (trackView.inArmMode()) {
trackView.toDefaultMode();
gridButton.sendValue(mainKnob.inGridMode() ? 127 : 0);
} else if (trackView.canArm()) {
trackView.enterArmMode();
gridButton.sendValue(127);
}
} else {
if (trackView.inArmMode()) {
trackView.toDefaultMode();
} else if (!mainKnob.inGridMode()) {
mainKnob.enterGridMode(gridButton);
} else {
mainKnob.exitGridMode();
}
gridButton.sendValue(mainKnob.inGridMode() ? 127 : 0);
}
}
});
}
/**
*
* Handles switch between the different Modes
*
* 1. Clip Launcher Mode
* 2. Pad Mode
* 3. Step Mode
* 4. Effect Launcher Mode (Not yet implemented)
*
* @param {ClipMode} cliplaunchMode
* @param {PadMode} padMode
* @param {StepMode} stepMode
* @param {EffectMode} effectMode
* @param {Clip} cursorClip
* @param {TrackHandler} trackHandler
* @param {TrackViewContainer} trackViewContainer
*
*/
function ModeHandler(cliplaunchMode, padMode, stepMode, effectMode, cursorClip, trackHandler, trackViewContainer) {
var stepButton = controls.createButton(MAIN_BUTTONS.STEP);
var padButton = controls.createButton(MAIN_BUTTONS.PAD);
var fxButton = controls.createButton(MAIN_BUTTONS.PERFORM);
var cursorTrackHasPads = false;
var currentTrackType = "EMPTY";
padMode.selbutton = padButton;
stepMode.selbutton = stepButton;
cliplaunchMode.selbutton = new EmptyButton();
effectMode.selbutton = fxButton;
padButton.sendValue(0);
stepButton.sendValue(0);
stepMode.setExitHandler(forceExit);
function forceExit() {
if (currentMode === stepMode || currentMode == padMode) {
currentMode.selbutton.sendValue(0);
currentMode.exit();
cliplaunchMode.enter();
toClipTrackContol();
currentMode = cliplaunchMode;
}
}
trackHandler.getCursorTrack().addTrackTypeObserver(10, "EMPTY", function (type) {
currentTrackType = type;
if (type !== "Instrument") {
forceExit();
}
});
this.setCrrentHasDrumPads = function (value) {
cursorTrackHasPads = value;
if (currentMode === stepMode) {
if (stepMode.isInDrumMode() && !cursorTrackHasPads) {
stepMode.setToPianoMode();
stepMode.enter();
} else if (!stepMode.isInDrumMode() && cursorTrackHasPads) {
stepMode.setToDrumMode();
stepMode.enter();
}
} else if (currentMode === padMode) {
if (padMode.inDrumView() && !cursorTrackHasPads) {
padMode.setToNoteView();
padMode.enter();
} else if (!padMode.inDrumView() && cursorTrackHasPads) {
padMode.setToDrumView();
padMode.enter();
}
}
};
this.notifyShift = function (value) {
currentMode.notifyShift(value);
};
stepButton.setCallback(function (value) {
if (value > 0) {
if (currentMode === stepMode) {
if (modifiers.isSelectDown()) {
trackHandler.selectNextSlotInTrack();
} else if (modifiers.isShiftDown()) {
if (stepMode.isInDrumMode()) {
stepMode.setToPianoMode();
} else {
stepMode.setToDrumMode();
}
stepMode.enter();
} else {
currentMode.selbutton.sendValue(0);
currentMode.exit();
cliplaunchMode.enter();
toClipTrackContol();
currentMode = cliplaunchMode;
}
} else {
if (!globalClipView.isClipSelected()) {
var status = trackHandler.getTrackStatus();
if (status.selected === -1) {
host.showPopupNotification(" No content to be edited. Corresponding track needs to be selected");
return;
} else {
trackHandler.createClip();
}
} else if (!globalClipView.isInstrumentTrack() || currentTrackType !== "Instrument") {
if(!globalClipView.isInstrumentTrack()) {
host.showPopupNotification(" Track of selected clip is not an Instrument track");
} else {
host.showPopupNotification(" Selected track is not an Instrument track");
}
return;
}
stepButton.sendValue(127);
currentMode.selbutton.sendValue(0);
currentMode.exit();
if (cursorTrackHasPads) {
stepMode.setToDrumMode();
} else {
stepMode.setToPianoMode();
}
stepMode.enter();
currentMode = stepMode;
}
}
});
padButton.setCallback(function (value) {
if (value > 0) {
if (modifiers.isSelectDown() && currentMode === padMode) {
padMode.selectionModAction();
} else if (currentMode === padMode) {
if (modifiers.isShiftDown()) {
if (padMode.inDrumView()) {
padMode.setToNoteView();
} else {
padMode.setToDrumView();
}
} else {
currentMode.selbutton.sendValue(0);
currentMode.exit();
cliplaunchMode.enter();
toClipTrackContol();
currentMode = cliplaunchMode;
}
} else {
padButton.sendValue(127);
currentMode.selbutton.sendValue(0);
currentMode.exit();
if (cursorTrackHasPads) {
padMode.setToDrumView();
} else {
padMode.setToNoteView();
}
padMode.enter();
currentMode = padMode;
}
}
});
function toClipTrackContol() {
if (controls.sliderBank.inEffectMode()) {
controls.sliderBank.switchToTrackMode();
cliplaunchMode.setIndication(true);
effectMode.setIndication(false);
trackViewContainer.toMixerView();
}
}
fxButton.setCallback(function (value) {
if (value === 0) {
return;
}
if (currentMode === effectMode) {
currentMode.selbutton.sendValue(0);
currentMode.exit();
cliplaunchMode.enter();
currentMode = cliplaunchMode;
controls.sliderBank.switchToTrackMode();
trackViewContainer.toMixerView();
cliplaunchMode.setIndication(true);
effectMode.setIndication(false);
} else {
currentMode.selbutton.sendValue(0);
currentMode.exit();
effectMode.enter();
trackViewContainer.toEffectView();
currentMode = effectMode;
currentMode.selbutton.sendValue(127);
controls.sliderBank.switchToEffectMode();
cliplaunchMode.setIndication(false);
effectMode.setIndication(true);
}
});
}
function animate() {
if (aninamtionCycle > 7) {
controls.buttonMatrix.showPattern(Pattern1, aninamtionCycle);
return;
}
controls.buttonMatrix.showPattern(Pattern1, aninamtionCycle);
aninamtionCycle++;
host.scheduleTask(animate, null, 400);
}
function initLeftButtons() {
controls.setButtonMatrixCallback(
function (sender, row, col, value, notenr) {
currentMode.handleEvent(sender, row, col, value, notenr);
});
var dirPadUp = controls.createButton(DirectionPad.TOP);
var dirPadLeft = controls.createButton(DirectionPad.LEFT);
var dirPadRight = controls.createButton(DirectionPad.RIGHT);
var dirPadDown = controls.createButton(DirectionPad.DOWN);
dirPadUp.setCallback(
function (value) {
if (value !== 0) {
currentMode.navigate(DirectionPad.TOP);
}
});
dirPadLeft.setCallback(
function (value) {
if (value !== 0) {
currentMode.navigate(DirectionPad.LEFT);
}
});
dirPadRight.setCallback(
function (value) {
modifiers.setDpadRightDown(value);
if (value !== 0) {
currentMode.navigate(DirectionPad.RIGHT);
}
});
dirPadDown.setCallback(
function (value) {
if (value !== 0) {
currentMode.navigate(DirectionPad.DOWN);
}
});
dirPadUp.sendValue(0, true);
dirPadDown.sendValue(0, true);
dirPadLeft.sendValue(0, true);
dirPadRight.sendValue(0, true);
}
function onMidi(status, data1, data2) {
if (!controls.handleMidi(status, data1, data2)) {
//println(" Got MIDI " + (status&0xF) + " " + data1 + " " + data2 + " " + (status>>4));
println(" Unmapped MIDI " + (status & 0xF) + " " + data1 + " " + data2 + " " + (status >> 4));
}
}
function onSysex(data) {
var i;
if (data === "f000210915004d5000014d01f7") {
for (i = 0; i < shiftReceivers.length; i++) {
shiftReceivers[i].notifyShift(true);
}
} else if (data === "f000210915004d5000014d00f7") {
for (i = 0; i < shiftReceivers.length; i++) {
shiftReceivers[i].notifyShift(false);
}
} else if (data === "f000210915004d5000014601f7") {
currentMode.update();
controls.fullUpdate();
} else {
println(" RECEIVED SysEx = " + data);
}
}
function exit() {
println(" ==== Shutting Down ===== ");
controls.exit();
}