Skip to content

Commit

Permalink
Roland DJ-202: Map shifted FX inputs
Browse files Browse the repository at this point in the history
Since the shift button applies both to the FX racks as well as the decks, the
button is now a property of the controller instance.

- Shift+FX₁{1…4} ⇒ Cycle selected effect
- Shift+Level-knob ⇒ Control FX rack super knob
  • Loading branch information
eigengrau committed Apr 10, 2018
1 parent 6d07b1e commit 2c08261
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 31 deletions.
91 changes: 61 additions & 30 deletions res/controllers/Roland_DJ-202-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ DJ202.tempoRange = [0.08, 0.16, 0.5]

DJ202.init = function () {

DJ202.shiftButton = function (channel, control, value, status, group) {
DJ202.deck.concat(DJ202.effectUnit).forEach(
value
? function (module) { module.shift(); }
: function (module) { module.unshift(); }
);
};

DJ202.leftDeck = new DJ202.Deck([1,3], 0);
DJ202.rightDeck = new DJ202.Deck([2,4], 1);

DJ202.deck = [DJ202.leftDeck, DJ202.rightDeck];

DJ202.effectUnit = [];
DJ202.effectUnit[1] = new DJ202.EffectUnit(1);
DJ202.effectUnit[2] = new DJ202.EffectUnit(2);
Expand Down Expand Up @@ -43,14 +52,6 @@ DJ202.Deck = function (deckNumbers, offset) {
components.Deck.call(this, deckNumbers);
channel = offset+1;

this.shiftButton = function (channel, control, value, status, group) {
if (value === 127) {
this.shift();
} else {
this.unshift();
}
};

this.loadTrack = new components.Button({
midi: [0x9F, 0x02 + offset],
unshift: function () {
Expand Down Expand Up @@ -237,6 +238,20 @@ DJ202.EffectUnit = function (unitNumber) {
this.group = '[EffectRack1_EffectUnit' + unitNumber + ']';
engine.setValue(this.group, 'show_focus', 1);

this.shift = function () {
this.button.forEach(function (button) {
button.shift();
});
this.knob.shift();
};

this.unshift = function () {
this.button.forEach(function (button) {
button.unshift();
});
this.knob.unshift();
};

this.EffectButton = function (buttonNumber) {
this.buttonNumber = buttonNumber;

Expand All @@ -246,33 +261,43 @@ DJ202.EffectUnit = function (unitNumber) {
components.Button.call(this);
};
this.EffectButton.prototype = new components.Button({
input: function (channel, control, value, status) {
if (this.isPress(channel, control, value, status)) {
this.isLongPressed = false;
this.longPressTimer = engine.beginTimer(this.longPressTimeout, function () {
var effectGroup = '[EffectRack1_EffectUnit' + unitNumber + '_Effect' + this.buttonNumber + ']';
script.toggleControl(effectGroup, 'enabled');
this.isLongPressed = true;
}, true);
} else {
if (!this.isLongPressed) {
var focusedEffect = engine.getValue(eu.group, 'focused_effect');
if (focusedEffect === this.buttonNumber) {
engine.setValue(eu.group, 'focused_effect', 0);
} else {
engine.setValue(eu.group, 'focused_effect', this.buttonNumber);
unshift: function() {
this.input = function (channel, control, value, status) {
if (this.isPress(channel, control, value, status)) {
this.isLongPressed = false;
this.longPressTimer = engine.beginTimer(this.longPressTimeout, function () {
var effectGroup = '[EffectRack1_EffectUnit' + unitNumber + '_Effect' + this.buttonNumber + ']';
script.toggleControl(effectGroup, 'enabled');
this.isLongPressed = true;
}, true);
} else {
if (!this.isLongPressed) {
var focusedEffect = engine.getValue(eu.group, 'focused_effect');
if (focusedEffect === this.buttonNumber) {
engine.setValue(eu.group, 'focused_effect', 0);
} else {
engine.setValue(eu.group, 'focused_effect', this.buttonNumber);
}
}
this.isLongPressed = false;
engine.stopTimer(this.longPressTimer);
}
this.isLongPressed = false;
engine.stopTimer(this.longPressTimer);
}
this.outKey = 'focused_effect';
this.output = function (value, group, control) {
this.send((value === this.buttonNumber) ? this.on : this.off);
};
this.sendShifted = true;
this.shiftOffset = 0x0B;
},
outKey: 'focused_effect',
output: function (value, group, control) {
this.send((value === this.buttonNumber) ? this.on : this.off);
},
sendShifted: true,
shiftOffset: 0x0B,
shift: function () {
this.input = function (channel, control, value, status) {
var group = '[EffectRack1_EffectUnit' + unitNumber + '_Effect' + this.buttonNumber + ']';
script.toggleControl(group, 'next_effect');
};
}
});

this.button = [];
Expand All @@ -298,6 +323,12 @@ DJ202.EffectUnit = function (unitNumber) {
}
};
},
shift: function() {
this.input = function (channel, control, value, status) {
var group = '[EffectRack1_EffectUnit' + unitNumber + ']';
engine.setParameter(group, 'super1', value / 0x7f);
}
}
});

this.knobSoftTakeoverHandler = engine.makeConnection(eu.group, 'focused_effect', function (value, group, control) {
Expand Down
2 changes: 1 addition & 1 deletion res/controllers/Roland_DJ-202.midi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<controls>
<control>
<group>[Channel1]</group>
<key>DJ202.leftDeck.shiftButton</key>
<key>DJ202.shiftButton</key>
<status>0x9F</status>
<midino>0x00</midino>
<options>
Expand Down

0 comments on commit 2c08261

Please sign in to comment.