summaryrefslogtreecommitdiffstats
path: root/res/controllers/Hercules-DJ-Console-4-Mx-scripts.js
diff options
context:
space:
mode:
authorJosepMaJAZ <josepma@gmail.com>2017-12-16 18:06:28 +0100
committerBe <be@mixxx.org>2018-03-28 17:00:39 -0500
commit41ea90a105861d559a4d2116c99f6c53f290b6a3 (patch)
tree82186b912297ee949efb6a44a6777dc842d22aea /res/controllers/Hercules-DJ-Console-4-Mx-scripts.js
parent257df65e808f3fb42eaffd830e20dff2837b1ae2 (diff)
Hercules DJ Console 4-MX updates for 2.1
Diffstat (limited to 'res/controllers/Hercules-DJ-Console-4-Mx-scripts.js')
-rw-r--r--res/controllers/Hercules-DJ-Console-4-Mx-scripts.js89
1 files changed, 50 insertions, 39 deletions
diff --git a/res/controllers/Hercules-DJ-Console-4-Mx-scripts.js b/res/controllers/Hercules-DJ-Console-4-Mx-scripts.js
index 7b4467c936..f6f98caf4a 100644
--- a/res/controllers/Hercules-DJ-Console-4-Mx-scripts.js
+++ b/res/controllers/Hercules-DJ-Console-4-Mx-scripts.js
@@ -43,6 +43,9 @@
// Round of fixes on several controls related to preview deck and effects.
// Added permanent rate change action to pitch buttons when used with shift. (For those cases where
// the defined range of the slider is not enough)
+// Version 2017-12-16
+// Some changes for Mixxx 2.1
+// Single JogWheel mode hack (One of my jog wheels got broken.. this is a workaround).
// Usage:
// ------
// Check the dedicated controller wiki page at:
@@ -52,7 +55,6 @@
/////////////////////////////////////////////////////////////////////
var Hercules4Mx = function() {};
-
// The 4 possible values for the beatFlashLed option below.
Hercules4Mx.Leds = {
"none": 0,
@@ -93,7 +95,10 @@ Hercules4Mx.userSettings = {
// mixxx20 : As they were initially defined with the release of Mixxx 2.0
// mixxx21 : AS they were defined with the release of Mixxx 2.1
// With a little caution, you can modify them at the bottom of this file
- 'FXbuttonsSetup': 'mixxx21'
+ 'FXbuttonsSetup': 'mixxx21',
+ // This allows to use the left jog wheel in place of the right jog wheel when pressing the right jog wheel.
+ // I implemented this to overcome the failure of the right jog wheel on my controller.
+ 'useSingleJogWheelHack': false
};
//
@@ -109,6 +114,8 @@ Hercules4Mx.userSettings = {
////////////////////////////////////////////////////////////////////////
// --- Internal variables ----
Hercules4Mx.debuglog = false;
+Hercules4Mx.swapJogWheel = false;
+Hercules4Mx.rightJogWheelGroup = "[Channel2]";
Hercules4Mx.navigationStatus = {
//Navigation direction 1 up, -1 down, 0 do not move
@@ -226,7 +233,7 @@ Hercules4Mx.pitchMsbValue = [0x40, 0x40, 0x40, 0x40];
//Default action for the action map.
Hercules4Mx.noActionButtonMap = {
//Action to do when pressed
- 'buttonPressAction': Hercules4Mx.FxActionNoOp,
+ 'buttonPressAction': null, //This needs to be setup at the end, once the function is defined
//Action to do when released
'buttonReleaseAction': null,
//Additional information, if needed
@@ -341,7 +348,8 @@ Hercules4Mx.init = function(id, debugging) {
//timer-called (delayed) setup.
Hercules4Mx.doDelayedSetup = function() {
var i;
- // Activate soft takeover for the relevant controls. Important: Previous to 2.1, engine.softTakeover only works when scripted with setValue !!
+ // Activate soft takeover for the relevant controls.
+ // Important: Previous to 2.1, engine.softTakeover only works when scripted with setValue!!
for (i = 1; i <= 4; i++) {
engine.softTakeover("[Channel" + i + "]", "rate", true);
engine.softTakeover("[Channel" + i + "]", "volume", true);
@@ -491,10 +499,13 @@ Hercules4Mx.onLoopStateChange = function(value, group, control) {
};
//A change in an effect channel status has happened
Hercules4Mx.onEffectStateChange = function(value, group, control) {
- var fxidx = parseInt(group.slice(-2).substr(0, 1)); // "[EffectRack1_EffectUnit1]"
+ var fxidx = parseInt(group.slice(-2).substr(0, 1)); // "[EffectRack1_EffectUnit1_Effect1]"
if (fxidx > 0 && fxidx <= Hercules4Mx.FxLedIdx.length) {
var newval = (value > 0) ? 0x7F : 0x0;
+ /* old 2.0 behaviour
var deck = parseInt(control.slice(-9).substr(0, 1)); // "group_[Channel1]_enable"
+ */
+ var deck = parseInt(group.slice(-10).substr(0, 1));
var messageto = (deck === 1 || deck === 2) ? Hercules4Mx.NOnC1 : Hercules4Mx.NOnC2;
var offset = (deck === 1 || deck === 3) ? 0x00 : 0x20;
midi.sendShortMsg(messageto, Hercules4Mx.FxLedIdx[fxidx - 1] + offset, newval);
@@ -1163,8 +1174,8 @@ Hercules4Mx.effectKnob = function(midichan, control, value, status, group) {
engine.setValue(fxGroup, "loop_move", direction);
Hercules4Mx.editModeStatus.used = true;
} else if (Hercules4Mx.editModeStatus.mode === Hercules4Mx.editModes.effectknob) {
- fxGroup = "[EffectRack1_EffectUnit" + Hercules4Mx.editModeStatus.effect + "]";
- engine.setParameter(fxGroup, "super1", engine.getParameter(fxGroup, "super1") + step * direction);
+ fxGroup = "[EffectRack1_EffectUnit" + group.slice(-3).substr(0, 1) + "_Effect" + Hercules4Mx.editModeStatus.effect + "]";
+ engine.setParameter(fxGroup, "meta", engine.getParameter(fxGroup, "meta") + step * direction);
Hercules4Mx.editModeStatus.used = true;
} else if (Hercules4Mx.editModeStatus.mode === Hercules4Mx.editModes.beatgrid) {
var Fxgroup = "[Channel" + group.slice(-3).substr(0, 1) + "]";
@@ -1227,8 +1238,8 @@ Hercules4Mx.FxSwitchUp = function(group, fxbutton, value, extraparam) {
}
if (Hercules4Mx.editModeStatus.used === false) {
var deck = script.deckFromGroup(group);
- var state = engine.getParameter("[EffectRack1_EffectUnit" + extraparam + "]", "group_[Channel" + deck + "]_enable");
- engine.setParameter("[EffectRack1_EffectUnit" + extraparam + "]", "group_[Channel" + deck + "]_enable", !state);
+ var state = engine.getParameter("[EffectRack1_EffectUnit" + deck + "_Effect" + extraparam + "]", "enabled");
+ engine.setParameter("[EffectRack1_EffectUnit" + deck + "_Effect" + extraparam + "]", "enabled", !state);
}
Hercules4Mx.deactivateEditModeAction();
};
@@ -1393,6 +1404,10 @@ Hercules4Mx.FXButton = function(midichan, control, value, status, groupInitial)
Hercules4Mx.deactivateEditModeAction();
}
} else if (value) {
+ if (Hercules4Mx.debuglog === true) {
+ engine.log(JSON.stringify(mapping));
+ engine.log(JSON.stringify(Hercules4Mx.noActionButtonMap));
+ }
mapping.buttonPressAction(group, fxbutton, 1, mapping.extraParameter);
} else if (mapping.buttonReleaseAction !== null) {
mapping.buttonReleaseAction(group, fxbutton, 0, mapping.extraParameter);
@@ -1413,6 +1428,10 @@ Hercules4Mx.jogWheel = function(midichan, control, value, status, groupInitial)
Hercules4Mx.doNavigateAction();
} else {
var group = (Hercules4Mx.previewOnDeck[groupInitial]) ? '[PreviewDeck1]' : groupInitial;
+ if (Hercules4Mx.userSettings.useSingleJogWheelHack === true
+ && Hercules4Mx.swapJogWheel === true) {
+ group = Hercules4Mx.rightJogWheelGroup;
+ }
engine.setValue(group, "jog", direction + engine.getValue(group, "jog"));
}
};
@@ -1452,6 +1471,7 @@ Hercules4Mx.wheelTouch = function(midichan, control, value, status, groupInitial
// If button up
engine.scratchDisable(script.deckFromGroup(group));
}
+ Hercules4Mx.swapJogWheel = (value > 0);
}
};
//Jog wheel used with pressure (for scratching)
@@ -1463,7 +1483,7 @@ Hercules4Mx.scratchWheel = function(midichan, control, value, status, groupIniti
} else {
//It has a speed sensor, but you have to move it really fast for it to send something different.
var direction = (value < 0x40) ? value : value - 0x80;
- var group = (Hercules4Mx.previewOnDeck[groupInitial]) ? '[PreviewDeck1]' : groupInitial;
+ var group = (Hercules4Mx.previewOnDeck[groupInitial]) ? '[PreviewDeck1]' : groupInitial;
engine.scratchTick(script.deckFromGroup(group), direction);
}
};
@@ -1492,56 +1512,39 @@ Hercules4Mx.deckRateLsb = function(midichan, control, value, status, group) {
}
};
-//These are mapped with javascript so that engine.softTakeover can be enabled programatically.
-//If we could use the setParameter() method, we wouldn't need the
-//absoluteNonLin or faderToVolume, but setParameter currently does not work with softTakeover.
-//TODO: Since version 2.1, setParameter works. Simplify the code.
Hercules4Mx.deckGain = function(midichan, control, value, status, groupInitial) {
var group = (Hercules4Mx.previewOnDeck[groupInitial] === true) ? '[PreviewDeck1]' : groupInitial;
- engine.setValue(group, "pregain", script.absoluteNonLin(value, 0, 1, 4));
+ engine.setParameter(group, "pregain", script.absoluteLin(value,0,1));
};
Hercules4Mx.deckTreble = function(midichan, control, value, status, group) {
//[EqualizerRack1_[Channel1]_Effect1]
var groupChannel = "[Channel" + group.slice(-11).substr(0,1) + "]";
if (Hercules4Mx.previewOnDeck[groupChannel] === false) {
- engine.setValue(group, "parameter3", script.absoluteNonLin(value, 0, 1, 4));
+ engine.setParameter(group, "parameter3", script.absoluteLin(value,0,1));
}
};
Hercules4Mx.deckMids = function(midichan, control, value, status, group) {
//[EqualizerRack1_[Channel1]_Effect1]
var groupChannel = "[Channel" + group.slice(-11).substr(0,1) + "]";
if (Hercules4Mx.previewOnDeck[groupChannel] === false) {
- engine.setValue(group, "parameter2", script.absoluteNonLin(value, 0, 1, 4));
+ engine.setParameter(group, "parameter2", script.absoluteLin(value,0,1));
}
};
Hercules4Mx.deckBass = function(midichan, control, value, status, group) {
//[EqualizerRack1_[Channel1]_Effect1]
var groupChannel = "[Channel" + group.slice(-11).substr(0,1) + "]";
if (Hercules4Mx.previewOnDeck[groupChannel] === false) {
- engine.setValue(group, "parameter1", script.absoluteNonLin(value, 0, 1, 4));
+ engine.setParameter(group, "parameter1", script.absoluteLin(value,0,1));
}
};
Hercules4Mx.deckVolume = function(midichan, control, value, status, group) {
if (Hercules4Mx.previewOnDeck[group] === false) {
- engine.setValue(group, "volume", Hercules4Mx.faderToVolume(value));
- }
-};
-// function to scale fader volume linearly in dB until the second-to-last line, and
-// do the rest linearly. 0dBFs -6dbFs, -12dbFs,-18dbFs, -inf). Just like what the UI does.
-// Neither the script.absoluteLin nor script.absoluteNonLin can do this.
-Hercules4Mx.faderToVolume = function (value) {
- var lowerval = 32; //(1/4th of 127)
- var lowerdb = 0.125; //(1/4th of 1)
- if (value < lowerval) {
- return value*lowerdb/lowerval;
- } else {
- var dbs = -(127-value)*6/32;
- return Math.pow(10.0,dbs/20.0);
+ engine.setParameter(group, "volume", script.absoluteLin(value,0,1));
}
};
Hercules4Mx.crossfader = function(midichan, control, value, status, group) {
- engine.setValue(group, "crossfader", script.absoluteLin(value, -1, 1));
+ engine.setParameter(group, "crossfader", script.absoluteLin(value,0,1));
};
Hercules4Mx.deckheadphones = function(midichan, control, value, status, group) {
@@ -1575,6 +1578,7 @@ Hercules4Mx.deckCStateChange = function(midichan, control, value, status, group)
Hercules4Mx.deckDStateChange = function(midichan, control, value, status, group) {
Hercules4Mx.VuMeterR.midichan = (value > 0) ? 0x91 : 0x90;
Hercules4Mx.updateVumeterSourceAction(Hercules4Mx.VuMeterR, (value > 0) ? 4 : 2);
+ Hercules4Mx.rightJogWheelGroup = (value > 0) ? "[Channel4]" : "[Channel2]";
};
// Internal select what data is sent to the vumeter
@@ -1620,6 +1624,8 @@ Hercules4Mx.getNewDestinationChannel = function(chan) {
// FX button presets configuration.
Hercules4Mx.reinitButtonsMap = function() {
Hercules4Mx.buttonMappings = Hercules4Mx.buttonMappings.slice(Hercules4Mx.buttonMappings.length);
+ //This is setup here because the function is undefined when the map is defined.
+ Hercules4Mx.noActionButtonMap.buttonPressAction = Hercules4Mx.FxActionNoOp;
};
Hercules4Mx.mapNewButton = function(pushAction, releaseAction, extraParameter, signalLed) {
var i;
@@ -1645,18 +1651,15 @@ Hercules4Mx.mapNewButton = function(pushAction, releaseAction, extraParameter, s
if (pushAction === Hercules4Mx.FxSamplerPush) {
var curlen = Hercules4Mx.buttonMappings.length;
Hercules4Mx.samplerLedIdx.push(curlen);
- Hercules4Mx.samplerLedIdx.push(0x20 + curlen);
engine.connectControl("[Sampler" + extraParameter + "]", "play_indicator", "Hercules4Mx.onSamplerStateChange");
- engine.connectControl("[Sampler" + (2 + parseInt(extraParameter)) + "]", "play_indicator", "Hercules4Mx.onSamplerStateChange");
engine.trigger("[Sampler" + extraParameter + "]", "play_indicator");
- engine.trigger("[Sampler" + (2 + parseInt(extraParameter)) + "]", "play_indicator");
}
if (pushAction === Hercules4Mx.FxSwitchDown) {
Hercules4Mx.FxLedIdx.push(Hercules4Mx.buttonMappings.length);
for (i = 1; i <= 4; i++) {
- engine.connectControl("[EffectRack1_EffectUnit" + extraParameter + "]", "group_[Channel" + i + "]_enable", "Hercules4Mx.onEffectStateChange");
- engine.trigger("[EffectRack1_EffectUnit" + extraParameter + "]", "group_[Channel" + i + "]_enable");
+ engine.connectControl("[EffectRack1_EffectUnit" + i + "_Effect" + extraParameter + "]", "enabled", "Hercules4Mx.onEffectStateChange");
+ engine.trigger("[EffectRack1_EffectUnit" + i + "_Effect" + extraParameter + "]", "enabled");
}
}
}
@@ -1671,6 +1674,15 @@ Hercules4Mx.completeButtonsMap = function() {
engine.trigger("[Channel" + i + "]", "loop_enabled");
}
}
+ var newArrayIdx = Hercules4Mx.samplerLedIdx.slice();
+ // Complete the sampler mapping. This allows to duplicate the number of samplers, since Deck 1 and Deck 2 effect buttons
+ // activate different samplers instead of the same ones.
+ for (var i = 0; i < newArrayIdx.length; i++) {
+ Hercules4Mx.samplerLedIdx.push(0x20 + newArrayIdx[i]);
+ var extraParameter = Hercules4Mx.buttonMappings[newArrayIdx[i] -1].extraParameter;
+ engine.connectControl("[Sampler" + (newArrayIdx.length + parseInt(extraParameter)) + "]", "play_indicator", "Hercules4Mx.onSamplerStateChange");
+ engine.trigger("[Sampler" + (newArrayIdx.length + parseInt(extraParameter)) + "]", "play_indicator");
+ }
};
//Mappings of the buttons as described in the DJ Console Manual for Virtual DJ 7 LE.
@@ -1779,4 +1791,3 @@ Hercules4Mx.setupFXButtonsCustomMixx21 = function() {
Hercules4Mx.beatLoopEditButtons.push("beatloop_8_toggle"); // loop edit mode, button 5
Hercules4Mx.beatLoopEditButtons.push("beatloop_32_toggle"); // loop edit mode, button 6
};
-