diff --git a/res/controllers/Electrix-Tweaker-scripts.js b/res/controllers/Electrix-Tweaker-scripts.js index 532a9e59ff4..8f138a26b94 100644 --- a/res/controllers/Electrix-Tweaker-scripts.js +++ b/res/controllers/Electrix-Tweaker-scripts.js @@ -1,17 +1,4 @@ -// ====================================================== USER OPTIONS ========================================================= - -// Set this to false if you do not want the volume of samples to be proportional to how hard you press the big buttons. When this is false, the sampler buttons will play the samplers at whatever volume the sample deck is set to. -ElectrixTweaker.samplerVelocityAsVolume = true -// The higher this is, the less hard you have to strike the sample pads to play samples loudly (when ElectrixTweaker.samplerVelocityAsVolume is true). -ElectrixTweaker.samplerSensitivity = 4 - -// Adjust sensitivity of EQs (range 1-7, only use integers) -ElectrixTweaker.eqSensitivity = 6 - -// Set these to true to enable vinyl mode for that deck on startup. This will also enable vinyl control on startup. -ElectrixTweaker.vinylMode = {'[Channel1]': false, '[Channel2]': false, '[Channel3]': false, '[Channel4]': false} - -/** +/* * Electrix Tweaker controller script 1.1.1 for Mixxx 1.12 * Copyright (C) 2015 Be * @@ -28,194 +15,209 @@ ElectrixTweaker.vinylMode = {'[Channel1]': false, '[Channel2]': false, '[Channel * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * See http://mixxx.org/wiki/doku.php/electrix_tweaker for instructions on how to use this mapping + */ - See http://mixxx.org/wiki/doku.php/electrix_tweaker for instructions on how to use this mapping -**/ +var ElectrixTweaker = function() {}; -// ==================================================== GLOBAL VARIABLES ======================================================= +// ====================================================== USER OPTIONS ========================================================= + +// Set this to false if you do not want the volume of samples to be proportional to how hard you press the big buttons. When this is false, the sampler buttons will play the samplers at whatever volume the sample deck is set to. +ElectrixTweaker.samplerVelocityAsVolume = true; +// The higher this is, the less hard you have to strike the sample pads to play samples loudly (when ElectrixTweaker.samplerVelocityAsVolume is true). +ElectrixTweaker.samplerSensitivity = 4; + +// Adjust sensitivity of EQs (range 1-7, only use integers) +ElectrixTweaker.eqSensitivity = 6; + +// Set these to true to enable vinyl mode for that deck on startup. This will also enable vinyl control on startup. +ElectrixTweaker.vinylMode = {"[Channel1]": false, "[Channel2]": false, "[Channel3]": false, "[Channel4]": false}; -function ElectrixTweaker() {} + + +// ==================================================== GLOBAL VARIABLES ======================================================= ElectrixTweaker.colorCodes = { - 'off': 0, - 'green': 1, - 'red': 4, - 'yellow': 8, - 'blue': 16, - 'cyan': 32, - 'magenta': 64, - 'white': 127 -} + "off": 0, + "green": 1, + "red": 4, + "yellow": 8, + "blue": 16, + "cyan": 32, + "magenta": 64, + "white": 127 +}; ElectrixTweaker.deckColor = { - '[Channel1]': ElectrixTweaker.colorCodes['blue'], - '[Channel2]': ElectrixTweaker.colorCodes['blue'], - '[Channel3]': ElectrixTweaker.colorCodes['magenta'], - '[Channel4]': ElectrixTweaker.colorCodes['magenta'] -} + "[Channel1]": ElectrixTweaker.colorCodes.blue, + "[Channel2]": ElectrixTweaker.colorCodes.blue, + "[Channel3]": ElectrixTweaker.colorCodes.magenta, + "[Channel4]": ElectrixTweaker.colorCodes.magenta +}; ElectrixTweaker.hotcueColors = [ - ElectrixTweaker.colorCodes['cyan'], - ElectrixTweaker.colorCodes['green'], - ElectrixTweaker.colorCodes['red'], - ElectrixTweaker.colorCodes['white'] -] + ElectrixTweaker.colorCodes.cyan, + ElectrixTweaker.colorCodes.green, + ElectrixTweaker.colorCodes.red, + ElectrixTweaker.colorCodes.white +]; ElectrixTweaker.encoders = { - '[Channel1]': { - 'High': { - 'cc': 57, - 'ring': 79, - 'button': 45 + "[Channel1]": { + "High": { + "cc": 57, + "ring": 79, + "button": 45 }, - 'Mid': { - 'cc': 58, - 'ring': 80, - 'button': 46 + "Mid": { + "cc": 58, + "ring": 80, + "button": 46 }, - 'Low': { - 'cc': 59, - 'ring': 81, - 'button': 47 + "Low": { + "cc": 59, + "ring": 81, + "button": 47 } }, - '[Channel2]': { - 'High': { - 'cc': 60, - 'ring': 82, - 'button': 48 + "[Channel2]": { + "High": { + "cc": 60, + "ring": 82, + "button": 48 }, - 'Mid': { - 'cc': 61, - 'ring': 83, - 'button': 49 + "Mid": { + "cc": 61, + "ring": 83, + "button": 49 }, - 'Low': { - 'cc': 62, - 'ring': 84, - 'button': 50 + "Low": { + "cc": 62, + "ring": 84, + "button": 50 } } -} -ElectrixTweaker.encoders['[Channel3]'] = ElectrixTweaker.encoders['[Channel1]'] -ElectrixTweaker.encoders['[Channel4]'] = ElectrixTweaker.encoders['[Channel2]'] +}; +ElectrixTweaker.encoders["[Channel3]"] = ElectrixTweaker.encoders["[Channel1]"]; +ElectrixTweaker.encoders["[Channel4]"] = ElectrixTweaker.encoders["[Channel2]"]; // each consecutive value in this array sets the encoder ring LEDs to the show the next LED -ElectrixTweaker.encoderRingSteps = [0, 10, 25, 35, 50, 60, 64, 75, 85, 95, 105, 115, 127] -ElectrixTweaker.encoderRingStepsFill = [0, 1, 20, 30, 40, 50, 60, 64, 75, 85, 95, 105, 120, 127] +ElectrixTweaker.encoderRingSteps = [0, 10, 25, 35, 50, 60, 64, 75, 85, 95, 105, 115, 127]; +ElectrixTweaker.encoderRingStepsFill = [0, 1, 20, 30, 40, 50, 60, 64, 75, 85, 95, 105, 120, 127]; ElectrixTweaker.buttons = { - '[Channel1]': { - 'arrowSide': 42, + "[Channel1]": { + "arrowSide": 42, - 'mode': 33, - 'pfl': 34, - 'play': 35, + "mode": 33, + "pfl": 34, + "play": 35, - 'hotcues': [ - [1, 2, 3, 4], - [9, 10, 11, 12] - ], + "hotcues": [ + [1, 2, 3, 4], + [9, 10, 11, 12] + ], - 'forward': 17, - 'slip': 18, - 'shift': 19, - 'deckToggle': 20, + "forward": 17, + "slip": 18, + "shift": 19, + "deckToggle": 20, - 'back': 25, - 'quantize': 26, - 'key': 27, - 'sync': 28 + "back": 25, + "quantize": 26, + "key": 27, + "sync": 28 }, - '[Channel2]': { - 'mode': 36, - 'pfl': 37, - 'play': 38, + "[Channel2]": { + "mode": 36, + "pfl": 37, + "play": 38, - 'arrowSide': 43, + "arrowSide": 43, - 'hotcues': [ - [5, 6, 7, 8], - [13, 14, 15, 16] - ], + "hotcues": [ + [5, 6, 7, 8], + [13, 14, 15, 16] + ], - 'forward': 21, - 'slip': 22, - 'shift': 23, - 'deckToggle': 24, + "forward": 21, + "slip": 22, + "shift": 23, + "deckToggle": 24, - 'back': 29, - 'quantize': 30, - 'key': 31, - 'sync': 32 + "back": 29, + "quantize": 30, + "key": 31, + "sync": 32 } -} -ElectrixTweaker.buttons['[Channel3]'] = ElectrixTweaker.buttons['[Channel1]'] -ElectrixTweaker.buttons['[Channel4]'] = ElectrixTweaker.buttons['[Channel2]'] - -ElectrixTweaker.shift = false -ElectrixTweaker.topShift = false -ElectrixTweaker.deckShift = {'[Channel1]': false, '[Channel2]': false, '[Channel3]': false, '[Channel4]': false} -ElectrixTweaker.deck = {'[Channel1]': '[Channel1]', '[Channel2]': '[Channel2]'} -ElectrixTweaker.mode = {'[Channel1]': 'eq', '[Channel2]': 'eq', '[Channel3]': 'eq', '[Channel4]': 'eq'} -ElectrixTweaker.loopMoveSize = {'[Channel1]': 1, '[Channel2]': 1, '[Channel3]': 1, '[Channel4]': 1} -ElectrixTweaker.loopSize = {'[Channel1]': 4, '[Channel2]': 4, '[Channel3]': 4, '[Channel4]': 4} -ElectrixTweaker.slipMode = {'[Channel1]': false, '[Channel2]': false, '[Channel3]': false, '[Channel4]': false} -ElectrixTweaker.deckShift = {'[Channel1]': false, '[Channel2]': false, '[Channel3]': false, '[Channel4]': false} -ElectrixTweaker.hotcuePage = {'[Channel1]': 0, '[Channel2]': 0, '[Channel3]': 0, '[Channel4]': 0} -ElectrixTweaker.hotcuesPressed = {'[Channel1]': 0, '[Channel2]': 0, '[Channel3]': 0, '[Channel4]': 0} -ElectrixTweaker.playPressedWhileCueJuggling = {'[Channel1]': false, '[Channel2]': false, '[Channel3]': false, '[Channel4]': false} -ElectrixTweaker.slipModeUnsetWhileLooping = {'[Channel1]': false, '[Channel2]': false, '[Channel3]': false, '[Channel4]': false} -ElectrixTweaker.midEncoderLEDTimer = {'[Channel1]': 0, '[Channel2]': 0, '[Channel3]': 0, '[Channel4]': 0} -ElectrixTweaker.midEncoderLEDTimer = {'[Channel1]': 0, '[Channel2]': 0, '[Channel3]': 0, '[Channel4]': 0} - -ElectrixTweaker.sysexPrefix = [ 240, 0, 1, 106, 1 ] +}; +ElectrixTweaker.buttons["[Channel3]"] = ElectrixTweaker.buttons["[Channel1]"]; +ElectrixTweaker.buttons["[Channel4]"] = ElectrixTweaker.buttons["[Channel2]"]; + +ElectrixTweaker.shift = false; +ElectrixTweaker.topShift = false; +ElectrixTweaker.deckShift = {"[Channel1]": false, "[Channel2]": false, "[Channel3]": false, "[Channel4]": false}; +ElectrixTweaker.deck = {"[Channel1]": "[Channel1]", "[Channel2]": "[Channel2]"}; +ElectrixTweaker.mode = {"[Channel1]": "eq", "[Channel2]": "eq", "[Channel3]": "eq", "[Channel4]": "eq"}; +ElectrixTweaker.loopMoveSize = {"[Channel1]": 1, "[Channel2]": 1, "[Channel3]": 1, "[Channel4]": 1}; +ElectrixTweaker.loopSize = {"[Channel1]": 4, "[Channel2]": 4, "[Channel3]": 4, "[Channel4]": 4}; +ElectrixTweaker.slipMode = {"[Channel1]": false, "[Channel2]": false, "[Channel3]": false, "[Channel4]": false}; +ElectrixTweaker.deckShift = {"[Channel1]": false, "[Channel2]": false, "[Channel3]": false, "[Channel4]": false}; +ElectrixTweaker.hotcuePage = {"[Channel1]": 0, "[Channel2]": 0, "[Channel3]": 0, "[Channel4]": 0}; +ElectrixTweaker.hotcuesPressed = {"[Channel1]": 0, "[Channel2]": 0, "[Channel3]": 0, "[Channel4]": 0}; +ElectrixTweaker.playPressedWhileCueJuggling = {"[Channel1]": false, "[Channel2]": false, "[Channel3]": false, "[Channel4]": false}; +ElectrixTweaker.slipModeUnsetWhileLooping = {"[Channel1]": false, "[Channel2]": false, "[Channel3]": false, "[Channel4]": false}; +ElectrixTweaker.midEncoderLEDTimer = {"[Channel1]": 0, "[Channel2]": 0, "[Channel3]": 0, "[Channel4]": 0}; +ElectrixTweaker.midEncoderLEDTimer = {"[Channel1]": 0, "[Channel2]": 0, "[Channel3]": 0, "[Channel4]": 0}; + +ElectrixTweaker.sysexPrefix = [240, 0, 1, 106, 1]; ElectrixTweaker.defaultSettings = [ -[ 240, 0, 1, 106, 1, 1, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0, 48, 0, 49, 0, 50, 247 ], -[ 240, 0, 1, 106, 1, 2, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 247 ], -[ 240, 0, 1, 106, 1, 3, 0, 56, 0, 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 247 ], -[ 240, 0, 1, 106, 1, 4, 0, 63, 0, 64, 0, 65, 0, 66, 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, 0, 72, 0, 73, 0, 74, 0, 75, 0, 76, 0, 77, 0, 78, 247 ], -[ 240, 0, 1, 106, 1, 5, 126, 5, 1, 247 ], -[ 240, 0, 1, 106, 1, 6, 127, 127, 15, 0, 7, 0, 9, 5, 247 ], -[ 240, 0, 1, 106, 1, 7, 42, 42, 247 ], -[ 240, 0, 1, 106, 1, 8, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 247 ], -[ 240, 0, 1, 106, 1, 9, 0, 79, 0, 80, 0, 81, 0, 82, 0, 83, 0, 84, 247 ], -[ 240, 0, 1, 106, 1, 13, 15, 247 ], -[ 240, 0, 1, 106, 1, 14, 0, 247 ], -[ 240, 0, 1, 106, 1, 15, 0, 247 ] -] -ElectrixTweaker.requestConfiguration = ElectrixTweaker.sysexPrefix.concat([ 126 , 247 ]) - -ElectrixTweaker.samplerRegEx = /\[Sampler(\d+)\]/ -ElectrixTweaker.channelRegEx = /\[Channel(\d+)\]/ + [240, 0, 1, 106, 1, 1, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0, 48, 0, 49, 0, 50, 247], + [240, 0, 1, 106, 1, 2, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 247], + [240, 0, 1, 106, 1, 3, 0, 56, 0, 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 247], + [240, 0, 1, 106, 1, 4, 0, 63, 0, 64, 0, 65, 0, 66, 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, 0, 72, 0, 73, 0, 74, 0, 75, 0, 76, 0, 77, 0, 78, 247], + [240, 0, 1, 106, 1, 5, 126, 5, 1, 247], + [240, 0, 1, 106, 1, 6, 127, 127, 15, 0, 7, 0, 9, 5, 247], + [240, 0, 1, 106, 1, 7, 42, 42, 247], + [240, 0, 1, 106, 1, 8, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 247], + [240, 0, 1, 106, 1, 9, 0, 79, 0, 80, 0, 81, 0, 82, 0, 83, 0, 84, 247], + [240, 0, 1, 106, 1, 13, 15, 247], + [240, 0, 1, 106, 1, 14, 0, 247], + [240, 0, 1, 106, 1, 15, 0, 247] +]; +ElectrixTweaker.requestConfiguration = ElectrixTweaker.sysexPrefix.concat([126, 247]); + +ElectrixTweaker.samplerRegEx = /\[Sampler(\d+)\]/; +ElectrixTweaker.channelRegEx = /\[Channel(\d+)\]/; // ================================================= INITIALIZATION & SHUTDOWN ============================================ -ElectrixTweaker.init = function () { - if (engine.getValue('[Master]', 'num_samplers') < 8) { - engine.setValue('[Master]', 'num_samplers', 8) +ElectrixTweaker.init = function() { + if (engine.getValue("[Master]", "num_samplers") < 8) { + engine.setValue("[Master]", "num_samplers", 8); } - for (var group in ElectrixTweaker.encoders) { // loop over each [Channel] -// engine.softTakeover('[QuickEffectRack1_'+group+']', 'super1', true) -// engine.softTakeover(group, 'volume', true) - // uncomment the line below when Bug #1472868 is fixed -// ElectrixTweaker.vinylMode[group] = engine.getValue(group, 'vinylcontrol_enabled') - engine.setValue(group, 'vinylcontrol_enabled', ElectrixTweaker.vinylMode[group]) + for (const group in ElectrixTweaker.encoders) { // loop over each [Channel] + // engine.softTakeover('[QuickEffectRack1_'+group+']', 'super1', true) + // engine.softTakeover(group, 'volume', true) + // uncomment the line below when issue #8142 is fixed + // ElectrixTweaker.vinylMode[group] = engine.getValue(group, 'vinylcontrol_enabled') + engine.setValue(group, "vinylcontrol_enabled", ElectrixTweaker.vinylMode[group]); } - ElectrixTweaker.initDeck('[Channel1]') - ElectrixTweaker.initDeck('[Channel2]') - for (i=1; i<=8; i++) { - engine.connectControl('[Sampler'+i+']', 'track_samples', 'ElectrixTweaker.oneShotLED') - engine.trigger('[Sampler'+i+']', 'track_samples') + ElectrixTweaker.initDeck("[Channel1]"); + ElectrixTweaker.initDeck("[Channel2]"); + for (let i=1; i<=8; i++) { + engine.connectControl("[Sampler"+i+"]", "track_samples", "ElectrixTweaker.oneShotLED"); + engine.trigger("[Sampler"+i+"]", "track_samples"); } - midi.sendShortMsg(0x90, 39, 127) // light up arrow - midi.sendShortMsg(0x90, 40, 127) // light top shift button - midi.sendShortMsg(0x90, 41, 127) // light down arrow + midi.sendShortMsg(0x90, 39, 127); // light up arrow + midi.sendShortMsg(0x90, 40, 127); // light top shift button + midi.sendShortMsg(0x90, 41, 127); // light down arrow // midi.sendSysexMsg(ElectrixTweaker.requestConfiguration, ElectrixTweaker.requestConfiguration.length) // for (var msg in ElectrixTweaker.defaultSettings) { // midi.sendSysexMsg(ElectrixTweaker.defaultSettings[msg], ElectrixTweaker.defaultSettings[msg].length) // } -} +}; // ElectrixTweaker.inboundSysex = function (data, length) { // print('========================== incoming sysex message ======================================') // print(length) @@ -226,949 +228,949 @@ ElectrixTweaker.init = function () { // } ElectrixTweaker.shutdown = function() { - for (var group in ElectrixTweaker.encoders) { - for (var encoder in ElectrixTweaker.encoders[group]) { + for (const group in ElectrixTweaker.encoders) { + for (const encoder in ElectrixTweaker.encoders[group]) { // set encoder to absolute EQ mode with speed 5 - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder]['cc'], 118) + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder].cc, 118); // enable local control of LED ring - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder]['ring'], 70) + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder].ring, 70); // set rings to center - midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group][encoder]['cc'], 64) + midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group][encoder].cc, 64); // turn off blue button lights - midi.sendShortMsg(0x90, ElectrixTweaker.encoders[group][encoder]['button'], 0) + midi.sendShortMsg(0x90, ElectrixTweaker.encoders[group][encoder].button, 0); } } // turn off all button LEDs - for (i = 0; i <= 70; i++) { - midi.sendShortMsg(0x90, i, ElectrixTweaker.colorCodes['off']) + for (let i = 0; i <= 70; i++) { + midi.sendShortMsg(0x90, i, ElectrixTweaker.colorCodes.off); } -} +}; // ==================================================== MODE SWITCHING FUNCTIONS ================================================ -ElectrixTweaker.initDeck = function (group) { - var disconnectDeck = parseInt(ElectrixTweaker.channelRegEx.exec(group)[1]) +ElectrixTweaker.initDeck = function(group) { + let disconnectDeck = parseInt(ElectrixTweaker.channelRegEx.exec(group)[1]); if (disconnectDeck <= 2) { - disconnectDeck += 2 + disconnectDeck += 2; } else { - disconnectDeck -= 2 + disconnectDeck -= 2; } - disconnectDeck = '[Channel' + disconnectDeck + ']' - ElectrixTweaker.connectDeckControls(disconnectDeck, true) + disconnectDeck = "[Channel" + disconnectDeck + "]"; + ElectrixTweaker.connectDeckControls(disconnectDeck, true); // workaround for https://github.com/mixxxdj/mixxx/issues/8104 - for (i=1; i <= 32; i++) { - engine.setValue(disconnectDeck, 'hotcue_'+i+'_activate', 0) + for (let i=1; i <= 32; i++) { + engine.setValue(disconnectDeck, "hotcue_"+i+"_activate", 0); } - midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group]['shift'], ElectrixTweaker.colorCodes['yellow']) - midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group]['deckToggle'], ElectrixTweaker.deckColor[group]) + midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group].shift, ElectrixTweaker.colorCodes.yellow); + midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group].deckToggle, ElectrixTweaker.deckColor[group]); midi.sendShortMsg( 0x90, - ElectrixTweaker.buttons[group]['slip'], - ElectrixTweaker.slipMode[group] ? ElectrixTweaker.deckColor[group] : ElectrixTweaker.colorCodes['off'] - ) - - ElectrixTweaker.mode[group] = ElectrixTweaker.mode[disconnectDeck] - - ElectrixTweaker.connectDeckControls(group) -} - -ElectrixTweaker.connectDeckControls = function (group, remove) { - remove = (typeof remove !== 'undefined') ? remove : false // default value for remove is false - - var controlsToFunctions = { - 'pfl': 'ElectrixTweaker.pflButtonLED', -// 'track_samples': 'ElectrixTweaker.arrowSideLED', // the line below would overwrite this attribute - 'track_samples': 'ElectrixTweaker.playButtonLED', - 'play': 'ElectrixTweaker.playButtonLED', - 'playposition': 'ElectrixTweaker.playButtonLED', - 'cue_indicator': 'ElectrixTweaker.playButtonLED', - 'sync_enabled': 'ElectrixTweaker.syncLED', - 'keylock': 'ElectrixTweaker.keylockLED', - 'quantize': 'ElectrixTweaker.quantizeLED' - } - engine.connectControl(group, 'track_samples', 'ElectrixTweaker.arrowSideLED', remove) - for (var control in controlsToFunctions) { - engine.connectControl(group, control, controlsToFunctions[control], remove) + ElectrixTweaker.buttons[group].slip, + ElectrixTweaker.slipMode[group] ? ElectrixTweaker.deckColor[group] : ElectrixTweaker.colorCodes.off + ); + + ElectrixTweaker.mode[group] = ElectrixTweaker.mode[disconnectDeck]; + + ElectrixTweaker.connectDeckControls(group); +}; + +ElectrixTweaker.connectDeckControls = function(group, remove) { + remove = (typeof remove !== "undefined") ? remove : false; // default value for remove is false + + const controlsToFunctions = { + "pfl": "ElectrixTweaker.pflButtonLED", + // 'track_samples': 'ElectrixTweaker.arrowSideLED', // the line below would overwrite this attribute + "track_samples": "ElectrixTweaker.playButtonLED", + "play": "ElectrixTweaker.playButtonLED", + "playposition": "ElectrixTweaker.playButtonLED", + "cue_indicator": "ElectrixTweaker.playButtonLED", + "sync_enabled": "ElectrixTweaker.syncLED", + "keylock": "ElectrixTweaker.keylockLED", + "quantize": "ElectrixTweaker.quantizeLED" + }; + engine.connectControl(group, "track_samples", "ElectrixTweaker.arrowSideLED", remove); + for (const control in controlsToFunctions) { + engine.connectControl(group, control, controlsToFunctions[control], remove); if (! remove) { - engine.trigger(group, control) + engine.trigger(group, control); } } - ElectrixTweaker.connectHotcuePage(group, remove) - ElectrixTweaker.connectEncoderMode(group, ElectrixTweaker.mode[group], remove) + ElectrixTweaker.connectHotcuePage(group, remove); + ElectrixTweaker.connectEncoderMode(group, ElectrixTweaker.mode[group], remove); if (ElectrixTweaker.vinylMode[group]) { - ElectrixTweaker.connectVinylLEDs(group, remove) + ElectrixTweaker.connectVinylLEDs(group, remove); } -} +}; -ElectrixTweaker.connectEncoderMode = function (group, mode, remove) { - remove = (typeof remove !== 'undefined') ? remove : false // default value for remove is false +ElectrixTweaker.connectEncoderMode = function(group, mode, remove) { + remove = (typeof remove !== "undefined") ? remove : false; // default value for remove is false switch (mode) { - case 'eq': - midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group]['mode'], ElectrixTweaker.colorCodes['white']) - for (var encoder in ElectrixTweaker.encoders[group]) { - engine.connectControl(group, 'filter' + encoder, 'ElectrixTweaker.eqEncoderLEDs', remove) - engine.connectControl(group, 'filter' + encoder + 'Kill', 'ElectrixTweaker.eqEncoderKillButtonLED', remove) - if (! remove) { - // set encoder to absolute EQ mode with speed 5 - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder]['cc'], 70 + 8*ElectrixTweaker.eqSensitivity) - // enable local control of LED ring - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder]['ring'], 70) - - engine.trigger(group, 'filter' + encoder) - engine.trigger(group, 'filter' + encoder + 'Kill') - } - } - break - case 'loop': - engine.connectControl(group, 'loop_enabled', 'ElectrixTweaker.loopButtonToggleLED', remove) + case "eq": + midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group].mode, ElectrixTweaker.colorCodes.white); + for (const encoder in ElectrixTweaker.encoders[group]) { + engine.connectControl(group, "filter" + encoder, "ElectrixTweaker.eqEncoderLEDs", remove); + engine.connectControl(group, "filter" + encoder + "Kill", "ElectrixTweaker.eqEncoderKillButtonLED", remove); if (! remove) { - engine.trigger(group, 'loop_enabled') - midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group]['mode'], ElectrixTweaker.colorCodes['magenta']) - for (var encoder in ElectrixTweaker.encoders[group]) { - // set encoder to relative mode - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder]['cc'], 64) - // set LED ring to EQ mode with local control disabled - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder]['ring'], 98) - } + // set encoder to absolute EQ mode with speed 5 + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder].cc, 70 + 8*ElectrixTweaker.eqSensitivity); + // enable local control of LED ring + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder].ring, 70); - midi.sendShortMsg( - 0xB0, - ElectrixTweaker.encoders[group]['High']['ring'], - ElectrixTweaker.encoderRingSteps[ - 6 + Math.log(ElectrixTweaker.loopMoveSize[group]) / Math.log(2) - ] - ) + engine.trigger(group, "filter" + encoder); + engine.trigger(group, "filter" + encoder + "Kill"); + } + } + break; + case "loop": + engine.connectControl(group, "loop_enabled", "ElectrixTweaker.loopButtonToggleLED", remove); + if (! remove) { + engine.trigger(group, "loop_enabled"); + midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group].mode, ElectrixTweaker.colorCodes.magenta); + for (const encoder in ElectrixTweaker.encoders[group]) { + // set encoder to relative mode + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder].cc, 64); + // set LED ring to EQ mode with local control disabled + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder].ring, 98); + } - midi.sendShortMsg( - 0xB0, - ElectrixTweaker.encoders[group]['Mid']['ring'], - 64 - ) + midi.sendShortMsg( + 0xB0, + ElectrixTweaker.encoders[group].High.ring, + ElectrixTweaker.encoderRingSteps[ + 6 + Math.log(ElectrixTweaker.loopMoveSize[group]) / Math.log(2) + ] + ); - midi.sendShortMsg( - 0xB0, - ElectrixTweaker.encoders[group]['Low']['ring'], - ElectrixTweaker.encoderRingSteps[ - 6 + Math.log(ElectrixTweaker.loopSize[group]) / Math.log(2) - ] - ) - } - break + midi.sendShortMsg( + 0xB0, + ElectrixTweaker.encoders[group].Mid.ring, + 64 + ); + + midi.sendShortMsg( + 0xB0, + ElectrixTweaker.encoders[group].Low.ring, + ElectrixTweaker.encoderRingSteps[ + 6 + Math.log(ElectrixTweaker.loopSize[group]) / Math.log(2) + ] + ); + } + break; } -} +}; -ElectrixTweaker.connectHotcuePage = function (group, remove) { - remove = (typeof remove !== 'undefined') ? remove : false // default value for remove is false +ElectrixTweaker.connectHotcuePage = function(group, remove) { + remove = (typeof remove !== "undefined") ? remove : false; // default value for remove is false - var min = 1 + (ElectrixTweaker.hotcuePage[group] * 8) - var max = min + 7 - for (i=min; i<=max; i++) { - engine.connectControl(group, 'hotcue_'+i+'_enabled', 'ElectrixTweaker.hotcueLED', remove) + const min = 1 + (ElectrixTweaker.hotcuePage[group] * 8); + const max = min + 7; + for (let i=min; i<=max; i++) { + engine.connectControl(group, "hotcue_"+i+"_enabled", "ElectrixTweaker.hotcueLED", remove); if (! remove) { - engine.trigger(group, 'hotcue_'+i+'_enabled') + engine.trigger(group, "hotcue_"+i+"_enabled"); } } -} - -ElectrixTweaker.connectVinylLEDs = function (group, remove) { - var controlsToFunctions = { - 'passthrough': 'ElectrixTweaker.vinylStatusLED', - 'vinylcontrol_status': 'ElectrixTweaker.vinylStatusLED', - 'vinylcontrol_mode': 'ElectrixTweaker.vinylModeLED', - 'vinylcontrol_cueing': 'ElectrixTweaker.vinylModeLED' - } - for (var control in controlsToFunctions) { - engine.connectControl(group, control, controlsToFunctions[control], remove) +}; + +ElectrixTweaker.connectVinylLEDs = function(group, remove) { + const controlsToFunctions = { + "passthrough": "ElectrixTweaker.vinylStatusLED", + "vinylcontrol_status": "ElectrixTweaker.vinylStatusLED", + "vinylcontrol_mode": "ElectrixTweaker.vinylModeLED", + "vinylcontrol_cueing": "ElectrixTweaker.vinylModeLED" + }; + for (const control in controlsToFunctions) { + engine.connectControl(group, control, controlsToFunctions[control], remove); } if (remove) { midi.sendShortMsg( 0x90, - ElectrixTweaker.buttons[group]['back'], - (engine.getValue(group, 'quantize')) ? ElectrixTweaker.colorCodes['white'] : ElectrixTweaker.colorCodes['green'] - ) + ElectrixTweaker.buttons[group].back, + (engine.getValue(group, "quantize")) ? ElectrixTweaker.colorCodes.white : ElectrixTweaker.colorCodes.green + ); midi.sendShortMsg( 0x90, - ElectrixTweaker.buttons[group]['forward'], - (engine.getValue(group, 'quantize')) ? ElectrixTweaker.colorCodes['white'] : ElectrixTweaker.colorCodes['green'] - ) + ElectrixTweaker.buttons[group].forward, + (engine.getValue(group, "quantize")) ? ElectrixTweaker.colorCodes.white : ElectrixTweaker.colorCodes.green + ); midi.sendShortMsg( 0x90, - ElectrixTweaker.buttons[group]['slip'], - (ElectrixTweaker.slipMode[group]) ? ElectrixTweaker.deckColor[group] : ElectrixTweaker.colorCodes['off'] - ) + ElectrixTweaker.buttons[group].slip, + (ElectrixTweaker.slipMode[group]) ? ElectrixTweaker.deckColor[group] : ElectrixTweaker.colorCodes.off + ); } else { - for (var control in controlsToFunctions) { - engine.trigger(group, control) + for (const control in controlsToFunctions) { + engine.trigger(group, control); } } -} +}; -ElectrixTweaker.topShiftButton = function (channel, control, value, status, group) { +ElectrixTweaker.topShiftButton = function(channel, control, value, status, group) { // ElectrixTweaker.shift = ! ElectrixTweaker.shift - ElectrixTweaker.topShift = ! ElectrixTweaker.topShift + ElectrixTweaker.topShift = ! ElectrixTweaker.topShift; - ElectrixTweaker.connectEncoderMode(ElectrixTweaker.deck['[Channel1]'], ElectrixTweaker.mode[group], value/127) - ElectrixTweaker.connectEncoderMode(ElectrixTweaker.deck['[Channel2]'], ElectrixTweaker.mode[group], value/127) + ElectrixTweaker.connectEncoderMode(ElectrixTweaker.deck["[Channel1]"], ElectrixTweaker.mode[group], value/127); + ElectrixTweaker.connectEncoderMode(ElectrixTweaker.deck["[Channel2]"], ElectrixTweaker.mode[group], value/127); if (value) { for (group in ElectrixTweaker.deck) { - for (var encoder in ElectrixTweaker.encoders[group]) { + for (const encoder in ElectrixTweaker.encoders[group]) { // set encoder to absolute EQ mode with speed 5 - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder]['cc'], 70 + 8*ElectrixTweaker.eqSensitivity) + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder].cc, 70 + 8*ElectrixTweaker.eqSensitivity); // enable local control of LED ring - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder]['ring'], 70) + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group][encoder].ring, 70); } - engine.connectControl(ElectrixTweaker.deck[group], 'pregain', 'ElectrixTweaker.gainLEDs') - engine.trigger(ElectrixTweaker.deck[group], 'pregain') + engine.connectControl(ElectrixTweaker.deck[group], "pregain", "ElectrixTweaker.gainLEDs"); + engine.trigger(ElectrixTweaker.deck[group], "pregain"); } } else { for (group in ElectrixTweaker.deck) { - engine.connectControl(ElectrixTweaker.deck[group], 'pregain', 'ElectrixTweaker.gainLEDs', true) + engine.connectControl(ElectrixTweaker.deck[group], "pregain", "ElectrixTweaker.gainLEDs", true); } } - var controlsToFunctions = { - 'volume': 'ElectrixTweaker.masterGainLEDs', - 'balance': 'ElectrixTweaker.masterBalanceLEDs', - 'headVolume': 'ElectrixTweaker.headGainLEDs', - 'headMix': 'ElectrixTweaker.headMixLEDs', - 'headSplit': 'ElectrixTweaker.headSplitLED' - } - for (var control in controlsToFunctions) { - engine.connectControl('[Master]', control, controlsToFunctions[control], ! value/127) + const controlsToFunctions = { + "volume": "ElectrixTweaker.masterGainLEDs", + "balance": "ElectrixTweaker.masterBalanceLEDs", + "headVolume": "ElectrixTweaker.headGainLEDs", + "headMix": "ElectrixTweaker.headMixLEDs", + "headSplit": "ElectrixTweaker.headSplitLED" + }; + for (const control in controlsToFunctions) { + engine.connectControl("[Master]", control, controlsToFunctions[control], ! value/127); if (value) { - engine.trigger('[Master]', control) + engine.trigger("[Master]", control); } } -} +}; -ElectrixTweaker.deckShiftButton = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] - ElectrixTweaker.deckShift[group] = ! ElectrixTweaker.deckShift[group] +ElectrixTweaker.deckShiftButton = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; + ElectrixTweaker.deckShift[group] = ! ElectrixTweaker.deckShift[group]; if (value) { // set low encoder to relative mode - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group]['Low']['cc'], 64) + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group].Low.cc, 64); // set low LED ring to walk mode with local control disabled - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group]['Low']['ring'], 96) + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group].Low.ring, 96); midi.sendShortMsg( 0xB0, - ElectrixTweaker.encoders[group]['Low']['ring'], + ElectrixTweaker.encoders[group].Low.ring, ElectrixTweaker.encoderRingStepsFill[ElectrixTweaker.hotcuePage[group]+1] - ) + ); // set mid encoder to relative mode - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group]['Mid']['cc'], 64) + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group].Mid.cc, 64); // set mid encoder LED ring to EQ mode with local control disabled // There seems to be a bug in the Tweaker firmware when local control is enabled one LED ring but not another. If local control is enabled here, the other rings behave confusingly. - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group]['Mid']['ring'], 98) - midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group]['Mid']['ring'], 64) + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group].Mid.ring, 98); + midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group].Mid.ring, 64); // set high encoder to absolute EQ mode with sensitivity level 1 // 1 step = 1 MIDI value for fine pitch control - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group]['High']['cc'], 78) + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group].High.cc, 78); // set high LED ring to EQ mode with local control disabled - midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group]['High']['ring'], 78) - engine.connectControl(group, 'rate', 'ElectrixTweaker.rateEncoderLEDs') - engine.trigger(group, 'rate') + midi.sendShortMsg(0xBF, ElectrixTweaker.encoders[group].High.ring, 78); + engine.connectControl(group, "rate", "ElectrixTweaker.rateEncoderLEDs"); + engine.trigger(group, "rate"); if (ElectrixTweaker.topShift && ElectrixTweaker.deckShift[group]) { - ElectrixTweaker.connectVinylLEDs(group, ElectrixTweaker.vinylMode[group]) - ElectrixTweaker.vinylMode[group] = ! ElectrixTweaker.vinylMode[group] + ElectrixTweaker.connectVinylLEDs(group, ElectrixTweaker.vinylMode[group]); + ElectrixTweaker.vinylMode[group] = ! ElectrixTweaker.vinylMode[group]; } } else { - engine.stopTimer(ElectrixTweaker.midEncoderLEDTimer[group]) - engine.connectControl(group, 'rate', 'ElectrixTweaker.rateEncoderLEDs', true) + engine.stopTimer(ElectrixTweaker.midEncoderLEDTimer[group]); + engine.connectControl(group, "rate", "ElectrixTweaker.rateEncoderLEDs", true); } - ElectrixTweaker.connectEncoderMode(group, ElectrixTweaker.mode[group], value/127) -} + ElectrixTweaker.connectEncoderMode(group, ElectrixTweaker.mode[group], value/127); +}; -ElectrixTweaker.rateEncoderLEDs = function (value, group, control) { +ElectrixTweaker.rateEncoderLEDs = function(value, group, _control) { midi.sendShortMsg( - 0xB0, - ElectrixTweaker.encoders[group]['High']['cc'], - script.absoluteLinInverse(value, -1, 1) - ) -} + 0xB0, + ElectrixTweaker.encoders[group].High.cc, + script.absoluteLinInverse(value, -1, 1) + ); +}; // ================================================== ARROWS + BIG ENCODER ==================================================== -ElectrixTweaker.bigEncoder = function (channel, control, value, status, group) { +ElectrixTweaker.bigEncoder = function(channel, control, value, _status, _group) { if (ElectrixTweaker.topShift) { - for (i=0 ; i<35; i++) { - engine.setValue('[Playlist]', (value == 1) ? 'SelectNextTrack' : 'SelectPrevTrack', 1) + for (let i=0; i<35; i++) { + engine.setValue("[Playlist]", (value === 1) ? "SelectNextTrack" : "SelectPrevTrack", 1); } } else { - engine.setValue('[Playlist]', (value == 1) ? 'SelectNextTrack' : 'SelectPrevTrack', 1) + engine.setValue("[Playlist]", (value === 1) ? "SelectNextTrack" : "SelectPrevTrack", 1); } -} -ElectrixTweaker.bigEncoderButton = function (channel, control, value, status, group) { +}; +ElectrixTweaker.bigEncoderButton = function(channel, control, value, _status, _group) { if (value) { if (ElectrixTweaker.topShift) { - engine.setValue('[Playlist]', 'LoadSelectedIntoFirstStopped', 1) + engine.setValue("[Playlist]", "LoadSelectedIntoFirstStopped", 1); } else { - engine.setValue('[Master]', 'maximize_library', ! engine.getValue('[Master]', 'maximize_library')) + engine.setValue("[Master]", "maximize_library", ! engine.getValue("[Master]", "maximize_library")); } } -} -ElectrixTweaker.arrowSide = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +}; +ElectrixTweaker.arrowSide = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (value) { if (ElectrixTweaker.topShift) { - engine.setValue(group, 'eject', 1) - engine.beginTimer(250, 'engine.setValue("'+group+'", "eject", 0)', true) + engine.setValue(group, "eject", 1); + engine.beginTimer(250, "engine.setValue(\""+group+"\", \"eject\", 0)", true); } else { - engine.setValue(group, 'LoadSelectedTrack', 1) + engine.setValue(group, "LoadSelectedTrack", 1); } } -} -ElectrixTweaker.arrowSideLED = function (value, group, control) { - midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group]['arrowSide'], (value) ? 127 : 0) -} -ElectrixTweaker.arrowUp = function (channel, control, value, status, group) { +}; +ElectrixTweaker.arrowSideLED = function(value, group, _control) { + midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group].arrowSide, (value) ? 127 : 0); +}; +ElectrixTweaker.arrowUp = function(channel, control, value, _status, _group) { if (value) { if (ElectrixTweaker.topShift) { - engine.setValue('[Playlist]', 'ToggleSelectedSidebarItem', 1) + engine.setValue("[Playlist]", "ToggleSelectedSidebarItem", 1); } else { - engine.setValue('[Playlist]', 'SelectPrevPlaylist', 1) + engine.setValue("[Playlist]", "SelectPrevPlaylist", 1); } } -} -ElectrixTweaker.arrowDown = function (channel, control, value, status, group) { +}; +ElectrixTweaker.arrowDown = function(channel, control, value, _status, _group) { if (value) { if (ElectrixTweaker.topShift) { - engine.setValue('[Playlist]', 'ToggleSelectedSidebarItem', 1) + engine.setValue("[Playlist]", "ToggleSelectedSidebarItem", 1); } else { - engine.setValue('[Playlist]', 'SelectNextPlaylist', 1) + engine.setValue("[Playlist]", "SelectNextPlaylist", 1); } } -} +}; // ===================================================== SAMPLERS =========================================================== -ElectrixTweaker.oneShot = function (channel, control, value, status, group) { +ElectrixTweaker.oneShot = function(channel, control, value, status, group) { if (value) { - if (engine.getValue(group, 'track_samples')) { + if (engine.getValue(group, "track_samples")) { if (ElectrixTweaker.topShift) { - engine.setValue(group, 'key', 0) - engine.setValue(group, 'sync_enabled', 0) - engine.setValue(group, 'repeat', 0) - engine.setValue(group, 'play', 0) - engine.setValue(group, 'eject', 1) - engine.beginTimer(250, 'engine.setValue("'+group+'", "eject", 0)', true) + engine.setValue(group, "key", 0); + engine.setValue(group, "sync_enabled", 0); + engine.setValue(group, "repeat", 0); + engine.setValue(group, "play", 0); + engine.setValue(group, "eject", 1); + engine.beginTimer(250, "engine.setValue(\""+group+"\", \"eject\", 0)", true); } else { if (ElectrixTweaker.samplerVelocityAsVolume) { - engine.setValue(group, 'volume', script.absoluteNonLin(value * ElectrixTweaker.samplerSensitivity, 0, .25, 1)) + engine.setValue(group, "volume", script.absoluteNonLin(value * ElectrixTweaker.samplerSensitivity, 0, .25, 1)); } - engine.setValue(group, 'playposition', 0) - engine.setValue(group, 'play', 1) + engine.setValue(group, "playposition", 0); + engine.setValue(group, "play", 1); } } else { if (ElectrixTweaker.samplerVelocityAsVolume) { - engine.setValue(group, 'volume', script.absoluteNonLin(value, 0, .25, 1)) + engine.setValue(group, "volume", script.absoluteNonLin(value, 0, .25, 1)); } - engine.setValue(group, 'LoadSelectedTrackAndPlay', 1) + engine.setValue(group, "LoadSelectedTrackAndPlay", 1); } } else { - engine.setValue(group, 'play', 0) + engine.setValue(group, "play", 0); } -} -ElectrixTweaker.oneShotLED = function (value, group, control) { - midi.sendShortMsg(0x90, 62 + parseInt(ElectrixTweaker.samplerRegEx.exec(group)[1]), (value) ? 127 : 0) -} +}; +ElectrixTweaker.oneShotLED = function(value, group, _control) { + midi.sendShortMsg(0x90, 62 + parseInt(ElectrixTweaker.samplerRegEx.exec(group)[1]), (value) ? 127 : 0); +}; // ================================================= CHANNEL STRIPS =========================================================== -ElectrixTweaker.leftKnob = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +ElectrixTweaker.leftKnob = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; // soft takeover - if (Math.abs(script.absoluteLin(value, 0, 1) - engine.getValue('[QuickEffectRack1_'+group+']', 'super1')) < .1) { - engine.setValue('[QuickEffectRack1_'+group+']', 'super1', script.absoluteLin(value, 0, 1)) + if (Math.abs(script.absoluteLin(value, 0, 1) - engine.getValue("[QuickEffectRack1_"+group+"]", "super1")) < .1) { + engine.setValue("[QuickEffectRack1_"+group+"]", "super1", script.absoluteLin(value, 0, 1)); } -} -ElectrixTweaker.rightKnob = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +}; +ElectrixTweaker.rightKnob = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; // soft takeover - if (Math.abs(script.absoluteLin(value, 0, 1) - engine.getValue('[QuickEffectRack1_'+group+']', 'super1')) < .1) { - engine.setValue('[QuickEffectRack1_'+group+']', 'super1', script.absoluteLin(value, 0, 1)) + if (Math.abs(script.absoluteLin(value, 0, 1) - engine.getValue("[QuickEffectRack1_"+group+"]", "super1")) < .1) { + engine.setValue("[QuickEffectRack1_"+group+"]", "super1", script.absoluteLin(value, 0, 1)); } -} +}; -ElectrixTweaker.eqEncoderLEDs = function (value, group, control) { - var encoder = control.replace('filter', '') - midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group][encoder]['cc'], script.absoluteNonLinInverse(value, 0, 1, 4)) -} +ElectrixTweaker.eqEncoderLEDs = function(value, group, control) { + const encoder = control.replace("filter", ""); + midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group][encoder].cc, script.absoluteNonLinInverse(value, 0, 1, 4)); +}; -ElectrixTweaker.eqEncoderKillButtonLED = function (value, group, control) { - var encoder = control.replace('filter', '') - encoder = encoder.replace('Kill', '') - midi.sendShortMsg(0x90, ElectrixTweaker.encoders[group][encoder]['button'], value * 127) -} +ElectrixTweaker.eqEncoderKillButtonLED = function(value, group, control) { + let encoder = control.replace("filter", ""); + encoder = encoder.replace("Kill", ""); + midi.sendShortMsg(0x90, ElectrixTweaker.encoders[group][encoder].button, value * 127); +}; -ElectrixTweaker.masterGainLEDs = function (value, group, control) { - midi.sendShortMsg(0xB0, ElectrixTweaker.encoders['[Channel2]']['High']['cc'], script.absoluteNonLinInverse(value, 0, 1, 4)) -} +ElectrixTweaker.masterGainLEDs = function(value, _group, _control) { + midi.sendShortMsg(0xB0, ElectrixTweaker.encoders["[Channel2]"].High.cc, script.absoluteNonLinInverse(value, 0, 1, 4)); +}; -ElectrixTweaker.masterBalanceLEDs = function (value, group, control) { - midi.sendShortMsg(0xB0, ElectrixTweaker.encoders['[Channel2]']['Mid']['cc'], script.absoluteLinInverse(value, -1, 1)) -} +ElectrixTweaker.masterBalanceLEDs = function(value, _group, _control) { + midi.sendShortMsg(0xB0, ElectrixTweaker.encoders["[Channel2]"].Mid.cc, script.absoluteLinInverse(value, -1, 1)); +}; -ElectrixTweaker.headGainLEDs = function (value, group, control) { - midi.sendShortMsg(0xB0, ElectrixTweaker.encoders['[Channel1]']['High']['cc'], script.absoluteNonLinInverse(value, 0, 1, 4)) -} +ElectrixTweaker.headGainLEDs = function(value, _group, _control) { + midi.sendShortMsg(0xB0, ElectrixTweaker.encoders["[Channel1]"].High.cc, script.absoluteNonLinInverse(value, 0, 1, 4)); +}; -ElectrixTweaker.headMixLEDs = function (value, group, control) { - midi.sendShortMsg(0xB0, ElectrixTweaker.encoders['[Channel1]']['Mid']['cc'], script.absoluteLinInverse(value, -1, 1)) -} +ElectrixTweaker.headMixLEDs = function(value, _group, _control) { + midi.sendShortMsg(0xB0, ElectrixTweaker.encoders["[Channel1]"].Mid.cc, script.absoluteLinInverse(value, -1, 1)); +}; -ElectrixTweaker.headSplitLED = function (value, group, control) { - midi.sendShortMsg(0x90, ElectrixTweaker.encoders['[Channel1]']['Mid']['button'], value * 127) -} +ElectrixTweaker.headSplitLED = function(value, _group, _control) { + midi.sendShortMsg(0x90, ElectrixTweaker.encoders["[Channel1]"].Mid.button, value * 127); +}; -ElectrixTweaker.gainLEDs = function (value, group, control) { - midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group]['Low']['cc'], script.absoluteNonLinInverse(value, 0, 1, 4)) -} +ElectrixTweaker.gainLEDs = function(value, group, _control) { + midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group].Low.cc, script.absoluteNonLinInverse(value, 0, 1, 4)); +}; -ElectrixTweaker.highEncoder = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +ElectrixTweaker.highEncoder = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (ElectrixTweaker.topShift) { - if (control == ElectrixTweaker.encoders['[Channel1]']['High']['cc']) { - engine.setValue('[Master]', 'headVolume', script.absoluteNonLin(value, 0, 1, 5)) + if (control === ElectrixTweaker.encoders["[Channel1]"].High.cc) { + engine.setValue("[Master]", "headVolume", script.absoluteNonLin(value, 0, 1, 5)); } else { - engine.setValue('[Master]', 'volume', script.absoluteNonLin(value, 0, 1, 5)) + engine.setValue("[Master]", "volume", script.absoluteNonLin(value, 0, 1, 5)); } } else if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'rate', script.absoluteLin(value, -1, 1, 0, 126)) + engine.setValue(group, "rate", script.absoluteLin(value, -1, 1, 0, 126)); } else { switch (ElectrixTweaker.mode[group]) { - case 'eq': - engine.setValue(group, 'filterHigh', script.absoluteNonLin(value, 0, 1, 4) ) - break - case 'loop': - if ((value == 127) && (ElectrixTweaker.loopMoveSize[group] >= Math.pow(2, -5))) { - ElectrixTweaker.loopMoveSize[group] = ElectrixTweaker.loopMoveSize[group] / 2 - } else if ((value == 1) && (ElectrixTweaker.loopMoveSize[group] <= Math.pow(2, 5))) { - ElectrixTweaker.loopMoveSize[group] = ElectrixTweaker.loopMoveSize[group] * 2 - } - midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group]['High']['ring'], ElectrixTweaker.encoderRingSteps[ 6 + Math.log(ElectrixTweaker.loopMoveSize[group]) / Math.log(2) ] ) - break + case "eq": + engine.setValue(group, "filterHigh", script.absoluteNonLin(value, 0, 1, 4)); + break; + case "loop": + if ((value === 127) && (ElectrixTweaker.loopMoveSize[group] >= Math.pow(2, -5))) { + ElectrixTweaker.loopMoveSize[group] = ElectrixTweaker.loopMoveSize[group] / 2; + } else if ((value === 1) && (ElectrixTweaker.loopMoveSize[group] <= Math.pow(2, 5))) { + ElectrixTweaker.loopMoveSize[group] = ElectrixTweaker.loopMoveSize[group] * 2; + } + midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group].High.ring, ElectrixTweaker.encoderRingSteps[6 + Math.log(ElectrixTweaker.loopMoveSize[group]) / Math.log(2)]); + break; } } -} -ElectrixTweaker.highEncoderPress = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +}; +ElectrixTweaker.highEncoderPress = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (value) { if (ElectrixTweaker.topShift) { - if (control == ElectrixTweaker.encoders['[Channel1]']['High']['button']) { - engine.setValue('[Master]', 'headVolume', 1) + if (control === ElectrixTweaker.encoders["[Channel1]"].High.button) { + engine.setValue("[Master]", "headVolume", 1); } else { - engine.setValue('[Master]', 'volume', 1) + engine.setValue("[Master]", "volume", 1); } } else { switch (ElectrixTweaker.mode[group]) { - case 'eq': - if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'filterHigh', 1) - } else { - engine.setValue(group, 'filterHighKill', ! engine.getValue(group, 'filterHighKill')) - } - break - case 'loop': - // What to do with this? - break + case "eq": + if (ElectrixTweaker.deckShift[group]) { + engine.setValue(group, "filterHigh", 1); + } else { + engine.setValue(group, "filterHighKill", ! engine.getValue(group, "filterHighKill")); + } + break; + case "loop": + // What to do with this? + break; } } } -} -ElectrixTweaker.midEncoder = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +}; +ElectrixTweaker.midEncoder = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (ElectrixTweaker.topShift) { - if (control == ElectrixTweaker.encoders['[Channel1]']['Mid']['cc']) { - engine.setValue('[Master]', 'headMix', script.absoluteLin(value, -1, 1)) + if (control === ElectrixTweaker.encoders["[Channel1]"].Mid.cc) { + engine.setValue("[Master]", "headMix", script.absoluteLin(value, -1, 1)); } else { - engine.setValue('[Master]', 'balance', script.absoluteLin(value, -1, 1)) + engine.setValue("[Master]", "balance", script.absoluteLin(value, -1, 1)); } } else if (ElectrixTweaker.deckShift[group]) { - engine.stopTimer(ElectrixTweaker.midEncoderLEDTimer[group]) - if (value == 127) { - engine.setValue(group, 'beatjump_32_backward', 1) - midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group]['Mid']['ring'], 0) + engine.stopTimer(ElectrixTweaker.midEncoderLEDTimer[group]); + if (value === 127) { + engine.setValue(group, "beatjump_32_backward", 1); + midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group].Mid.ring, 0); } else { - engine.setValue(group, 'beatjump_32_forward', 1) - midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group]['Mid']['ring'], 127) + engine.setValue(group, "beatjump_32_forward", 1); + midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group].Mid.ring, 127); } - ElectrixTweaker.midEncoderLEDTimer[group] = engine.beginTimer(1000, 'midi.sendShortMsg(0xB0, ElectrixTweaker.encoders["'+group+'"]["Mid"]["ring"], 64)', true) + ElectrixTweaker.midEncoderLEDTimer[group] = engine.beginTimer(1000, "midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[\""+group+"\"][\"Mid\"][\"ring\"], 64)", true); } else { switch (ElectrixTweaker.mode[group]) { - case 'eq': - engine.setValue(group, 'filterMid', script.absoluteNonLin(value, 0, 1, 4)) - break - case 'loop': - engine.stopTimer(ElectrixTweaker.midEncoderLEDTimer[group]) - if (value == 127) { - engine.setValue(group, 'loop_move_' + ElectrixTweaker.loopMoveSize[group] + '_backward', 1) - midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group]['Mid']['ring'], 0) + case "eq": + engine.setValue(group, "filterMid", script.absoluteNonLin(value, 0, 1, 4)); + break; + case "loop": + engine.stopTimer(ElectrixTweaker.midEncoderLEDTimer[group]); + if (value === 127) { + engine.setValue(group, "loop_move_" + ElectrixTweaker.loopMoveSize[group] + "_backward", 1); + midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group].Mid.ring, 0); - } else { - engine.setValue(group, 'loop_move_' + ElectrixTweaker.loopMoveSize[group] + '_forward', 1) - midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group]['Mid']['ring'], 127) - } - ElectrixTweaker.midEncoderLEDTimer[group] = engine.beginTimer(1000, 'midi.sendShortMsg(0xB0, ElectrixTweaker.encoders["'+group+'"]["Mid"]["ring"], 64)', true) - break + } else { + engine.setValue(group, "loop_move_" + ElectrixTweaker.loopMoveSize[group] + "_forward", 1); + midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[group].Mid.ring, 127); + } + ElectrixTweaker.midEncoderLEDTimer[group] = engine.beginTimer(1000, "midi.sendShortMsg(0xB0, ElectrixTweaker.encoders[\""+group+"\"][\"Mid\"][\"ring\"], 64)", true); + break; } } -} -ElectrixTweaker.midEncoderPress = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +}; +ElectrixTweaker.midEncoderPress = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (value) { if (ElectrixTweaker.topShift) { - if (control == ElectrixTweaker.encoders['[Channel1]']['Mid']['button']) { - engine.setValue('[Master]', 'headSplit', ! engine.getValue('[Master]', 'headSplit')) + if (control === ElectrixTweaker.encoders["[Channel1]"].Mid.button) { + engine.setValue("[Master]", "headSplit", ! engine.getValue("[Master]", "headSplit")); } else { - engine.setValue('[Master]', 'balance', 0) + engine.setValue("[Master]", "balance", 0); } } else { switch (ElectrixTweaker.mode[group]) { - case 'eq': - if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'filterMid', 1) - } else { - engine.setValue(group, 'filterMidKill', ! engine.getValue(group, 'filterMidKill')) - } - break - case 'loop': + case "eq": + if (ElectrixTweaker.deckShift[group]) { + engine.setValue(group, "filterMid", 1); + } else { + engine.setValue(group, "filterMidKill", ! engine.getValue(group, "filterMidKill")); + } + break; + case "loop": // What to do with this? } } } -} -ElectrixTweaker.lowEncoder = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +}; +ElectrixTweaker.lowEncoder = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (ElectrixTweaker.topShift) { - engine.setValue(group, 'pregain', script.absoluteNonLin(value, 0, 1, 4)) + engine.setValue(group, "pregain", script.absoluteNonLin(value, 0, 1, 4)); } else if (ElectrixTweaker.deckShift[group]) { - if (value == 1 && ElectrixTweaker.hotcuePage[group] < 3) { - ElectrixTweaker.connectHotcuePage(group, true) - ElectrixTweaker.hotcuePage[group]++ - ElectrixTweaker.connectHotcuePage(group) - } else if (value == 127 && ElectrixTweaker.hotcuePage[group] > 0) { - ElectrixTweaker.connectHotcuePage(group, true) - ElectrixTweaker.hotcuePage[group]-- - ElectrixTweaker.connectHotcuePage(group) + if (value === 1 && ElectrixTweaker.hotcuePage[group] < 3) { + ElectrixTweaker.connectHotcuePage(group, true); + ElectrixTweaker.hotcuePage[group]++; + ElectrixTweaker.connectHotcuePage(group); + } else if (value === 127 && ElectrixTweaker.hotcuePage[group] > 0) { + ElectrixTweaker.connectHotcuePage(group, true); + ElectrixTweaker.hotcuePage[group]--; + ElectrixTweaker.connectHotcuePage(group); } midi.sendShortMsg( 0xB0, - ElectrixTweaker.encoders[group]['Low']['ring'], + ElectrixTweaker.encoders[group].Low.ring, ElectrixTweaker.encoderRingStepsFill[ElectrixTweaker.hotcuePage[group]+1] - ) + ); } else { switch (ElectrixTweaker.mode[group]) { - case 'eq': - engine.setValue(group, 'filterLow', script.absoluteNonLin(value, 0, 1, 4)) - break - case 'loop': - if ((value == 127) && (ElectrixTweaker.loopSize[group] >= Math.pow(2, -5))) { - ElectrixTweaker.loopSize[group] = ElectrixTweaker.loopSize[group] / 2 - engine.setValue(group, 'loop_halve', 1) - engine.setValue(group, 'loop_halve', 0) - } else if ((value == 1) && (ElectrixTweaker.loopSize[group] <= Math.pow(2, 5))) { - ElectrixTweaker.loopSize[group] = ElectrixTweaker.loopSize[group] * 2 - engine.setValue(group, 'loop_double', 1) - engine.setValue(group, 'loop_double', 0) - } - midi.sendShortMsg( - 0xB0, - ElectrixTweaker.encoders[group]['Low']['ring'], - ElectrixTweaker.encoderRingSteps[ - 6 + Math.log(ElectrixTweaker.loopSize[group]) / Math.log(2) - ] - ) - break + case "eq": + engine.setValue(group, "filterLow", script.absoluteNonLin(value, 0, 1, 4)); + break; + case "loop": + if ((value === 127) && (ElectrixTweaker.loopSize[group] >= Math.pow(2, -5))) { + ElectrixTweaker.loopSize[group] = ElectrixTweaker.loopSize[group] / 2; + engine.setValue(group, "loop_halve", 1); + engine.setValue(group, "loop_halve", 0); + } else if ((value === 1) && (ElectrixTweaker.loopSize[group] <= Math.pow(2, 5))) { + ElectrixTweaker.loopSize[group] = ElectrixTweaker.loopSize[group] * 2; + engine.setValue(group, "loop_double", 1); + engine.setValue(group, "loop_double", 0); + } + midi.sendShortMsg( + 0xB0, + ElectrixTweaker.encoders[group].Low.ring, + ElectrixTweaker.encoderRingSteps[ + 6 + Math.log(ElectrixTweaker.loopSize[group]) / Math.log(2) + ] + ); + break; } } -} -ElectrixTweaker.lowEncoderPress = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +}; +ElectrixTweaker.lowEncoderPress = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (value) { if (ElectrixTweaker.topShift) { - engine.setValue(group, 'pregain', 1) + engine.setValue(group, "pregain", 1); } else { switch (ElectrixTweaker.mode[group]) { - case 'eq': - if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'filterLow', 1) - } else { - engine.setValue(group, 'filterLowKill', ! engine.getValue(group, 'filterLowKill')) - } - break - case 'loop': - if (ElectrixTweaker.slipMode[group]) { - engine.setValue(group, 'slip_enabled', ! engine.getValue(group, 'slip_enabled')) - } - if (engine.getValue(group, 'loop_enabled')) { - engine.setValue(group, 'reloop_exit', 1) - } else { - engine.setValue(group, 'beatloop_' + ElectrixTweaker.loopSize[group] + '_activate', 1) - } - break + case "eq": + if (ElectrixTweaker.deckShift[group]) { + engine.setValue(group, "filterLow", 1); + } else { + engine.setValue(group, "filterLowKill", ! engine.getValue(group, "filterLowKill")); + } + break; + case "loop": + if (ElectrixTweaker.slipMode[group]) { + engine.setValue(group, "slip_enabled", ! engine.getValue(group, "slip_enabled")); + } + if (engine.getValue(group, "loop_enabled")) { + engine.setValue(group, "reloop_exit", 1); + } else { + engine.setValue(group, "beatloop_" + ElectrixTweaker.loopSize[group] + "_activate", 1); + } + break; } } - } else if (ElectrixTweaker.mode[group] == 'loop' && (ElectrixTweaker.slipMode[group] || ElectrixTweaker.slipModeUnsetWhileLooping[group])) { - engine.setValue(group, 'slip_enabled', ! engine.getValue(group, 'slip_enabled')) - if (engine.getValue(group, 'loop_enabled')) { - engine.setValue(group, 'reloop_exit', 1) + } else if (ElectrixTweaker.mode[group] === "loop" && (ElectrixTweaker.slipMode[group] || ElectrixTweaker.slipModeUnsetWhileLooping[group])) { + engine.setValue(group, "slip_enabled", ! engine.getValue(group, "slip_enabled")); + if (engine.getValue(group, "loop_enabled")) { + engine.setValue(group, "reloop_exit", 1); } - ElectrixTweaker.slipModeUnsetWhileLooping[group] = false + ElectrixTweaker.slipModeUnsetWhileLooping[group] = false; } -} -ElectrixTweaker.loopButtonToggleLED = function (value, group, control) { - midi.sendShortMsg(0x90, ElectrixTweaker.encoders[group]['Low']['button'], value * 127) -} +}; +ElectrixTweaker.loopButtonToggleLED = function(value, group, _control) { + midi.sendShortMsg(0x90, ElectrixTweaker.encoders[group].Low.button, value * 127); +}; -ElectrixTweaker.modeButton = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +ElectrixTweaker.modeButton = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (value) { - ElectrixTweaker.connectEncoderMode(group, ElectrixTweaker.mode[group], true) + ElectrixTweaker.connectEncoderMode(group, ElectrixTweaker.mode[group], true); switch (ElectrixTweaker.mode[group]) { - case 'eq': - ElectrixTweaker.mode[group] = 'loop' - break - case 'loop': - ElectrixTweaker.mode[group] = 'eq' - break + case "eq": + ElectrixTweaker.mode[group] = "loop"; + break; + case "loop": + ElectrixTweaker.mode[group] = "eq"; + break; } - ElectrixTweaker.connectEncoderMode(group, ElectrixTweaker.mode[group]) + ElectrixTweaker.connectEncoderMode(group, ElectrixTweaker.mode[group]); } -} +}; -ElectrixTweaker.fader = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +ElectrixTweaker.fader = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; // soft takeover. This is necessary for toggling between decks 1/3 or 2/4 // because the fader can't be moved to the new deck's value by this script - if (Math.abs(value - script.absoluteNonLinInverse(engine.getValue(group, 'volume'), 0, .25, 1)) < 30) { - engine.setValue(group, 'volume', script.absoluteNonLin(value, 0, .25, 1)) + if (Math.abs(value - script.absoluteNonLinInverse(engine.getValue(group, "volume"), 0, .25, 1)) < 30) { + engine.setValue(group, "volume", script.absoluteNonLin(value, 0, .25, 1)); } -} +}; -ElectrixTweaker.pflButton = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +ElectrixTweaker.pflButton = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (value) { if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'reloop_exit', 1) + engine.setValue(group, "reloop_exit", 1); } else { - engine.setValue(group, 'pfl', ! engine.getValue(group, 'pfl')) + engine.setValue(group, "pfl", ! engine.getValue(group, "pfl")); } } -} -ElectrixTweaker.pflButtonLED = function (value, group, control) { +}; +ElectrixTweaker.pflButtonLED = function(value, group, control) { midi.sendShortMsg( 0x90, ElectrixTweaker.buttons[group][control], - (value) ? ElectrixTweaker.colorCodes['green'] : ElectrixTweaker.colorCodes['off'] - ) -} + (value) ? ElectrixTweaker.colorCodes.green : ElectrixTweaker.colorCodes.off + ); +}; -ElectrixTweaker.playButton = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +ElectrixTweaker.playButton = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'cue_default', value) + engine.setValue(group, "cue_default", value); } else if (ElectrixTweaker.topShift) { - engine.setValue(group, 'cue_gotoandstop', 1) + engine.setValue(group, "cue_gotoandstop", 1); } else if (value) { if (ElectrixTweaker.hotcuesPressed[group]) { - ElectrixTweaker.playPressedWhileCueJuggling[group] = true + ElectrixTweaker.playPressedWhileCueJuggling[group] = true; } - engine.setValue(group, 'play', ! engine.getValue(group, 'play')) + engine.setValue(group, "play", ! engine.getValue(group, "play")); } -} -ElectrixTweaker.playButtonLED = function (value, group, control) { - if (control == 'cue_indicator' && value == 1) { - midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group]['play'], ElectrixTweaker.colorCodes['yellow']) +}; +ElectrixTweaker.playButtonLED = function(value, group, control) { + if (control === "cue_indicator" && value === 1) { + midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group].play, ElectrixTweaker.colorCodes.yellow); } else { - if (engine.getValue(group, 'play')) { + if (engine.getValue(group, "play")) { if ( - (control != 'playposition') // do not spam MIDI signals with each update in playposition while playing + (control !== "playposition") // do not spam MIDI signals with each update in playposition while playing && ( (! ElectrixTweaker.hotcuesPressed[group]) || ElectrixTweaker.playPressedWhileCueJuggling[group] ) ) { - midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group]['play'], ElectrixTweaker.colorCodes['green']) + midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group].play, ElectrixTweaker.colorCodes.green); } - } else if (engine.getValue(group, 'track_samples')) { - midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group]['play'], ElectrixTweaker.colorCodes['red']) + } else if (engine.getValue(group, "track_samples")) { + midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group].play, ElectrixTweaker.colorCodes.red); } else { - midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group]['play'], ElectrixTweaker.colorCodes['off']) + midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group].play, ElectrixTweaker.colorCodes.off); } } -} +}; //===================================================================== BUTTON GRID ========================================================= -ElectrixTweaker.hotcue = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] - var row = (control < ElectrixTweaker.buttons[group]['hotcues'][1][0]) ? 0 : 1 - var cueButton = 4 + row*4 - (ElectrixTweaker.buttons[group]['hotcues'][row][3] - control) - var cue = cueButton + (8 * ElectrixTweaker.hotcuePage[group]) +ElectrixTweaker.hotcue = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; + const row = (control < ElectrixTweaker.buttons[group].hotcues[1][0]) ? 0 : 1; + const cueButton = 4 + row*4 - (ElectrixTweaker.buttons[group].hotcues[row][3] - control); + const cue = cueButton + (8 * ElectrixTweaker.hotcuePage[group]); if (value) { - if (engine.getValue(group, 'hotcue_'+cue+'_enabled')) { + if (engine.getValue(group, "hotcue_"+cue+"_enabled")) { if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'hotcue_'+cue+'_set', 1) + engine.setValue(group, "hotcue_"+cue+"_set", 1); } else if (ElectrixTweaker.topShift) { - engine.setValue(group, 'hotcue_'+cue+'_clear', 1) + engine.setValue(group, "hotcue_"+cue+"_clear", 1); } else { if (ElectrixTweaker.slipMode[group]) { - if (engine.getValue(group, 'play') && (! ElectrixTweaker.hotcuesPressed[group])) { - engine.setValue(group, 'slip_enabled', 1) + if (engine.getValue(group, "play") && (! ElectrixTweaker.hotcuesPressed[group])) { + engine.setValue(group, "slip_enabled", 1); } - engine.setValue(group, 'hotcue_'+cue+'_activate', 1) - ElectrixTweaker.hotcuesPressed[group]++ + engine.setValue(group, "hotcue_"+cue+"_activate", 1); + ElectrixTweaker.hotcuesPressed[group]++; } else { - engine.setValue(group, 'hotcue_'+cue+'_goto', 1) + engine.setValue(group, "hotcue_"+cue+"_goto", 1); } } } else { - engine.setValue(group, 'hotcue_'+cue+'_set', 1) + engine.setValue(group, "hotcue_"+cue+"_set", 1); } } else { if (ElectrixTweaker.hotcuesPressed[group]) { // do not go below 0 - ElectrixTweaker.hotcuesPressed[group]-- + ElectrixTweaker.hotcuesPressed[group]--; } - engine.setValue(group, 'hotcue_'+cue+'_activate', 0) + engine.setValue(group, "hotcue_"+cue+"_activate", 0); if (! ElectrixTweaker.hotcuesPressed[group]) { - ElectrixTweaker.playPressedWhileCueJuggling[group] = false - engine.setValue(group, 'slip_enabled', 0) + ElectrixTweaker.playPressedWhileCueJuggling[group] = false; + engine.setValue(group, "slip_enabled", 0); } } -} -ElectrixTweaker.hotcueLED = function (value, group, control) { - var cue = parseInt(control.split('_')[1]) - (8 * ElectrixTweaker.hotcuePage[group]) - var row = (cue <= 4) ? 0 : 1 +}; +ElectrixTweaker.hotcueLED = function(value, group, control) { + const cue = parseInt(control.split("_")[1]) - (8 * ElectrixTweaker.hotcuePage[group]); + const row = (cue <= 4) ? 0 : 1; midi.sendShortMsg( 0x90, - ElectrixTweaker.buttons[group]['hotcues'][row][cue - 1 - 4*row], + ElectrixTweaker.buttons[group].hotcues[row][cue - 1 - 4*row], value * ElectrixTweaker.hotcueColors[ElectrixTweaker.hotcuePage[group]] - ) -} + ); +}; -ElectrixTweaker.slipButton = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +ElectrixTweaker.slipButton = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (value) { if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'loop_in', 1) + engine.setValue(group, "loop_in", 1); } else { if (ElectrixTweaker.slipMode[group]) { - if (ElectrixTweaker.hotcuesPressed[group] && ! engine.getValue(group, 'slip_enabled')) { - engine.setValue(group, 'play', 0) + if (ElectrixTweaker.hotcuesPressed[group] && ! engine.getValue(group, "slip_enabled")) { + engine.setValue(group, "play", 0); } - if (engine.getValue(group, 'loop_enabled')) { - ElectrixTweaker.slipModeUnsetWhileLooping[group] = true + if (engine.getValue(group, "loop_enabled")) { + ElectrixTweaker.slipModeUnsetWhileLooping[group] = true; } //engine.setValue(group, 'slip_cancel', 1) - ElectrixTweaker.hotcuesPressed[group] = 0 + ElectrixTweaker.hotcuesPressed[group] = 0; } - ElectrixTweaker.slipMode[group] = ! ElectrixTweaker.slipMode[group] + ElectrixTweaker.slipMode[group] = ! ElectrixTweaker.slipMode[group]; midi.sendShortMsg( 0x90, - ElectrixTweaker.buttons[group]['slip'], - ElectrixTweaker.slipMode[group] ? ElectrixTweaker.deckColor[group] : ElectrixTweaker.colorCodes['off'] - ) + ElectrixTweaker.buttons[group].slip, + ElectrixTweaker.slipMode[group] ? ElectrixTweaker.deckColor[group] : ElectrixTweaker.colorCodes.off + ); } } -} +}; -ElectrixTweaker.deckToggle = function (channel, control, value, status, group) { +ElectrixTweaker.deckToggle = function(channel, control, value, status, group) { if (value) { if (ElectrixTweaker.deckShift[group]) { - engine.setValue(ElectrixTweaker.deck[group], 'loop_out', 1) + engine.setValue(ElectrixTweaker.deck[group], "loop_out", 1); } else { - var deckNumber = parseInt( - ElectrixTweaker.channelRegEx.exec( - ElectrixTweaker.deck[group] - )[1] - ) + let deckNumber = parseInt( + ElectrixTweaker.channelRegEx.exec( + ElectrixTweaker.deck[group] + )[1] + ); if (deckNumber <= 2) { - deckNumber += 2 + deckNumber += 2; } else { - deckNumber -= 2 + deckNumber -= 2; } - ElectrixTweaker.deck[group] = '[Channel' + deckNumber + ']' - ElectrixTweaker.initDeck(ElectrixTweaker.deck[group]) + ElectrixTweaker.deck[group] = "[Channel" + deckNumber + "]"; + ElectrixTweaker.initDeck(ElectrixTweaker.deck[group]); } } -} +}; -ElectrixTweaker.sync = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +ElectrixTweaker.sync = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (value) { if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'rate', 0) + engine.setValue(group, "rate", 0); } else { - engine.setValue(group, 'sync_enabled', ! engine.getValue(group, 'sync_enabled')) + engine.setValue(group, "sync_enabled", ! engine.getValue(group, "sync_enabled")); } } -} -ElectrixTweaker.syncLED = function (value, group, control) { +}; +ElectrixTweaker.syncLED = function(value, group, _control) { midi.sendShortMsg( 0x90, - ElectrixTweaker.buttons[group]['sync'], - (value) ? ElectrixTweaker.deckColor[group] : ElectrixTweaker.colorCodes['off'] - ) -} + ElectrixTweaker.buttons[group].sync, + (value) ? ElectrixTweaker.deckColor[group] : ElectrixTweaker.colorCodes.off + ); +}; -ElectrixTweaker.key = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +ElectrixTweaker.key = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (value) { if (ElectrixTweaker.deckShift[group]) { - if (engine.getValue(group, 'file_key') != engine.getValue(group, 'key')) { - engine.setValue(group, 'reset_key', 1) + if (engine.getValue(group, "file_key") !== engine.getValue(group, "key")) { + engine.setValue(group, "reset_key", 1); } else { - engine.setValue(group, 'sync_key', 1) + engine.setValue(group, "sync_key", 1); } } else { - engine.setValue(group, 'keylock', ! engine.getValue(group, 'keylock')) + engine.setValue(group, "keylock", ! engine.getValue(group, "keylock")); } } -} -ElectrixTweaker.keylockLED = function (value, group, control) { +}; +ElectrixTweaker.keylockLED = function(value, group, _control) { midi.sendShortMsg( 0x90, - ElectrixTweaker.buttons[group]['key'], - (value) ? ElectrixTweaker.deckColor[group] : ElectrixTweaker.colorCodes['off'] - ) -} + ElectrixTweaker.buttons[group].key, + (value) ? ElectrixTweaker.deckColor[group] : ElectrixTweaker.colorCodes.off + ); +}; -ElectrixTweaker.quantize = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +ElectrixTweaker.quantize = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (value) { if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'beats_translate_curpos', 1) + engine.setValue(group, "beats_translate_curpos", 1); } else { - engine.setValue(group, 'quantize', ! engine.getValue(group, 'quantize')) + engine.setValue(group, "quantize", ! engine.getValue(group, "quantize")); } } -} -ElectrixTweaker.quantizeLED = function (value, group, control) { +}; +ElectrixTweaker.quantizeLED = function(value, group, _control) { midi.sendShortMsg( 0x90, - ElectrixTweaker.buttons[group]['quantize'], - (value) ? ElectrixTweaker.deckColor[group] : ElectrixTweaker.colorCodes['off'] - ) + ElectrixTweaker.buttons[group].quantize, + (value) ? ElectrixTweaker.deckColor[group] : ElectrixTweaker.colorCodes.off + ); if (! ElectrixTweaker.vinylMode[group]) { midi.sendShortMsg( 0x90, - ElectrixTweaker.buttons[group]['back'], - (value) ? ElectrixTweaker.colorCodes['white'] : ElectrixTweaker.colorCodes['green'] - ) + ElectrixTweaker.buttons[group].back, + (value) ? ElectrixTweaker.colorCodes.white : ElectrixTweaker.colorCodes.green + ); midi.sendShortMsg( 0x90, - ElectrixTweaker.buttons[group]['forward'], - (value) ? ElectrixTweaker.colorCodes['white'] : ElectrixTweaker.colorCodes['green'] - ) + ElectrixTweaker.buttons[group].forward, + (value) ? ElectrixTweaker.colorCodes.white : ElectrixTweaker.colorCodes.green + ); } -} +}; -ElectrixTweaker.vinylModeLED = function (value, group, control) { - var color - switch (engine.getValue(group, 'vinylcontrol_mode')) { - // absolute mode - case 0: color = 'off'; break +ElectrixTweaker.vinylModeLED = function(value, group, _control) { + let color; + switch (engine.getValue(group, "vinylcontrol_mode")) { + // absolute mode + case 0: color = "off"; break; // relative mode - case 1: - switch (engine.getValue(group, 'vinylcontrol_cueing')) { - case 0: color = 'white'; break - case 1: color = 'yellow'; break - case 2: color = 'green'; break - } - break + case 1: + switch (engine.getValue(group, "vinylcontrol_cueing")) { + case 0: color = "white"; break; + case 1: color = "yellow"; break; + case 2: color = "green"; break; + } + break; // constant mode - case 2: color = 'red'; break + case 2: color = "red"; break; } - midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group]['forward'], ElectrixTweaker.colorCodes[color]) -} -ElectrixTweaker.vinylStatusLED = function (value, group, control) { - if (engine.getValue(group, 'passthrough')) { - midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group]['back'], ElectrixTweaker.colorCodes['white']) + midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group].forward, ElectrixTweaker.colorCodes[color]); +}; +ElectrixTweaker.vinylStatusLED = function(value, group, _control) { + if (engine.getValue(group, "passthrough")) { + midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group].back, ElectrixTweaker.colorCodes.white); } else { - var color - switch (engine.getValue(group, 'vinylcontrol_status')) { - case 0: color = 'off'; break - case 1: color = 'green'; break - case 2: color = 'yellow'; break - case 3: color = 'red'; break + let color; + switch (engine.getValue(group, "vinylcontrol_status")) { + case 0: color = "off"; break; + case 1: color = "green"; break; + case 2: color = "yellow"; break; + case 3: color = "red"; break; } - midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group]['back'], ElectrixTweaker.colorCodes[color]) + midi.sendShortMsg(0x90, ElectrixTweaker.buttons[group].back, ElectrixTweaker.colorCodes[color]); } -} +}; -ElectrixTweaker.forward = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +ElectrixTweaker.forward = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (ElectrixTweaker.vinylMode[group]) { if (value) { - switch (engine.getValue(group, 'vinylcontrol_mode')) { - // absolute mode - case 0: engine.setValue(group, 'vinylcontrol_mode', 1); break + switch (engine.getValue(group, "vinylcontrol_mode")) { + // absolute mode + case 0: engine.setValue(group, "vinylcontrol_mode", 1); break; // relative mode - case 1: - if (engine.getValue(group, 'play') && ! ElectrixTweaker.shift) { - switch (engine.getValue(group, 'vinylcontrol_cueing')) { - case 0: engine.setValue(group, 'vinylcontrol_cueing', 1); break - case 1: engine.setValue(group, 'vinylcontrol_cueing', 2); break - case 2: engine.setValue(group, 'vinylcontrol_cueing', 0); break - } - } else { - engine.setValue(group, 'vinylcontrol_mode', 2) + case 1: + if (engine.getValue(group, "play") && ! ElectrixTweaker.shift) { + switch (engine.getValue(group, "vinylcontrol_cueing")) { + case 0: engine.setValue(group, "vinylcontrol_cueing", 1); break; + case 1: engine.setValue(group, "vinylcontrol_cueing", 2); break; + case 2: engine.setValue(group, "vinylcontrol_cueing", 0); break; } - break + } else { + engine.setValue(group, "vinylcontrol_mode", 2); + } + break; // constant mode - case 2: engine.setValue(group, 'vinylcontrol_mode', 0); break + case 2: engine.setValue(group, "vinylcontrol_mode", 0); break; } } } else { - if (engine.getValue(group, 'quantize')) { + if (engine.getValue(group, "quantize")) { if (value) { if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'beatjump_1_forward', 1) + engine.setValue(group, "beatjump_1_forward", 1); } else { - engine.setValue(group, 'beatjump_4_forward', 1) + engine.setValue(group, "beatjump_4_forward", 1); } } } else { if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'rate_temp_up', value / 127) + engine.setValue(group, "rate_temp_up", value / 127); } else { - engine.setValue(group, 'fwd', value) + engine.setValue(group, "fwd", value); } } } -} -ElectrixTweaker.back = function (channel, control, value, status, group) { - group = ElectrixTweaker.deck[group] +}; +ElectrixTweaker.back = function(channel, control, value, status, group) { + group = ElectrixTweaker.deck[group]; if (ElectrixTweaker.vinylMode[group]) { if (value) { - if (ElectrixTweaker.deckShift[group] || engine.getValue(group, 'passthrough')) { - engine.setValue(group, 'passthrough', ! engine.getValue(group, 'passthrough')) + if (ElectrixTweaker.deckShift[group] || engine.getValue(group, "passthrough")) { + engine.setValue(group, "passthrough", ! engine.getValue(group, "passthrough")); } else { - engine.setValue(group, 'vinylcontrol_enabled', ! engine.getValue(group, 'vinylcontrol_enabled')) + engine.setValue(group, "vinylcontrol_enabled", ! engine.getValue(group, "vinylcontrol_enabled")); } } } else { - if (engine.getValue(group, 'quantize')) { + if (engine.getValue(group, "quantize")) { if (value) { if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'beatjump_1_backward', 1) + engine.setValue(group, "beatjump_1_backward", 1); } else { - engine.setValue(group, 'beatjump_4_backward', 1) + engine.setValue(group, "beatjump_4_backward", 1); } } } else { if (ElectrixTweaker.deckShift[group]) { - engine.setValue(group, 'rate_temp_down', value / 127) + engine.setValue(group, "rate_temp_down", value / 127); } else { - engine.setValue(group, 'back', value) + engine.setValue(group, "back", value); } } } -} +}; diff --git a/res/controllers/Reloop-Beatmix-2-4-scripts.js b/res/controllers/Reloop-Beatmix-2-4-scripts.js index 655dc003b6a..96ab2e68f0e 100644 --- a/res/controllers/Reloop-Beatmix-2-4-scripts.js +++ b/res/controllers/Reloop-Beatmix-2-4-scripts.js @@ -8,8 +8,8 @@ * You can adjust these values to suit your needs by setting the two variables below. * Set them to -1 if you want to completely disable flashing at the end of track. **************************/ - var JogFlashWarningTime = 30; // number of seconds to slowly blink at the end of track - var JogFlashCriticalTime = 15; // number of seconds to quickly blink at the end of track +const JogFlashWarningTime = 30; // number of seconds to slowly blink at the end of track +const JogFlashCriticalTime = 15; // number of seconds to quickly blink at the end of track /************************ GPL v2 licence ***************************** @@ -58,76 +58,73 @@ //////////////////////////////////////////////////////////////////////// // JSHint configuration // //////////////////////////////////////////////////////////////////////// -/* global engine */ -/* global script */ /* global print */ -/* global midi */ //////////////////////////////////////////////////////////////////////// // Global variables and declarations. // ======================================================== var ReloopBeatmix24 = {}; -var RateRangeArray = [0.08, 0.10, 0.12, 0.16]; +const RateRangeArray = [0.08, 0.10, 0.12, 0.16]; // Timers & long press state -var jogWheelTimers = []; -var loadButtonTimers = []; -var loadButtonLongPressed = []; -var FxModeTimers = []; -var FxModeLongPressed = []; +const jogWheelTimers = []; +const loadButtonTimers = []; +const loadButtonLongPressed = []; +const FxModeTimers = []; +const FxModeLongPressed = []; // A variable to store previous value of some connectControls -var previousValue = []; +const previousValue = []; // Trax mode // 1 for playlist mode // 2 for track mode // 3 for preview mode -var traxMode = 2; +let traxMode = 2; // Effects mode // 1 for single effect mode (1 effect controlled in each EffectUnit) // 2 for multi-effect mode (3 effects controlled in each EffectUnit) // SHIFT + long press on pitchbend +/- to change mode -var FxMode = 1; // Single effect mode by default +let FxMode = 1; // Single effect mode by default // Jog Led variables // set JogFlashWarningTime and JogFlashCriticalTime to -1 to disable jog wheel flash -var JogRPM = 33.0 + 1/3, // Jog Wheel simulates a 33.3RPM turntable - RoundTripTime = 60.0 / JogRPM, // Time in seconds for a complete turn - JogLedNumber = 16, // number of leds (sections) on the jog wheel - JogBaseLed = 0x3f, // Midino of last led (we count backward to turn in the right side) - JogFlashWarningInterval = 400, // number of ms to wait when flashing slowly - JogFlashCriticalInterval = 200; // number of ms to wait when flashing quickly +const JogRPM = 33.0 + 1/3; // Jog Wheel simulates a 33.3RPM turntable +const RoundTripTime = 60.0 / JogRPM; // Time in seconds for a complete turn +const JogLedNumber = 16; // number of leds (sections) on the jog wheel +const JogBaseLed = 0x3f; // Midino of last led (we count backward to turn in the right side) +const JogFlashWarningInterval = 400; // number of ms to wait when flashing slowly +const JogFlashCriticalInterval = 200; // number of ms to wait when flashing quickly -var JogLedLit = []; -var channelPlaying = []; // Keeping track of channel playing -var JogBlinking = []; +const JogLedLit = []; +const channelPlaying = []; // Keeping track of channel playing +const JogBlinking = []; // Buttons and Led Variables -var ON = 0x7F, - OFF = 0x00, - RED = 0x7F, - BLUE = 0x55, - VIOLET = 0x2A, - SHIFT = 0x40, - DOWN = 0x7F, - UP = 0x00; +const ON = 0x7F; +const OFF = 0x00; +const RED = 0x7F; +//const BLUE = 0x55; +const VIOLET = 0x2A; +const SHIFT = 0x40; +const DOWN = 0x7F; +const UP = 0x00; // The SysEx message to send to the controller to force the midi controller // to send the status of every item on the control surface. -var ControllerStatusSysex = [0xF0, 0x00, 0x20, 0x7F, 0x03, 0x01, 0xF7]; +const ControllerStatusSysex = [0xF0, 0x00, 0x20, 0x7F, 0x03, 0x01, 0xF7]; // Some useful regex -var channelRegEx = /\[Channel(\d+)\]/; -var samplerRegEx = /\[Sampler(\d+)\]/; +const channelRegEx = /\[Channel(\d+)\]/; +const samplerRegEx = /\[Sampler(\d+)\]/; // Initialise and shutdown stuff. // ======================================================== ReloopBeatmix24.TurnLEDsOff = function() { // Turn all LEDS off - var i, j; + let i, j; for (i = 0x91; i <= 0x94; i++) { // 4 decks // Pads @@ -156,10 +153,10 @@ ReloopBeatmix24.TurnLEDsOff = function() { }; ReloopBeatmix24.connectControls = function() { - var group; + let group; // Channels controls - for (var i = 1; i <= 4; i++) { + for (let i = 1; i <= 4; i++) { group = "[Channel" + i + "]"; engine.connectControl(group, "track_samples", "ReloopBeatmix24.deckLoaded"); @@ -174,12 +171,12 @@ ReloopBeatmix24.connectControls = function() { "group_" + group + "_enable", 0); engine.setValue("[EffectRack1_EffectUnit2]", "group_" + group + "_enable", 0); - channelPlaying[group] = engine.getValue(group, "play") ? true : false; + channelPlaying[group] = !!engine.getValue(group, "play"); JogBlinking[group] = false; } // Samplers controls - for (i = 1; i <= 8; i++) { + for (let i = 1; i <= 8; i++) { group = "[Sampler" + i + "]"; engine.connectControl(group, "track_samples", "ReloopBeatmix24.deckLoaded"); @@ -192,12 +189,12 @@ ReloopBeatmix24.connectControls = function() { engine.setValue("[EffectRack1_EffectUnit2]", "group_[Master]_enable", 0); }; -ReloopBeatmix24.init = function(id, debug) { +ReloopBeatmix24.init = function(id, _debug) { ReloopBeatmix24.id = id; ReloopBeatmix24.TurnLEDsOff(); // Turn off all LEDs ReloopBeatmix24.connectControls(false); - for (var i = 1; i <= 4; i++) { + for (let i = 1; i <= 4; i++) { engine.trigger("[Channel" + i + "]", "loop_end_position"); } @@ -217,8 +214,8 @@ ReloopBeatmix24.shutdown = function() { // Button functions. // ======================================================== ReloopBeatmix24.GetNextRange = function(previous) { - var len = RateRangeArray.length; - var pos = RateRangeArray.indexOf(previous); + const len = RateRangeArray.length; + const pos = RateRangeArray.indexOf(previous); // If 'previous' is not found in the array, pos == -1 and (pos+1) == 0, // so this function will return the first element return RateRangeArray[(pos + 1) % len]; @@ -226,7 +223,7 @@ ReloopBeatmix24.GetNextRange = function(previous) { ReloopBeatmix24.Range = function(channel, control, value, status, group) { if (value === DOWN) { - var oldvalue = engine.getValue(group, "rateRange"); + const oldvalue = engine.getValue(group, "rateRange"); engine.setValue(group, "rateRange", ReloopBeatmix24.GetNextRange( oldvalue)); engine.softTakeoverIgnoreNextValue(group, "rate"); @@ -255,70 +252,69 @@ ReloopBeatmix24.PitchSlider = function(channel, control, value, status, group) { // ======================================================== ReloopBeatmix24.traxSelect = function(value, step) { switch (traxMode) { - case 1: // Playlist mode - var i, j; - for (i = 0; i < Math.abs(value); i++) { - for (j = 0; j < step; j++) { - if (value < 0) { - engine.setValue("[Playlist]", "SelectPrevPlaylist", - true); - } else { - engine.setValue("[Playlist]", "SelectNextPlaylist", - true); - } + case 1: // Playlist mode + for (let i = 0; i < Math.abs(value); i++) { + for (let j = 0; j < step; j++) { + if (value < 0) { + engine.setValue("[Playlist]", "SelectPrevPlaylist", + true); + } else { + engine.setValue("[Playlist]", "SelectNextPlaylist", + true); } } - break; - case 2: // Track mode - engine.setValue("[Playlist]", "SelectTrackKnob", value * step); - break; - case 3: // Preview mode - engine.setValue("[PreviewDeck1]", "playposition", Math.max(0, - Math.min(1, engine.getValue("[PreviewDeck1]", - "playposition") + 0.02 * value * step))); - break; + } + break; + case 2: // Track mode + engine.setValue("[Playlist]", "SelectTrackKnob", value * step); + break; + case 3: // Preview mode + engine.setValue("[PreviewDeck1]", "playposition", Math.max(0, + Math.min(1, engine.getValue("[PreviewDeck1]", + "playposition") + 0.02 * value * step))); + break; } }; -ReloopBeatmix24.TraxTurn = function(channel, control, value, status, group) { +ReloopBeatmix24.TraxTurn = function(channel, control, value, _status, _group) { ReloopBeatmix24.traxSelect(value - 0x40, 1); }; -ReloopBeatmix24.ShiftTraxTurn = function(channel, control, value, status, group) { +ReloopBeatmix24.ShiftTraxTurn = function(channel, control, value, _status, _group) { ReloopBeatmix24.traxSelect(value - 0x40, 10); }; -ReloopBeatmix24.TraxPush = function(channel, control, value, status, group) { +ReloopBeatmix24.TraxPush = function(channel, control, value, _status, _group) { switch (traxMode) { + case 1: // Playlist mode + engine.setValue("[Playlist]", "ToggleSelectedSidebarItem", + value); + break; + case 2: // Track mode + engine.setValue("[PreviewDeck1]", "LoadSelectedTrackAndPlay", + value); + traxMode = 3; + break; + case 3: // Preview mode + if (value === DOWN) { + script.toggleControl("[PreviewDeck1]", "play"); + } + break; + } +}; + +ReloopBeatmix24.BackButton = function(channel, control, value, _status, _group) { + if (value === DOWN) { + switch (traxMode) { case 1: // Playlist mode - engine.setValue("[Playlist]", "ToggleSelectedSidebarItem", - value); + traxMode = 2; // Switch to track mode break; case 2: // Track mode - engine.setValue("[PreviewDeck1]", "LoadSelectedTrackAndPlay", - value); - traxMode = 3; + traxMode = 1; // Switch to playlist mode break; case 3: // Preview mode - if (value == DOWN) { - script.toggleControl("[PreviewDeck1]", "play"); - } + traxMode = 2; // Switch to track mode break; - } -}; - -ReloopBeatmix24.BackButton = function(channel, control, value, status, group) { - if (value === DOWN) { - switch (traxMode) { - case 1: // Playlist mode - traxMode = 2; // Switch to track mode - break; - case 2: // Track mode - traxMode = 1; // Switch to playlist mode - break; - case 3: // Preview mode - traxMode = 2; // Switch to track mode - break; } } }; @@ -379,8 +375,8 @@ ReloopBeatmix24.ShiftSamplerPad = function(channel, control, value, status, } }; -ReloopBeatmix24.SamplerVol = function(channel, control, value, status, group) { - for (var i = 1; i <= engine.getValue("[Master]", "num_samplers"); i++) { +ReloopBeatmix24.SamplerVol = function(channel, control, value, _status, _group) { + for (let i = 1; i <= engine.getValue("[Master]", "num_samplers"); i++) { engine.setValue("[Sampler" + i + "]", "volume", value / 127.0); } }; @@ -389,10 +385,10 @@ ReloopBeatmix24.SamplerVol = function(channel, control, value, status, group) { // ======================================================== ReloopBeatmix24.WheelTouch = function(channel, control, value, status, group) { - var deck = parseInt(group.substr(8, 1), 10); + const deck = parseInt(group.substr(8, 1), 10); if (value === DOWN) { - var alpha = 1.0 / 8; - var beta = alpha / 32; + const alpha = 1.0 / 8; + const beta = alpha / 32; engine.scratchEnable(deck, 800, JogRPM, alpha, beta); } else { engine.scratchDisable(deck); @@ -400,33 +396,34 @@ ReloopBeatmix24.WheelTouch = function(channel, control, value, status, group) { }; ReloopBeatmix24.WheelTurn = function(channel, control, value, status, group) { - var newValue = value - 64; - var deck = parseInt(group.substr(8, 1), 10); + const newValue = value - 64; + const deck = parseInt(group.substr(8, 1), 10); // In either case, register the movement if (engine.isScratching(deck)) { engine.scratchTick(deck, newValue); // Scratch! } else { - engine.setValue(group, 'jog', newValue / 5); // Pitch bend + engine.setValue(group, "jog", newValue / 5); // Pitch bend } }; // Led Feedback functions // ======================================================== ReloopBeatmix24.AllJogLEDsToggle = function(deck, state, step) { - step = typeof step !== 'undefined' ? step : 1; // default value - for (var j = 0x30; j <= 0x3F; j += step) { + step = typeof step !== "undefined" ? step : 1; // default value + for (let j = 0x30; j <= 0x3F; j += step) { midi.sendShortMsg(deck, j, state); } }; -ReloopBeatmix24.deckLoaded = function(value, group, control) { - var i; +ReloopBeatmix24.deckLoaded = function(value, group, _control) { + let i; switch (group.substr(1, 7)) { - case "Channel": - var channelChan = parseInt(channelRegEx.exec(group)[1]); + case "Channel": + { + const channelChan = parseInt(channelRegEx.exec(group)[1]); if (channelChan <= 4) { - // shut down load button + // shut down load button midi.sendShortMsg(0x90 + channelChan, 0x50, value ? ON : OFF); @@ -438,19 +435,21 @@ ReloopBeatmix24.deckLoaded = function(value, group, control) { delete JogLedLit[group]; } } - break; - case "Sampler": - var samplerChan = parseInt(samplerRegEx.exec(group)[1]); + } + break; + case "Sampler": + { + const samplerChan = parseInt(samplerRegEx.exec(group)[1]); if (samplerChan <= 8) { // We only handle 8 samplers (1 per pad) for (i = 0x91; i <= 0x94; i++) { - // PAD1 Mode A + // PAD1 Mode A midi.sendShortMsg(i, 0x08 - 1 + samplerChan, value ? RED : OFF); // SHIFT+PAD1 Mode A midi.sendShortMsg(i, 0x48 - 1 + samplerChan, value ? RED : OFF); if (samplerChan <= 4) { // Handle first 4 samplers in split mode - // PAD5 Mode A+B (sampler 1 in split mode) + // PAD5 Mode A+B (sampler 1 in split mode) midi.sendShortMsg(i, 0x14 - 1 + samplerChan, value ? RED : OFF); // SHIFT+PAD5 Mode A+B (sampler 1 in split mode) @@ -459,14 +458,15 @@ ReloopBeatmix24.deckLoaded = function(value, group, control) { } } } - break; + } + break; } }; -ReloopBeatmix24.SamplerPlay = function(value, group, control) { - var samplerChan = parseInt(samplerRegEx.exec(group)[1]); +ReloopBeatmix24.SamplerPlay = function(value, group, _control) { + const samplerChan = parseInt(samplerRegEx.exec(group)[1]); if (samplerChan <= 8) { // We only handle 8 samplers (1 per pad) - var ledColor; + let ledColor; if (value) { ledColor = VIOLET; } else { @@ -475,7 +475,7 @@ ReloopBeatmix24.SamplerPlay = function(value, group, control) { // We need to switch off pad lights before changing color otherwise // VIOLET to RED transition does not work well. (???) - for (var i = 0x91; i <= 0x94; i++) { + for (let i = 0x91; i <= 0x94; i++) { // PAD1 Mode A midi.sendShortMsg(i, 0x08 - 1 + samplerChan, OFF); midi.sendShortMsg(i, 0x08 - 1 + samplerChan, ledColor); @@ -494,15 +494,15 @@ ReloopBeatmix24.SamplerPlay = function(value, group, control) { } }; -ReloopBeatmix24.loopDefined = function(value, group, control) { - var channelChan = parseInt(channelRegEx.exec(group)[1]); +ReloopBeatmix24.loopDefined = function(value, group, _control) { + const channelChan = parseInt(channelRegEx.exec(group)[1]); if (channelChan <= 4) { midi.sendShortMsg(0x90 + channelChan, 0x44, value < 0 ? OFF : VIOLET); } }; -ReloopBeatmix24.ChannelPlay = function(value, group, control) { +ReloopBeatmix24.ChannelPlay = function(value, group, _control) { // Keep track of the playing state of each channel to avoid // calling engine.getValue(group, "play") too often if (value) { @@ -513,7 +513,7 @@ ReloopBeatmix24.ChannelPlay = function(value, group, control) { engine.stopTimer(jogWheelTimers[group]); delete jogWheelTimers[group]; JogBlinking[group] = false; - var channelChan = parseInt(channelRegEx.exec(group)[1]); + const channelChan = parseInt(channelRegEx.exec(group)[1]); ReloopBeatmix24.AllJogLEDsToggle(0x90 + channelChan, OFF, 2); engine.trigger(group, "playposition"); // light up jog position led } @@ -524,12 +524,11 @@ ReloopBeatmix24.ChannelPlay = function(value, group, control) { // This function will light jog led and is connected to playposition, // so value here represent the position in the track in the range [-0.14..1.14] // (0 = beginning, 1 = end) -ReloopBeatmix24.JogLed = function(value, group, control) { - +ReloopBeatmix24.JogLed = function(value, group, _control) { // time computation - var trackDuration = engine.getValue(group, "duration"); - var timeLeft = trackDuration * (1.0 - value); - var channelChan = parseInt(channelRegEx.exec(group)[1]); + const trackDuration = engine.getValue(group, "duration"); + const timeLeft = trackDuration * (1.0 - value); + const channelChan = parseInt(channelRegEx.exec(group)[1]); // Start JogWheel blinking if playing and time left < warning time if (channelPlaying[group] && timeLeft <= JogFlashWarningTime) { @@ -554,10 +553,10 @@ ReloopBeatmix24.JogLed = function(value, group, control) { return; } - var timePosition = trackDuration * value; - var rotationNumber = timePosition / RoundTripTime; // number of turn since beginning - var positionInCircle = rotationNumber - Math.floor(rotationNumber); // decimal part - var ledToLight = Math.round(positionInCircle * JogLedNumber); + const timePosition = trackDuration * value; + const rotationNumber = timePosition / RoundTripTime; // number of turn since beginning + const positionInCircle = rotationNumber - Math.floor(rotationNumber); // decimal part + const ledToLight = Math.round(positionInCircle * JogLedNumber); if (JogLedLit[group] === ledToLight) { // exit if there is no change return; } @@ -572,17 +571,17 @@ ReloopBeatmix24.JogLed = function(value, group, control) { }; ReloopBeatmix24.jogLedFlash = function(group, state) { - var chan = parseInt(group.substr(8, 1), 10); + const chan = parseInt(group.substr(8, 1), 10); // toggle all jog leds ReloopBeatmix24.AllJogLEDsToggle(0x90 + chan, state ? OFF : ON, 2); - var timeleft = engine.getValue(group, "duration") * (1.0 - engine.getValue( + const timeleft = engine.getValue(group, "duration") * (1.0 - engine.getValue( group, "playposition")); if (timeleft < JogFlashWarningTime) { // Set timer for leds shut off - var nextTime = (timeleft < JogFlashCriticalTime ? + const nextTime = (timeleft < JogFlashCriticalTime ? JogFlashCriticalInterval : JogFlashWarningInterval); jogWheelTimers[group] = engine.beginTimer(nextTime, "ReloopBeatmix24.jogLedFlash(\"" + group + "\", " + @@ -599,8 +598,8 @@ ReloopBeatmix24.jogLedFlash = function(group, state) { // Effects functions // ======================================================== ReloopBeatmix24.FxModeLedFlash = function(step, mode) { - var i; - var ledValue = (step % 2) ? ON : OFF; + let i; + const ledValue = (step % 2) ? ON : OFF; if (step >= 7) { for (i = 1; i <= 4; i++) { // engine.trigger should be sufficient, but... @@ -608,8 +607,8 @@ ReloopBeatmix24.FxModeLedFlash = function(step, mode) { i + "]_enable"); engine.trigger("[EffectRack1_EffectUnit2]", "group_[Channel" + i + "]_enable"); - // Workaround for bug #1607277 as engine.trigger doesn't work well - var newValue = engine.getValue("[EffectRack1_EffectUnit1]", + // Workaround for issue #8620 as engine.trigger doesn't work well + let newValue = engine.getValue("[EffectRack1_EffectUnit1]", "group_[Channel" + i + "]_enable"); midi.sendShortMsg(0x90 + i, 0x25, newValue ? ON : OFF); midi.sendShortMsg(0x90 + i, 0x25 + SHIFT, newValue ? ON : OFF); @@ -633,7 +632,7 @@ ReloopBeatmix24.FxModeCallback = function(group, mode) { FxModeLongPressed[group] = true; delete FxModeTimers[group]; // give some visual feedback (blink led 3 times) - for (var i = 0x91; i <= 0x94; i++) { + for (let i = 0x91; i <= 0x94; i++) { midi.sendShortMsg(i, 0x26 - mode, OFF); midi.sendShortMsg(i, 0x26 + SHIFT - mode, OFF); } @@ -646,7 +645,7 @@ ReloopBeatmix24.FxModeCallback = function(group, mode) { // It is mapped to SHIFT + PITCHBEND+/- (FX1 and FX2) ReloopBeatmix24.ActivateFx = function(channel, control, value, status, group) { // Calculate Fx num based on midi control (0x66 for Fx1 and 0x67 for Fx2) - var FxNum = control - 0x65; + const FxNum = control - 0x65; if (value === DOWN) { if (FxModeTimers[group]) { engine.stopTimer(FxModeTimers[group]); @@ -671,8 +670,8 @@ ReloopBeatmix24.ActivateFx = function(channel, control, value, status, group) { }; ReloopBeatmix24.FxKnobTurn = function(channel, control, value, status, group) { - if (FxMode == 1) { - var parameter = control; + if (FxMode === 1) { + const parameter = control; engine.setParameter(group, "parameter" + parameter.toString(), script.absoluteLin(value, 0, 1)); } @@ -681,14 +680,14 @@ ReloopBeatmix24.FxKnobTurn = function(channel, control, value, status, group) { ReloopBeatmix24.ShiftFxKnobTurn = function(channel, control, value, status, group) { - if (FxMode == 1) { - var parameter = 3 + control - SHIFT; + if (FxMode === 1) { + const parameter = 3 + control - SHIFT; engine.setParameter(group, "parameter" + parameter.toString(), script.absoluteLin(value, 0, 1)); } else { - var effectUnit = parseInt(group.substr(23, 1), 10); - var Effect = control - SHIFT; - var storeIndex = "FX" + Effect.toString() + "U" + effectUnit.toString(); + const effectUnit = parseInt(group.substr(23, 1), 10); + const Effect = control - SHIFT; + const storeIndex = "FX" + Effect.toString() + "U" + effectUnit.toString(); if (storeIndex in previousValue) { if (value - previousValue[storeIndex] > 5) { engine.setValue("[EffectRack1_EffectUnit" + effectUnit + @@ -735,8 +734,8 @@ ReloopBeatmix24.ShiftFxKnobOnOff = function(channel, control, value, status, gro }; ReloopBeatmix24.FxEncoderTurn = function(channel, control, value, status, group) { - var newValue = value - 0x40; - if (FxMode == 1) { + const newValue = value - 0x40; + if (FxMode === 1) { engine.setValue(group, newValue > 0 ? "mix_up" : "mix_down", 1); } else { engine.setValue(group, newValue > 0 ? "super1_up" : "super1_down", 1); @@ -745,8 +744,8 @@ ReloopBeatmix24.FxEncoderTurn = function(channel, control, value, status, group) ReloopBeatmix24.ShiftFxEncoderTurn = function(channel, control, value, status, group) { - var newValue = value - 0x40; - if (FxMode == 1) { + const newValue = value - 0x40; + if (FxMode === 1) { engine.setValue(group, "chain_selector", newValue); } else { engine.setValue(group, newValue > 0 ? "mix_up" : "mix_down", 1);