Skip to content

Commit

Permalink
Merge pull request mixxxdj#3 from dj3730/ddj400
Browse files Browse the repository at this point in the history
Implements changes to effect unit handling as requested by @Be-ing
  • Loading branch information
nschloe authored and jusko committed Jan 30, 2021
2 parents 22d65ab + 9f81d2d commit 663607f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 45 deletions.
79 changes: 46 additions & 33 deletions res/controllers/Pioneer-DDJ-400-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,29 @@ PioneerDDJ400.loopout = [false, false]; // out loop is pressed
PioneerDDJ400.loopAdjustMultiply = 5;


// Wrapper to easily ignore the function when the button is released.
var ignoreRelease = function(fn) {
"use strict";
return function(channel, control, value, status, group) {
if (value === 0) { // This means the button is released.
return;
}
return fn(channel, control, value, status, group);
};
};


PioneerDDJ400.init = function() {
"use strict";
// init controller
// init tempo Range to 10% (default = 6%)
engine.setValue("[Channel1]", "rateRange", PioneerDDJ400.tempoRanges[1]);
engine.setValue("[Channel2]", "rateRange", PioneerDDJ400.tempoRanges[1]);

// enable effect focus on FX3 for Effect Section
engine.setValue("[EffectRack1_EffectUnit1]", "show_focus", 0);
engine.setValue("[EffectRack1_EffectUnit1]", "group_[Channel1]_enable", 1);

// show focus buttons on Effect Ract 1 only
engine.setValue("[EffectRack1_EffectUnit1]", "show_focus", 1);
engine.setValue("[EffectRack1_EffectUnit2]", "show_focus", 0);
engine.setValue("[EffectRack1_EffectUnit2]", "group_[Channel2]_enable", 1);

engine.setValue("[EffectRack1_EffectUnit3]", "show_focus", 1);
engine.setValue("[EffectRack1_EffectUnit3]", "show_focus", 0);

// Connect the VU-Meter LEDS
engine.connectControl("[Channel1]", "VuMeter", "PioneerDDJ400.vuMeterUpdate");
Expand All @@ -144,6 +152,10 @@ PioneerDDJ400.init = function() {
// reset vumeter
PioneerDDJ400.toggleLight(LightsPioneerDDJ400.deck1.vuMeter, false);
PioneerDDJ400.toggleLight(LightsPioneerDDJ400.deck2.vuMeter, false);

// poll the controller for current control positions on startup
// note that for some reason, the tempo sliders are always reported to be in their center positions, regardless of the current physical position of the slider
midi.sendSysexMsg([0xF0,0x00,0x40,0x05,0x00,0x00,0x02,0x06,0x00,0x03,0x01,0xf7], 12);
};

PioneerDDJ400.toggleLight = function(midiIn, active) {
Expand Down Expand Up @@ -453,26 +465,23 @@ PioneerDDJ400.numFxSlots = 3;
Object.defineProperty(PioneerDDJ400, "selectedFxSlot", {
get: function() {
"use strict";
return engine.getValue("[EffectRack1_EffectUnit3]", "focused_effect");
return engine.getValue("[EffectRack1_EffectUnit1]", "focused_effect");
},
set: function(value) {
"use strict";
if (value <= 0 || value > PioneerDDJ400.numFxSlots) {
if (value < 0 || value > PioneerDDJ400.numFxSlots) {
return;
}

engine.setValue("[EffectRack1_EffectUnit3]", "focused_effect", value);

engine.setValue("[EffectRack1_EffectUnit1]", "focused_effect", value);
var isEffectEnabled = engine.getValue(PioneerDDJ400.selectedFxGroup, "enabled");

PioneerDDJ400.toggleLight(LightsPioneerDDJ400.beatFx, isEffectEnabled);
},
});

Object.defineProperty(PioneerDDJ400, "selectedFxGroup", {
get: function() {
"use strict";
return "[EffectRack1_EffectUnit3_Effect" + PioneerDDJ400.selectedFxSlot + "]";
return "[EffectRack1_EffectUnit1_Effect" + PioneerDDJ400.selectedFxSlot + "]";
},
});

Expand All @@ -484,47 +493,51 @@ PioneerDDJ400.beatFxLevelDepthRotate = function(_channel, _control, value) {
if (effectOn) {
engine.setValue(PioneerDDJ400.selectedFxGroup, "meta", newVal);
} else {
engine.setValue("[EffectRack1_EffectUnit3]", "mix", newVal);
engine.setValue("[EffectRack1_EffectUnit1]", "mix", newVal);
}
};

PioneerDDJ400.beatFxSelectPressed = function(_channel, _control, value) {
PioneerDDJ400.beatFxSelectPressed = ignoreRelease(function() {
"use strict";
engine.setValue(PioneerDDJ400.selectedFxGroup, "next_effect", value);
};
if (PioneerDDJ400.selectedFxSlot == 3) {
PioneerDDJ400.selectedFxSlot = 0;
} else {
PioneerDDJ400.selectedFxSlot = 3;
}
});

PioneerDDJ400.beatFxSelectShiftPressed = function(_channel, _control, value) {
"use strict";
engine.setValue(PioneerDDJ400.selectedFxGroup, "prev_effect", value);
};
//engine.setValue(PioneerDDJ400.selectedFxGroup, "prev_effect", value);

// Wrapper to easily ignore the function when the button is released.
var ignoreRelease = function(fn) {
"use strict";
return function(channel, control, value, status, group) {
if (value === 0) { // This means the button is released.
return;
}
return fn(channel, control, value, status, group);
};
};

PioneerDDJ400.beatFxLeftPressed = ignoreRelease(function() {
"use strict";
PioneerDDJ400.selectedFxSlot -= 1;
if (PioneerDDJ400.selectedFxSlot == 1) {
PioneerDDJ400.selectedFxSlot = 0;
} else {
PioneerDDJ400.selectedFxSlot = 1;
}
});

PioneerDDJ400.beatFxRightPressed = ignoreRelease(function() {
"use strict";
PioneerDDJ400.selectedFxSlot += 1;
if (PioneerDDJ400.selectedFxSlot == 2) {
PioneerDDJ400.selectedFxSlot = 0;
} else {
PioneerDDJ400.selectedFxSlot = 2;
}
});

PioneerDDJ400.beatFxOnOffPressed = ignoreRelease(function() {
"use strict";
var selectedSlot = PioneerDDJ400.selectedFxSlot;
if (selectedSlot <= 0 || selectedSlot > PioneerDDJ400.numFxSlots) {
return;
}
var isEnabled = !engine.getValue(PioneerDDJ400.selectedFxGroup, "enabled");

engine.setValue(PioneerDDJ400.selectedFxGroup, "enabled", isEnabled);

PioneerDDJ400.toggleLight(LightsPioneerDDJ400.beatFx, isEnabled);
});

Expand Down
24 changes: 12 additions & 12 deletions res/controllers/Pioneer-DDJ-400.midi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@

<control>
<description>BEAT LEFT - press - select the FX Slot to the left</description>
<group>[EffectRack1_EffectUnit3]</group>
<group>[EffectRack1_EffectUnit1]</group>
<key>PioneerDDJ400.beatFxLeftPressed</key>
<status>0x94</status>
<midino>0x4A</midino>
Expand All @@ -1058,7 +1058,7 @@
<!--
<control>
<description>BEAT LEFT +SHIFT - press - BPM auto mode for FX on</description>
<group>[EffectRack1_EffectUnit3]</group>
<group>[EffectRack1_EffectUnit1]</group>
<key></key>
<status>0x94</status>
<midino>0x66</midino>
Expand All @@ -1069,7 +1069,7 @@
-->
<control>
<description>BEAT RIGHT - press - select the FX Slot to the right</description>
<group>[EffectRack1_EffectUnit3]</group>
<group>[EffectRack1_EffectUnit1]</group>
<key>PioneerDDJ400.beatFxRightPressed</key>
<status>0x94</status>
<midino>0x4B</midino>
Expand All @@ -1080,7 +1080,7 @@
<!--
<control>
<description>BEAT RIGHT +SHIFT - press - BPM TAP mode for FX on</description>
<group>[EffectRack1_EffectUnit3]</group>
<group>[EffectRack1_EffectUnit1]</group>
<key></key>
<status>0x94</status>
<midino>0x6B</midino>
Expand All @@ -1092,7 +1092,7 @@

<control>
<description>BEAT FX SELECT - press - next FX in the selected Slot</description>
<group>[EffectRack1_EffectUnit3]</group>
<group>[EffectRack1_EffectUnit1]</group>
<key>PioneerDDJ400.beatFxSelectPressed</key>
<status>0x94</status>
<midino>0x63</midino>
Expand All @@ -1102,7 +1102,7 @@
</control>
<control>
<description>BEAT FX SELECT +SHIFT - press - prev FX in the selected Slot</description>
<group>[EffectRack1_EffectUnit3]</group>
<group>[EffectRack1_EffectUnit1]</group>
<key>PioneerDDJ400.beatFxSelectShiftPressed</key>
<status>0x94</status>
<midino>0x64</midino>
Expand All @@ -1114,7 +1114,7 @@
<!-- Beat Fx channel selector -->
<control>
<description>BEAT FX CH SELECT CH1 - slide - Select FX on DECK 1</description>
<group>[EffectRack1_EffectUnit3]</group>
<group>[EffectRack1_EffectUnit1]</group>
<key>PioneerDDJ400.beatFxChannel</key>
<status>0x94</status>
<midino>0x10</midino>
Expand All @@ -1124,7 +1124,7 @@
</control>
<control>
<description>BEAT FX CH SELECT CH2 - slide - Select FX on DECK 2</description>
<group>[EffectRack1_EffectUnit3]</group>
<group>[EffectRack1_EffectUnit1]</group>
<key>PioneerDDJ400.beatFxChannel</key>
<status>0x94</status>
<midino>0x11</midino>
Expand All @@ -1134,7 +1134,7 @@
</control>
<control>
<description>BEAT FX CH SELECT MASTER - slide - Select FX on Master</description>
<group>[EffectRack1_EffectUnit3]</group>
<group>[EffectRack1_EffectUnit1]</group>
<key>PioneerDDJ400.beatFxChannel</key>
<status>0x94</status>
<midino>0x14</midino>
Expand All @@ -1147,7 +1147,7 @@
<description>BEAT FX LEVEL/DEPTH - rotate (MSB) - Adjust FX Level (mix) and BEAT FX Depth (meta) in the
selected slot
</description>
<group>[EffectRack1_EffectUnit3]</group>
<group>[EffectRack1_EffectUnit1]</group>
<key>PioneerDDJ400.beatFxLevelDepthRotate</key>
<status>0xB4</status>
<midino>0x02</midino>
Expand All @@ -1158,7 +1158,7 @@

<control>
<description>BEAT FX ON/OFF - press - Toggle FX in the selected Slot</description>
<group>[EffectRack1_EffectUnit3]</group>
<group>[EffectRack1_EffectUnit1]</group>
<key>PioneerDDJ400.beatFxOnOffPressed</key>
<status>0x94</status>
<midino>0x47</midino>
Expand All @@ -1168,7 +1168,7 @@
</control>
<control>
<description>BEAT FX ON/OFF +SHIFT - press - Disable all enabled Beat FX Slots</description>
<group>[EffectRack1_EffectUnit3]</group>
<group>[EffectRack1_EffectUnit1]</group>
<key>PioneerDDJ400.beatFxOnOffShiftPressed</key>
<status>0x94</status>
<midino>0x43</midino>
Expand Down

0 comments on commit 663607f

Please sign in to comment.