Skip to content

Commit

Permalink
Merge pull request mixxxdj#5 from dj3730/ddj400
Browse files Browse the repository at this point in the history
Set highspeedScale to 20, to allow quick search through track using S…
  • Loading branch information
nschloe authored and jusko committed Dec 22, 2020
2 parents cbe8f69 + ddd7f64 commit 5464468
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 49 deletions.
109 changes: 72 additions & 37 deletions res/controllers/Pioneer-DDJ-400-script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Pioneer-DDJ-400-script.js
// ****************************************************************************
// * Mixxx mapping script file for the Pioneer DDJ-400.
// * Author: Warker, nschloe
// * Author: Warker, nschloe, dj3730
// * Forum: https://mixxx.org/forums/viewtopic.php?f=7&t=12113
// * Wiki: https://www.mixxx.org/wiki/doku.php/pioneer_ddj-400
//
Expand All @@ -16,19 +16,20 @@
// * Beat Sync
// * Beat Loop Mode
// * Sampler Mode
// * BeatFX (controls Effect Unit 1. LEFT selects EFFECT1, RIGHT selects EFFECT2, FX_SELECT selects EFFECT3.
// ON/OFF toggles selected effect slot. SHIFT+ON/OFF disables all three effect slots.
// * Hot Cue Mode
//
// Partially:
// * Beatjump mode (no lighting, shift mode)
// * Beatjump mode (no lighting, shift mode(adjust jump size))
// * PAD FX (only slots A-H, Q-P)
// * Effect Section (without Beat FX left + Right - no equivalent function found)
// * Output (lights)
// * Loop Section: Loop in / Out, Call, Double, Half
// (loop adjust not working, '4 beat loop' doesnt work correctly - see comments in PioneerDDJ400.loopin4beatPressedLong)
//
// Testing:
// * Keyboard Mode (check pitch value)
// * Keyshift Mode (check pitch value)
// * Hot Cue Mode (including loops)
// * Loop Section: Loop in / Out + Adjust, Call, Double, Half
// * Effect Section (Beat FX left + Right - select the Effect Slot (not Effect BPM))
//
// Not working/implemented:
// * Channel & Crossfader Start
Expand Down Expand Up @@ -93,7 +94,7 @@ PioneerDDJ400.shiftState = [0, 0];
PioneerDDJ400.vinylMode = true;
PioneerDDJ400.alpha = 1.0/8;
PioneerDDJ400.beta = PioneerDDJ400.alpha/32;
PioneerDDJ400.highspeedScale = 2;
PioneerDDJ400.highspeedScale = 150; // multiplier for fast seek through track using SHIFT+JOGWHEEL
PioneerDDJ400.bendScale = 0.5;

PioneerDDJ400.pointJumpSpace = 0.005; // amount in percent of the Song we can jump back to previous Cue or loop point
Expand Down Expand Up @@ -153,7 +154,7 @@ PioneerDDJ400.init = function() {
// reset vumeter
PioneerDDJ400.toggleLight(LightsPioneerDDJ400.deck1.vuMeter, false);
PioneerDDJ400.toggleLight(LightsPioneerDDJ400.deck2.vuMeter, false);
// DJ3730: added
// enable soft takeover for rate controls
engine.softTakeover("[Channel1]", "rate", true);
Expand All @@ -166,10 +167,38 @@ PioneerDDJ400.init = function() {
PioneerDDJ400.samplerCallbacks.push(engine.makeConnection("[Sampler" + i + "]", "play", PioneerDDJ400.samplerPlayOutputCallbackFunction));
}

// DJ3730: added
// trigger "track loaded" animations when a track is loaded
for (i=1; i<=2; i++) {
engine.connectControl("[Channel"+i+"]","track_loaded", "PioneerDDJ400.trackLoadedLED"+i);
engine.trigger("[Channel"+i+"]","track_loaded");
}

// DJ3730: added
// eye candy : play the "track loaded" animation on both decks at startup
midi.sendShortMsg(0x9F,0x00,0x7F);
midi.sendShortMsg(0x9F,0x01,0x7F);

// poll the controller for current control positions on startup
midi.sendSysexMsg([0xF0,0x00,0x40,0x05,0x00,0x00,0x02,0x06,0x00,0x03,0x01,0xf7], 12);
};

PioneerDDJ400.trackLoadedLED1 = function (loaded) {
PioneerDDJ400.trackLoadedLED(1, loaded);
}
PioneerDDJ400.trackLoadedLED2 = function (loaded) {
PioneerDDJ400.trackLoadedLED(2, loaded);
}

