diff --git a/res/controllers/Pioneer-DDJ-400-script.js b/res/controllers/Pioneer-DDJ-400-script.js index ec42310bf48..8cd0bacf7b0 100644 --- a/res/controllers/Pioneer-DDJ-400-script.js +++ b/res/controllers/Pioneer-DDJ-400-script.js @@ -125,7 +125,6 @@ PioneerDDJ400.samplerCallbacks = []; // 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; @@ -136,45 +135,33 @@ var ignoreRelease = function(fn) { 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]); // 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_EffectUnit3]", "show_focus", 0); // Connect the VU-Meter LEDS - engine.connectControl("[Channel1]", "VuMeter", "PioneerDDJ400.vuMeterUpdate"); - engine.connectControl("[Channel2]", "VuMeter", "PioneerDDJ400.vuMeterUpdate"); + engine.makeConnection("[Channel1]", "VuMeter", PioneerDDJ400.vuMeterUpdate); + engine.makeConnection("[Channel2]", "VuMeter", PioneerDDJ400.vuMeterUpdate); // 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); engine.softTakeover("[Channel2]", "rate", true); - // DJ3730: added // Sampler callbacks for (i = 1; i <= 16; ++i) { 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"); - } + // trigger "track loaded" animations when a track is loaded + engine.makeConnection("[Channel1]","track_loaded", PioneerDDJ400.trackLoadedLED); + engine.makeConnection("[Channel2]","track_loaded", PioneerDDJ400.trackLoadedLED); - // DJ3730: added // eye candy : play the "track loaded" animation on both decks at startup midi.sendShortMsg(0x9F,0x00,0x7F); midi.sendShortMsg(0x9F,0x01,0x7F); @@ -183,29 +170,21 @@ PioneerDDJ400.init = function() { 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.trackLoadedLED = function (value, group, control) { + if (value) { + var value = 0x7F; + } else { + var value = 0x00; + } + var channel = group.match(/^\[Channel(\d+)\]$/)[1]; + midi.sendShortMsg(0x9F,0x00+(channel-1),value); } PioneerDDJ400.toggleLight = function(midiIn, active) { - "use strict"; midi.sendShortMsg(midiIn.status, midiIn.data1, active ? 0x7F : 0); }; PioneerDDJ400.jogTurn = function(channel, _control, value, _status, group) { - "use strict"; var deckNum = channel + 1; // wheel center at 64; <64 rew >64 fwd var newVal = value - 64; @@ -234,14 +213,12 @@ PioneerDDJ400.jogTurn = function(channel, _control, value, _status, group) { PioneerDDJ400.jogSearch = function(_channel, _control, value, _status, group) { - "use strict"; // "highspeed" (scaleup value) pitch bend var newVal = (value - 64) * this.highspeedScale; engine.setValue(group, "jog", newVal); }; PioneerDDJ400.jogTouch = function(channel, _control, value) { - "use strict"; var deckNum = channel + 1; // skip scratchmode if we adjust the loop points @@ -282,12 +259,9 @@ PioneerDDJ400.tempoSliderLSB = function (channel, control, value, status, group) 'rate', ((0x4000 - fullValue) - 0x2000) / 0x2000 ); - - }; PioneerDDJ400.cycleTempoRange = function(_channel, _control, value, _status, group) { - "use strict"; if (value === 0) return; // ignore release var currRange = engine.getValue(group, "rateRange"); @@ -305,12 +279,10 @@ PioneerDDJ400.cycleTempoRange = function(_channel, _control, value, _status, gro var sortAsc = function(a, b) { // returns 1 if a > b, -1 if a < b, and 0 otherwise - "use strict"; return (a > b) ? 1 : (b > a ? -1 : 0); }; PioneerDDJ400.initCuePointsAndLoops = function(group) { - "use strict"; // create a list of positions in the track which can be selected var points = []; @@ -325,7 +297,6 @@ PioneerDDJ400.initCuePointsAndLoops = function(group) { }; PioneerDDJ400.cueLoopCallLeft = function(_channel, _control, value, _status, group) { - "use strict"; if (value === 0) { // ignore release return; @@ -353,7 +324,6 @@ PioneerDDJ400.cueLoopCallLeft = function(_channel, _control, value, _status, gro }; PioneerDDJ400.cueLoopCallRight = function(_channel, _control, value, _status, group) { - "use strict"; if (value === 0) { return; // ignore release } @@ -381,7 +351,6 @@ PioneerDDJ400.cueLoopCallRight = function(_channel, _control, value, _status, gr }; PioneerDDJ400.keyboardMode = function(channel, _control, value, _status, group) { - "use strict"; if (value > 0) { // clear current set hotcue point and refcount for keyboard mode this.keyboardHotCuePoint[channel] = 0; @@ -394,7 +363,6 @@ PioneerDDJ400.keyboardMode = function(channel, _control, value, _status, group) PioneerDDJ400.keyboardModeEnabledOutput = function(channel, group) { - "use strict"; var status = channel === 0 ? 0x97 : 0x99; var hotcuePad = 1; @@ -419,7 +387,6 @@ PioneerDDJ400.keyboardModeEnabledOutput = function(channel, group) { PioneerDDJ400.keyboardModePad = function(channel, control, value, _status, group) { - "use strict"; channel = (channel & 0xf) < 10 ? 0 : 1; var padNum = (control & 0xf) + 1; var hotcuePad = this.keyboardHotCuePoint[channel]; @@ -460,7 +427,6 @@ PioneerDDJ400.keyboardModePad = function(channel, control, value, _status, group }; PioneerDDJ400.keyshiftModePad = function(_channel, control, value, _status, group) { - "use strict"; if (value === 0) { return; // ignore release } @@ -468,7 +434,6 @@ PioneerDDJ400.keyshiftModePad = function(_channel, control, value, _status, grou }; PioneerDDJ400.samplerModeShiftPadPressed = function(_channel, _control, value, _status, group) { - "use strict"; if (value === 0) { return; // ignore release } @@ -484,12 +449,10 @@ PioneerDDJ400.samplerModeShiftPadPressed = function(_channel, _control, value, _ PioneerDDJ400.shiftPressed = function(channel, _control, value) { - "use strict"; this.shiftState[channel] = value; }; PioneerDDJ400.waveFormRotate = function(_channel, _control, value) { - "use strict"; // select the Waveform to zoom left shift = deck1, right shift = deck2 var deckNum = this.shiftState[0] > 0 ? 1 : 2; var oldVal = engine.getValue("[Channel"+deckNum+"]", "waveform_zoom"); @@ -499,7 +462,6 @@ PioneerDDJ400.waveFormRotate = function(_channel, _control, value) { }; PioneerDDJ400.loopin4beatPressed = function(channel, _control, value, _status, group) { - "use strict"; var loopEnabled = engine.getValue(group, "loop_enabled"); this.loopin4beat[channel] = (value > 0); @@ -512,7 +474,6 @@ PioneerDDJ400.loopin4beatPressedLong = function(_channel, _control, value, _stat // 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) { engine.setValue(group, "beatloop_4_activate", 1); @@ -520,7 +481,6 @@ PioneerDDJ400.loopin4beatPressedLong = function(_channel, _control, value, _stat }; PioneerDDJ400.loopoutPressed = function(channel, _control, value, _status, group) { - "use strict"; var loopEnabled = engine.getValue(group, "loop_enabled"); this.loopout[channel] = (value > 0); @@ -535,11 +495,9 @@ PioneerDDJ400.numFxSlots = 3; Object.defineProperty(PioneerDDJ400, "selectedFxSlot", { get: function() { - "use strict"; return engine.getValue("[EffectRack1_EffectUnit1]", "focused_effect"); }, set: function(value) { - "use strict"; if (value < 0 || value > PioneerDDJ400.numFxSlots) { return; } @@ -551,13 +509,11 @@ Object.defineProperty(PioneerDDJ400, "selectedFxSlot", { Object.defineProperty(PioneerDDJ400, "selectedFxGroup", { get: function() { - "use strict"; return "[EffectRack1_EffectUnit1_Effect" + PioneerDDJ400.selectedFxSlot + "]"; }, }); PioneerDDJ400.beatFxLevelDepthRotate = function(_channel, _control, value) { - "use strict"; var newVal = value === 0 ? 0 : (value / 0x7F); var effectOn = engine.getValue(PioneerDDJ400.selectedFxGroup, "enabled"); @@ -570,7 +526,6 @@ 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 { @@ -579,13 +534,11 @@ PioneerDDJ400.beatFxSelectPressed = ignoreRelease(function() { }); 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 { @@ -595,7 +548,6 @@ PioneerDDJ400.beatFxLeftPressed = ignoreRelease(function() { 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 { @@ -605,7 +557,6 @@ PioneerDDJ400.beatFxRightPressed = ignoreRelease(function() { PioneerDDJ400.beatFxOnOffPressed = ignoreRelease(function() { // toggle the currently focused effect slot in Effect Unit 1 (if any) - "use strict"; var selectedSlot = PioneerDDJ400.selectedFxSlot; if (selectedSlot <= 0 || selectedSlot > PioneerDDJ400.numFxSlots) { return; @@ -617,7 +568,6 @@ PioneerDDJ400.beatFxOnOffPressed = ignoreRelease(function() { 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_EffectUnit1_Effect" + i + "]", "enabled", 0); } @@ -625,7 +575,6 @@ PioneerDDJ400.beatFxOnOffShiftPressed = ignoreRelease(function() { }); PioneerDDJ400.beatFxChannel = ignoreRelease(function(_channel, control, _value, _status, group) { - "use strict"; var enableChannel1 = control === 0x10 || control === 0x14; var enableChannel2 = control === 0x11 || control === 0x14; @@ -634,7 +583,6 @@ PioneerDDJ400.beatFxChannel = ignoreRelease(function(_channel, control, _value, }); PioneerDDJ400.padFxBelowPressed = ignoreRelease(function(channel, control, value, status, group) { - "use strict"; var groupAbove = group.replace(/\[EffectRack1_EffectUnit(\d+)_Effect(\d+)]/, function(all, unit, effect) { var effectAbove = parseInt(effect) - 4; @@ -645,7 +593,6 @@ PioneerDDJ400.padFxBelowPressed = ignoreRelease(function(channel, control, value }); PioneerDDJ400.padFxShiftBelowPressed = ignoreRelease(function(channel, control, value, status, group) { - "use strict"; var groupAbove = group.replace(/\[EffectRack1_EffectUnit(\d+)_Effect(\d+)]/, function(all, unit, effect) { var effectAbove = parseInt(effect) - 4; @@ -658,7 +605,6 @@ PioneerDDJ400.padFxShiftBelowPressed = ignoreRelease(function(channel, control, // END BEAT FX PioneerDDJ400.vuMeterUpdate = function(value, group) { - "use strict"; var newVal = value * 150; switch (group) { @@ -676,7 +622,7 @@ PioneerDDJ400.vuMeterUpdate = function(value, group) { // SAMPLERS // -// DJ3730: blink pad when sample playback starts +// blink pad when sample playback starts PioneerDDJ400.samplerPlayOutputCallbackFunction = function (value, group, control) { if (value === 1) { var curPad = group.match(/^\[Sampler(\d+)\]$/)[1]; // for some reason, using script.samplerRegEx here results in an error under Linux @@ -685,7 +631,6 @@ PioneerDDJ400.samplerPlayOutputCallbackFunction = function (value, group, contro }; PioneerDDJ400.samplerModePadPressed = ignoreRelease(function(_channel, control, _value, status, group) { - "use strict"; var isLoaded = engine.getValue(group, "track_loaded") === 1; if (!isLoaded) { @@ -696,7 +641,6 @@ PioneerDDJ400.samplerModePadPressed = ignoreRelease(function(_channel, control, PioneerDDJ400.samplerModeShiftPadPressed = function(_channel, _control, value, _status, group){ - "use strict"; if(value == 0) { return; // ignore release } @@ -710,10 +654,9 @@ PioneerDDJ400.samplerModeShiftPadPressed = function(_channel, _control, value, _ } }; -const TimersPioneerDDJ400 = {}; +var TimersPioneerDDJ400 = {}; function startSamplerBlink(channel, control, group) { - "use strict"; var val = 0x7f; // print('channel ' + channel + ' +1= ' + (channel+1)); @@ -727,7 +670,7 @@ function startSamplerBlink(channel, control, group) { // also blink the pad while SHIFT is pressed midi.sendShortMsg((channel+1), control, val); - const isPlaying = engine.getValue(group, 'play') === 1; + var isPlaying = engine.getValue(group, 'play') === 1; if (!isPlaying) { // kill timer @@ -741,7 +684,6 @@ function startSamplerBlink(channel, control, group) { } function stopSamplerBlink(channel, control) { - "use strict"; TimersPioneerDDJ400[channel] = TimersPioneerDDJ400[channel] || {}; if (TimersPioneerDDJ400[channel][control] !== undefined) { @@ -751,7 +693,6 @@ function stopSamplerBlink(channel, control) { } PioneerDDJ400.shutdown = function() { - "use strict"; // reset vumeter PioneerDDJ400.toggleLight(LightsPioneerDDJ400.deck1.vuMeter, false); PioneerDDJ400.toggleLight(LightsPioneerDDJ400.deck2.vuMeter, false);