-
Notifications
You must be signed in to change notification settings - Fork 1
/
PIONEER_DDJ-S1.midi.js
66 lines (54 loc) · 1.66 KB
/
PIONEER_DDJ-S1.midi.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
const BUTTON_PRESSED = 127;
const BUTTON_RELEASED = 0;
function DBG(str) {
print("[PionerDDJS1] " + str);
}
var PionerDDJS1 = {};
PionerDDJS1.init = function(id, debugging) {
DBG("Hello from PionerDDJS1!");
}
PionerDDJS1.trackBrowse = function(channel, control, value, status, group) {
DBG('value: ' + value)
if (value === 1) {
engine.setValue('[Library]', 'MoveDown', 1)
} else if (value === 127) {
engine.setValue('[Library]', 'MoveUp', 1)
}
}
var JOG_SCALE = 0.1
PionerDDJS1.wheelTurn = function(channel, control, value, status, group) {
var newValue;
if (value < 64) {
newValue = value;
} else {
newValue = value - 128;
}
newValue = newValue * JOG_SCALE
var deckNumber = script.deckFromGroup(group);
if (engine.isScratching(deckNumber)) {
engine.scratchTick(deckNumber, newValue); // Scratch!
} else {
engine.setValue(group, 'jog', newValue); // Pitch bend
}
}
PionerDDJS1.wheelTouch = function(channel, control, value, status, group) {
var deckNumber = script.deckFromGroup(group);
if (value === 0x7F) { // Some wheels send 0x90 on press and release, so you need to check the value
var alpha = 1.0/8;
var beta = alpha/32;
engine.scratchEnable(deckNumber, 128, 33+1/3, alpha, beta);
} else { // If button up
engine.scratchDisable(deckNumber);
}
}
PionerDDJS1.loopDoubleHalve = function(channel, control, value, status, group) {
var deckNumber = script.deckFromGroup(group);
if (value === 0x7F) {
engine.setValue(group, 'loop_halve', 1);
} else {
engine.setValue(group, 'loop_double', 1);
}
}
PionerDDJS1.shutdown = function() {
DBG("Goodbye from PionerDDJS1!");
}