PioneerDDJ400.trackLoadedLED = function (channel, loaded) {
if (loaded) {
var value = 0x7F;
} else {
var value = 0x00;
}
midi.sendShortMsg(0x9F,0x00+(channel-1),value);
}

PioneerDDJ400.toggleLight = function(midiIn, active) {
"use strict";
midi.sendShortMsg(midiIn.status, midiIn.data1, active ? 0x7F : 0);
Expand Down Expand Up @@ -451,7 +480,6 @@ PioneerDDJ400.samplerModeShiftPadPressed = function(_channel, _control, value, _
} else { // load selected track
engine.setValue(group, "LoadSelectedTrack", 1);
}
// TODO: while playing a sample blink playing PAD?
};


Expand Down Expand Up @@ -481,6 +509,9 @@ PioneerDDJ400.loopin4beatPressed = function(channel, _control, value, _status, g
};

PioneerDDJ400.loopin4beatPressedLong = function(_channel, _control, value, _status, group) {
// problematic - loop gets set to the playback position where the 'long press' was recognized
// and not to the point at which the button was initially pressed
// as a result, the loop is not set where one would expect
"use strict";
var loopEnabled = engine.getValue(group, "loop_enabled");
if (!loopEnabled && value > 0) {
Expand Down Expand Up @@ -538,53 +569,57 @@ PioneerDDJ400.beatFxLevelDepthRotate = function(_channel, _control, value) {
};

PioneerDDJ400.beatFxSelectPressed = ignoreRelease(function() {
// focus Effect Slot 3 in Effect Unit 1, or clear focus if it is currently focused
"use strict";
if (PioneerDDJ400.selectedFxSlot == 3) {
PioneerDDJ400.selectedFxSlot = 0;
} else {
PioneerDDJ400.selectedFxSlot = 3;
}
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);

};

PioneerDDJ400.beatFxLeftPressed = ignoreRelease(function() {
// focus Effect Slot 1 in Effect Unit 1, or clear focus if it is currently focused
"use strict";
if (PioneerDDJ400.selectedFxSlot == 1) {
PioneerDDJ400.selectedFxSlot = 0;
} else {
PioneerDDJ400.selectedFxSlot = 1;
}
if (PioneerDDJ400.selectedFxSlot == 1) {
PioneerDDJ400.selectedFxSlot = 0;
} else {
PioneerDDJ400.selectedFxSlot = 1;
}
});

PioneerDDJ400.beatFxRightPressed = ignoreRelease(function() {
// focus Effect Slot 2 in Effect Unit 1, or clear focus if it is currently focused
"use strict";
if (PioneerDDJ400.selectedFxSlot == 2) {
PioneerDDJ400.selectedFxSlot = 0;
} else {
PioneerDDJ400.selectedFxSlot = 2;
}
if (PioneerDDJ400.selectedFxSlot == 2) {
PioneerDDJ400.selectedFxSlot = 0;
} else {
PioneerDDJ400.selectedFxSlot = 2;
}
});

PioneerDDJ400.beatFxOnOffPressed = ignoreRelease(function() {
// toggle the currently focused effect slot in Effect Unit 1 (if any)
"use strict";
var selectedSlot = PioneerDDJ400.selectedFxSlot;
var selectedSlot = PioneerDDJ400.selectedFxSlot;
if (selectedSlot <= 0 || selectedSlot > PioneerDDJ400.numFxSlots) {
return;
return;
}
var isEnabled = !engine.getValue(PioneerDDJ400.selectedFxGroup, "enabled");
engine.setValue(PioneerDDJ400.selectedFxGroup, "enabled", isEnabled);
PioneerDDJ400.toggleLight(LightsPioneerDDJ400.beatFx, isEnabled);
});

PioneerDDJ400.beatFxOnOffShiftPressed = ignoreRelease(function() {
// turn off all three effect slots in Effect Unit 1
"use strict";
for (var i = 1; i <= PioneerDDJ400.numFxSlots; i += 1) {
engine.setValue("[EffectRack1_EffectUnit3_Effect" + i + "]", "enabled", 0);
engine.setValue("[EffectRack1_EffectUnit1_Effect" + i + "]", "enabled", 0);
}
PioneerDDJ400.toggleLight(LightsPioneerDDJ400.beatFx, false);
});
Expand Down Expand Up @@ -644,7 +679,7 @@ PioneerDDJ400.vuMeterUpdate = function(value, group) {
// DJ3730: blink pad when sample playback starts
PioneerDDJ400.samplerPlayOutputCallbackFunction = function (value, group, control) {
if (value === 1) {
var curPad = group.match(script.samplerRegEx)[1];
var curPad = group.match(/^\[Sampler(\d+)\]$/)[1]; // for some reason, using script.samplerRegEx here results in an error under Linux
startSamplerBlink((0x97 + (curPad > 8 ? 2 : 0)), (0x30 + ((curPad > 8 ? curPad-8 : curPad)-1)), group);
}
};
Expand Down Expand Up @@ -724,16 +759,16 @@ PioneerDDJ400.shutdown = function() {
// housekeeping
// turn off all Sampler LEDs
for (i = 0; i <= 7; ++i) {
midi.sendShortMsg(0x97, 0x30 + i, 0x00); // Deck 1 pads
midi.sendShortMsg(0x98, 0x30 + i, 0x00); // Deck 1 pads with SHIFT
midi.sendShortMsg(0x99, 0x30 + i, 0x00); // Deck 2 pads
midi.sendShortMsg(0x9A, 0x30 + i, 0x00); // Deck 2 pads with SHIFT
midi.sendShortMsg(0x97, 0x30 + i, 0x00); // Deck 1 pads
midi.sendShortMsg(0x98, 0x30 + i, 0x00); // Deck 1 pads with SHIFT
midi.sendShortMsg(0x99, 0x30 + i, 0x00); // Deck 2 pads
midi.sendShortMsg(0x9A, 0x30 + i, 0x00); // Deck 2 pads with SHIFT
}
// turn off all Hotcue LEDs
for (i = 0; i <= 7; ++i) {
midi.sendShortMsg(0x97, 0x00 + i, 0x00); // Deck 1 pads
midi.sendShortMsg(0x98, 0x00 + i, 0x00); // Deck 1 pads with SHIFT
midi.sendShortMsg(0x99, 0x00 + i, 0x00); // Deck 2 pads
midi.sendShortMsg(0x9A, 0x00 + i, 0x00); // Deck 2 pads with SHIFT
midi.sendShortMsg(0x97, 0x00 + i, 0x00); // Deck 1 pads
midi.sendShortMsg(0x98, 0x00 + i, 0x00); // Deck 1 pads with SHIFT
midi.sendShortMsg(0x99, 0x00 + i, 0x00); // Deck 2 pads
midi.sendShortMsg(0x9A, 0x00 + i, 0x00); // Deck 2 pads with SHIFT
}
};
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 @@ -121,9 +121,9 @@
</options>
</control>
<control>
<description>PLAY/PAUSE +SHIFT (DECK1) - press - Play/Pause</description>
<description>PLAY/PAUSE +SHIFT (DECK1) - press - Reverse playback in Slip Mode while held (Censor)</description>
<group>[Channel1]</group>
<key>play</key>
<key>reverseroll</key>
<status>0x90</status>
<midino>0x47</midino>
<options>
Expand All @@ -141,9 +141,9 @@
</options>
</control>
<control>
<description>PLAY/PAUSE +SHIFT (DECK2) - press - Play/Pause</description>
<description>PLAY/PAUSE +SHIFT (DECK2) - press - Reverse playback in Slip Mode while held (Censor)</description>
<group>[Channel2]</group>
<key>play</key>
<key>reverseroll</key>
<status>0x91</status>
<midino>0x47</midino>
<options>
Expand Down Expand Up @@ -4167,7 +4167,7 @@
</output>

<!-- SAMPLER Mode Pads (while SHIFT is NOT pressed)-->
<!-- Deck 1 pads -->
<!-- Deck 1 pads -->
<output>
<group>[Sampler1]</group>
<key>track_loaded</key>
Expand Down Expand Up @@ -4233,7 +4233,7 @@
<minimum>0.5</minimum>
</output>
<!-- SAMPLER Mode Pads (while SHIFT is NOT pressed)-->
<!-- Deck 2 pads -->
<!-- Deck 2 pads -->
<output>
<group>[Sampler9]</group>
<key>track_loaded</key>
Expand Down Expand Up @@ -4298,10 +4298,10 @@
<on>0x7F</on>
<minimum>0.5</minimum>
</output>
<!-- SAMPLER Mode Pads (while SHIFT IS pressed)-->
<!-- Deck 1 pads -->
<!-- Deck 1 pads -->
<output>
<group>[Sampler1]</group>
<key>track_loaded</key>
Expand Down Expand Up @@ -4366,10 +4366,10 @@
<on>0x7F</on>
<minimum>0.5</minimum>
</output>
<!-- SAMPLER Mode Pads (while SHIFT IS pressed)-->
<!-- Deck 2 pads -->
<!-- Deck 2 pads -->
<output>
<group>[Sampler9]</group>
<key>track_loaded</key>
Expand Down

0 comments on commit 5464468

Please sign in to comment.