-
Notifications
You must be signed in to change notification settings - Fork 0
/
AIIOM.navigation.js
54 lines (48 loc) · 1.11 KB
/
AIIOM.navigation.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
/*
Implemented:
- Prev. track
- Next track
- Scroll tracks
*/
function initNavigation() {
return onMidiNavigation;
}
function onMidiNavigation(status, data1, data2) {
// Check if message is MIDI CC
if (isChannelController(status)) {
switch (data1) {
case BUTTON_06_PRETRACK:
handleNavigationPre(data2);
break;
case BUTTON_07_NEXTTRACK:
handleNavigationNext(data2);
break;
case KNOB_01_SCROLL:
handleNavigationScrollTracks(data2);
break;
}
}
}
function handleNavigationPre(value) {
if (buttonValueToBoolean(value)) {
cursorTrack.selectPrevious();
}
}
function handleNavigationNext(value) {
if (buttonValueToBoolean(value)) {
cursorTrack.selectNext();
}
}
function handleNavigationScrollTracks(value) {
if (isIncrementKnob01(value)) {
cursorTrack.selectNext();
} else {
cursorTrack.selectPrevious();
}
}
function isIncrementKnob01(value) {
if (value <= 63) {
return false;
}
return true;
}