Skip to content

Commit

Permalink
Implements changes to effect unit handling as requested by @Be-ing
Browse files Browse the repository at this point in the history
    * Level/Depth knob: metaknob of focused effect; if no effect is focused, controls the mix knob for effect unit 1
    * Beat `<`: focus effect 1
    * Beat `>`: focus effect 2
    * FX select button: focus effect 3
    * On/Off button: enable/disable focused effect
    * 1/2/Master switch: assign effect unit 1 to deck 1/2/master as labeled
Unfocus by pressing the button for the focused effect again (so if effect 1 is focused, press Beat `<` to unfocus and make the knob control the mix knob of the unit).
Removed hard-coding of handing of Effect Unit 1 and Effect Unit 2 to apply to Decks 1 and 2 respectively - now only Effect Unit 1 is controlled, and its application to decks depends on the 1/2/Master switch
Added focus indicators to Effect Unit 1 - removed focus indicators from Effect Unit 3
Also added controller polling to Init function
  • Loading branch information
dj3730 authored and jusko committed Jan 30, 2021
1 parent 22d65ab commit 9f81d2d
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 9f81d2d

Please sign in to comment.