Skip to content

Commit

Permalink
Roland DJ-202: Map key shift functions
Browse files Browse the repository at this point in the history
- Key-Lock (long) + Param{Up,Down} ⇒ Shift musical key
- Key-Lock (long) + ParamUp + ParamDown ⇒ Reset musical key
  • Loading branch information
eigengrau committed Apr 11, 2018
1 parent 0bd482c commit 037cd2b
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
48 changes: 46 additions & 2 deletions res/controllers/Roland_DJ-202-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,34 @@ DJ202.Deck = function (deckNumbers, offset) {
},
});

this.paramUp = function (channel, control, value, status, group) {
if (value) {
this.paramUp.active = true;
if (this.paramDown.active) {
script.triggerControl(group, 'reset_key');
} else {
var adjust = engine.getValue(group, 'pitch_adjust');
engine.setValue(group, 'pitch_adjust', Math.min(7, adjust + 1));
}
} else {
this.paramUp.active = false;
}
};

this.paramDown = function (channel, control, value, status, group) {
if (value) {
this.paramDown.active = true;
if (this.paramUp.active) {
script.triggerControl(group, 'reset_key');
} else {
var adjust = engine.getValue(group, 'pitch_adjust');
engine.setValue(group, 'pitch_adjust', Math.max(-7, adjust - 1));
}
} else {
this.paramDown.active = false;
}
};

this.keylock = new components.Button({
midi: [0x90 + offset, 0x0D],
shiftOffset: 1,
Expand All @@ -70,9 +98,25 @@ DJ202.Deck = function (deckNumbers, offset) {
outKey: 'keylock',
currentRangeIndex: 0,
unshift: function () {
this.type = components.Button.prototype.types.toggle;
this.input = components.Button.prototype.input;
this.input = function (channel, control, value, status, group) {
if (value) {
this.longPressTimer = engine.beginTimer(this.longPressTimeout, function () {
this.is_held = true;
}, true);
} else {
if (!this.is_held) {
script.toggleControl(this.group, this.outKey);
};
engine.stopTimer(this.longPressTimer);
this.is_held = false;
}
};
this.inKey = 'keylock';
this.outKey = 'keylock';
// The DJ-202 disables the keylock LED when the button is pressed
// shifted. Restore the LED when shift is released.
this.send(this.outGetValue());
midi.sendShortMsg(0x84, 0x00, 0x3);
},
shift: function () {
this.inKey = 'rateRange';
Expand Down
17 changes: 17 additions & 0 deletions res/controllers/Roland_DJ-202.midi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,23 @@
<script-binding/>
</options>
</control>
<control>
<group>[Channel1]</group>
<key>DJ202.leftDeck.paramDown</key>
<status>0x94</status>
<midino>0x44</midino>
<options>
<script-binding/>
</options>
</control> <control>
<group>[Channel1]</group>
<key>DJ202.leftDeck.paramUp</key>
<status>0x94</status>
<midino>0x43</midino>
<options>
<script-binding/>
</options>
</control>
<control>
<group>[Channel1]</group>
<key>DJ202.leftDeck.tapBPM.input</key>
Expand Down

0 comments on commit 037cd2b

Please sign in to comment.