From d30af760434b396eece5f8f451eba91d0d2da04b Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 14 Jan 2020 13:27:05 +0100 Subject: [PATCH 01/16] Roland DJ-505: Fix a few code style issues --- res/controllers/Roland_DJ-505-scripts.js | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/res/controllers/Roland_DJ-505-scripts.js b/res/controllers/Roland_DJ-505-scripts.js index 26c693f1f65c..0862793f9c8f 100644 --- a/res/controllers/Roland_DJ-505-scripts.js +++ b/res/controllers/Roland_DJ-505-scripts.js @@ -196,11 +196,11 @@ DJ505.init = function () { }; DJ505.autoShowDecks = function (value, group, control) { - var any_loaded = engine.getValue("[Channel3]", "track_loaded") || engine.getValue("[Channel4]", "track_loaded"); + var anyLoaded = engine.getValue("[Channel3]", "track_loaded") || engine.getValue("[Channel4]", "track_loaded"); if (!DJ505.autoShowFourDecks) { return; } - engine.setValue("[Master]", "show_4decks", any_loaded); + engine.setValue("[Master]", "show_4decks", anyLoaded); }; DJ505.shutdown = function () { @@ -688,9 +688,9 @@ DJ505.DeckToggleButton.prototype.input = function (channel, control, value, stat }; DJ505.DeckToggleButton.prototype.trigger = function () { this.send(this.secondaryDeck ? this.on : this.off); - var new_group = "[Channel" + (this.secondaryDeck ? this.decks[1] : this.decks[0]) + "]"; - if (this.loadTrackButton.group !== new_group) { - this.loadTrackButton.group = new_group; + var newGroup = "[Channel" + (this.secondaryDeck ? this.decks[1] : this.decks[0]) + "]"; + if (this.loadTrackButton.group !== newGroup) { + this.loadTrackButton.group = newGroup; this.loadTrackButton.disconnect(); this.loadTrackButton.connect(); this.loadTrackButton.trigger(); @@ -784,8 +784,8 @@ DJ505.Sampler = function() { if (!(bpm >= 5 && bpm <= 800)) { return; } - var bpm_value = Math.round(bpm*10); - midi.sendShortMsg(0xEA, bpm_value & 0x7f, (bpm_value >> 7) & 0x7f); + var bpmValue = Math.round(bpm*10); + midi.sendShortMsg(0xEA, bpmValue & 0x7f, (bpmValue >> 7) & 0x7f); this.syncDeck = deck; } }; @@ -1279,10 +1279,10 @@ DJ505.CueLoopMode = function (deck, offset) { unshift: function() { this.input = function (channel, control, value, status, group) { if (value) { - var hotcue_enabled = true; + var hotcueEnabled = true; if (!engine.getValue(group, "hotcue_" + this.number + "_enabled")) { // set a new cue point and loop - hotcue_enabled = false; + hotcueEnabled = false; script.triggerControl(group, "hotcue_" + this.number + "_activate"); } // jump to existing cue and loop @@ -1293,7 +1293,7 @@ DJ505.CueLoopMode = function (deck, offset) { // disable loop if currently enabled if (engine.getValue(group, "loop_enabled")) { - if (hotcue_enabled && + if (hotcueEnabled && engine.getValue(group, "loop_start_position") === startpos && engine.getValue(group, "loop_end_position") === endpos) { script.triggerControl(group, "loop_in_goto", 1); @@ -1309,7 +1309,7 @@ DJ505.CueLoopMode = function (deck, offset) { engine.setValue(group, "loop_end_position", endpos); // enable loop script.triggerControl(group, "reloop_toggle", 1); - if (hotcue_enabled) { + if (hotcueEnabled) { script.triggerControl(group, "loop_in_goto", 1); } } @@ -1343,7 +1343,7 @@ DJ505.CueLoopMode = function (deck, offset) { return; } this.sendRGB(color); - } else if (typeof color === 'number') { + } else if (typeof color === "number") { this.send(color); } }, @@ -1574,7 +1574,7 @@ DJ505.PitchPlayMode = function (deck, offset) { this.number = n + 1; this.on = this.color + DJ505.PadColor.DIM_MODIFIER; this.colors = pitchplayColors; - this.colorIdKey = 'hotcue_' + this.number + '_color_id'; + this.colorIdKey = "hotcue_" + this.number + "_color_id"; components.Button.call(this); }; this.PerformancePad.prototype = new components.Button({ @@ -1644,9 +1644,9 @@ DJ505.PitchPlayMode = function (deck, offset) { }; this.input = function (channel, control, value, status, group) { if (value > 0 && this.mode.cuepoint !== this.number && engine.getValue(this.group, "hotcue_" + this.number + "_enabled")) { - var previous_cuepoint = this.mode.cuepoint; + var previousCuepoint = this.mode.cuepoint; this.mode.cuepoint = this.number; - this.mode.pads[previous_cuepoint - 1].trigger(); + this.mode.pads[previousCuepoint - 1].trigger(); this.outputColor(engine.getValue(this.group, this.colorIdKey)); } }; From 3ffd2163f704a8e10ddd1387ade522ec20f970e0 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 14 Jan 2020 13:27:36 +0100 Subject: [PATCH 02/16] controllers/midi-components: Fix semicolon issues --- res/controllers/midi-components-0.0.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 7bb5c009578e..137886f83157 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -26,7 +26,7 @@ * the lodash.mixxx.js file in this directory for details. **/ -;(function (global) { +(function (global) { var Component = function (options) { if (Array.isArray(options) && typeof options[0] === 'number') { this.midi = options; @@ -659,7 +659,7 @@ && typeof component.shutdown === 'function') { component.shutdown(); } - }) + }); }, }; From 1235a188e03c8c5a6e64334bbaca261fad164c8d Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 14 Jan 2020 13:28:01 +0100 Subject: [PATCH 03/16] controllers/midi-components: Fix undeclared EffectUnit variable --- res/controllers/midi-components-0.0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 137886f83157..4bf073664780 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -718,7 +718,7 @@ } }); - EffectUnit = function (unitNumbers, allowFocusWhenParametersHidden, colors) { + var EffectUnit = function (unitNumbers, allowFocusWhenParametersHidden, colors) { var eu = this; this.focusChooseModeActive = false; From ed10dc8176374b3fa9b423c11e2b05a560388838 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 14 Jan 2020 13:33:53 +0100 Subject: [PATCH 04/16] controllers/midi-components: Use double quotes consistently --- res/controllers/midi-components-0.0.js | 242 ++++++++++++------------- 1 file changed, 121 insertions(+), 121 deletions(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 4bf073664780..8955985fcf7d 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -28,20 +28,20 @@ (function (global) { var Component = function (options) { - if (Array.isArray(options) && typeof options[0] === 'number') { + if (Array.isArray(options) && typeof options[0] === "number") { this.midi = options; } else { _.assign(this, options); } - if (typeof this.unshift === 'function') { + if (typeof this.unshift === "function") { this.unshift(); } // These cannot be in the prototype; they must be unique to each instance. this.isShifted = false; this.connections = []; - if (options !== undefined && typeof options.key === 'string') { + if (options !== undefined && typeof options.key === "string") { this.inKey = options.key; this.outKey = options.key; } @@ -122,7 +122,7 @@ if (undefined !== this.group && undefined !== this.outKey && undefined !== this.output && - typeof this.output === 'function') { + typeof this.output === "function") { this.connections[0] = engine.makeConnection(this.group, this.outKey, this.output); } }, @@ -220,13 +220,13 @@ }; PlayButton.prototype = new Button({ unshift: function () { - this.inKey = 'play'; + this.inKey = "play"; }, shift: function () { - this.inKey = 'reverse'; + this.inKey = "reverse"; }, type: Button.prototype.types.toggle, - outKey: 'play_indicator', + outKey: "play_indicator", }); var CueButton = function (options) { @@ -234,16 +234,16 @@ }; CueButton.prototype = new Button({ unshift: function () { - this.inKey = 'cue_default'; + this.inKey = "cue_default"; }, shift: function () { if (this.reverseRollOnShift) { - this.inKey = 'reverseroll'; + this.inKey = "reverseroll"; } else { - this.inKey = 'start_stop'; + this.inKey = "start_stop"; } }, - outKey: 'cue_indicator', + outKey: "cue_indicator", }); var SyncButton = function (options) { @@ -253,14 +253,14 @@ unshift: function () { this.input = function (channel, control, value, status, group) { if (this.isPress(channel, control, value, status)) { - if (engine.getValue(this.group, 'sync_enabled') === 0) { - engine.setValue(this.group, 'beatsync', 1); + if (engine.getValue(this.group, "sync_enabled") === 0) { + engine.setValue(this.group, "beatsync", 1); this.longPressTimer = engine.beginTimer(this.longPressTimeout, function () { - engine.setValue(this.group, 'sync_enabled', 1); + engine.setValue(this.group, "sync_enabled", 1); this.longPressTimer = 0; }, true); } else { - engine.setValue(this.group, 'sync_enabled', 0); + engine.setValue(this.group, "sync_enabled", 0); } } else { if (this.longPressTimer !== 0) { @@ -271,45 +271,45 @@ }; }, shift: function () { - this.inKey = 'quantize'; + this.inKey = "quantize"; this.type = Button.prototype.types.toggle; this.input = Button.prototype.input; }, - outKey: 'sync_enabled', + outKey: "sync_enabled", }); var LoopToggleButton = function (options) { Button.call(this, options); }; LoopToggleButton.prototype = new Button({ - inKey: 'reloop_exit', + inKey: "reloop_exit", inValueScale: function () { return 1; }, - outKey: 'loop_enabled', + outKey: "loop_enabled", }); var HotcueButton = function (options) { if (options.number === undefined) { - print('ERROR: No hotcue number specified for new HotcueButton.'); + print("ERROR: No hotcue number specified for new HotcueButton."); return; } if (options.colors !== undefined || options.sendRGB !== undefined) { - this.colorIdKey = 'hotcue_' + options.number + '_color_id'; + this.colorIdKey = "hotcue_" + options.number + "_color_id"; if (options.colors === undefined) { options.colors = color.predefinedColorsList(); } } this.number = options.number; - this.outKey = 'hotcue_' + this.number + '_enabled'; + this.outKey = "hotcue_" + this.number + "_enabled"; Button.call(this, options); }; HotcueButton.prototype = new Button({ unshift: function () { - this.inKey = 'hotcue_' + this.number + '_activate'; + this.inKey = "hotcue_" + this.number + "_activate"; }, shift: function () { - this.inKey = 'hotcue_' + this.number + '_clear'; + this.inKey = "hotcue_" + this.number + "_clear"; }, getColor: function() { if (this.colorIdKey !== undefined) { @@ -342,7 +342,7 @@ return; } this.sendRGB(color); - } else if (typeof color === 'number') { + } else if (typeof color === "number") { this.send(color); } }, @@ -359,25 +359,25 @@ }); var SamplerButton = function (options) { if (options.number === undefined) { - print('ERROR: No sampler number specified for new SamplerButton.'); + print("ERROR: No sampler number specified for new SamplerButton."); return; } this.volumeByVelocity = options.volumeByVelocity; this.number = options.number; - this.group = '[Sampler' + this.number + ']'; + this.group = "[Sampler" + this.number + "]"; Button.call(this, options); }; SamplerButton.prototype = new Button({ unshift: function () { this.input = function (channel, control, value, status, group) { if (this.isPress(channel, control, value, status)) { - if (engine.getValue(this.group, 'track_loaded') === 0) { - engine.setValue(this.group, 'LoadSelectedTrack', 1); + if (engine.getValue(this.group, "track_loaded") === 0) { + engine.setValue(this.group, "LoadSelectedTrack", 1); } else { if (this.volumeByVelocity) { - engine.setValue(this.group, 'volume', this.inValueScale(value)); + engine.setValue(this.group, "volume", this.inValueScale(value)); } - engine.setValue(this.group, 'cue_gotoandplay', 1); + engine.setValue(this.group, "cue_gotoandplay", 1); } } }; @@ -385,26 +385,26 @@ shift: function() { this.input = function (channel, control, value, status, group) { if (this.isPress(channel, control, value, status)) { - if (engine.getValue(this.group, 'play') === 1) { - engine.setValue(this.group, 'play', 0); + if (engine.getValue(this.group, "play") === 1) { + engine.setValue(this.group, "play", 0); } else { - engine.setValue(this.group, 'eject', 1); + engine.setValue(this.group, "eject", 1); } } else { - if (engine.getValue(this.group, 'play') === 0) { - engine.setValue(this.group, 'eject', 0); + if (engine.getValue(this.group, "play") === 0) { + engine.setValue(this.group, "eject", 0); } } }; }, output: function (value, group, control) { - if (engine.getValue(this.group, 'track_loaded') === 1) { + if (engine.getValue(this.group, "track_loaded") === 1) { if (this.loaded === undefined) { this.send(this.on); } else { - if (engine.getValue(this.group, 'play') === 1) { + if (engine.getValue(this.group, "play") === 1) { if (this.looping !== undefined && - engine.getValue(this.group, 'repeat') === 1) { + engine.getValue(this.group, "repeat") === 1) { this.send(this.looping); } else { this.send(this.playing); @@ -422,20 +422,20 @@ } }, connect: function() { - this.connections[0] = engine.makeConnection(this.group, 'track_loaded', this.output); + this.connections[0] = engine.makeConnection(this.group, "track_loaded", this.output); if (this.playing !== undefined) { - this.connections[1] = engine.makeConnection(this.group, 'play', this.output); + this.connections[1] = engine.makeConnection(this.group, "play", this.output); } if (this.looping !== undefined) { - this.connections[2] = engine.connectControl(this.group, 'repeat', this.output); + this.connections[2] = engine.connectControl(this.group, "repeat", this.output); } }, outKey: null, // hack to get Component constructor to call connect() }); var EffectAssignmentButton = function (options) { - options.key = 'group_' + options.group + '_enable'; - options.group = '[EffectRack1_EffectUnit' + options.effectUnit + ']'; + options.key = "group_" + options.group + "_enable"; + options.group = "[EffectRack1_EffectUnit" + options.effectUnit + "]"; Button.call(this, options); }; EffectAssignmentButton.prototype = new Button({ @@ -502,14 +502,14 @@ Encoder.prototype = new Component(); var ComponentContainer = function (initialLayer) { - if (typeof initialLayer === 'object') { + if (typeof initialLayer === "object") { this.applyLayer(initialLayer); } }; ComponentContainer.prototype = { forEachComponent: function (operation, recursive) { - if (typeof operation !== 'function') { - print('ERROR: ComponentContainer.forEachComponent requires a function argument'); + if (typeof operation !== "function") { + print("ERROR: ComponentContainer.forEachComponent requires a function argument"); return; } if (recursive === undefined) { recursive = true; } @@ -534,8 +534,8 @@ } }, forEachComponentContainer: function (operation, recursive) { - if (typeof operation !== 'function') { - print('ERROR: ComponentContainer.forEachComponentContainer requires a function argument'); + if (typeof operation !== "function") { + print("ERROR: ComponentContainer.forEachComponentContainer requires a function argument"); return; } if (recursive === undefined) { recursive = true; } @@ -564,7 +564,7 @@ reconnectComponents: function (operation, recursive) { this.forEachComponent(function (component) { component.disconnect(); - if (typeof operation === 'function') { + if (typeof operation === "function") { operation.call(this, component); } component.connect(); @@ -584,13 +584,13 @@ // shifted state, and the unshifted inKey would not get reset to 0. // To work around this, reset push Buttons' inKey to 0 when the shift // button is pressed. - if (typeof component.shift === 'function') { + if (typeof component.shift === "function") { if (component instanceof Button && (component.type === Button.prototype.types.push || component.type === undefined) && component.input === Button.prototype.input - && typeof component.inKey === 'string' - && typeof component.group === 'string') { + && typeof component.inKey === "string" + && typeof component.group === "string") { if (engine.getValue(component.group, component.inKey) !== 0) { engine.setValue(component.group, component.inKey, 0); } @@ -611,13 +611,13 @@ // Unshift direct child Components this.forEachComponent(function (component) { // Refer to comment in ComponentContainer.shift() above for explanation - if (typeof component.unshift === 'function') { + if (typeof component.unshift === "function") { if (component instanceof Button && (component.type === Button.prototype.types.push || component.type === undefined) && component.input === Button.prototype.input - && typeof component.inKey === 'string' - && typeof component.group === 'string') { + && typeof component.inKey === "string" + && typeof component.group === "string") { if (engine.getValue(component.group, component.inKey) !== 0) { engine.setValue(component.group, component.inKey, 0); } @@ -656,7 +656,7 @@ shutdown: function () { this.forEachComponent(function (component) { if (component.shutdown !== undefined - && typeof component.shutdown === 'function') { + && typeof component.shutdown === "function") { component.shutdown(); } }); @@ -668,16 +668,16 @@ if (Array.isArray(deckNumbers)) { // These must be unique to each instance, // so they cannot be in the prototype. - this.currentDeck = '[Channel' + deckNumbers[0] + ']'; + this.currentDeck = "[Channel" + deckNumbers[0] + "]"; this.deckNumbers = deckNumbers; - } else if (typeof deckNumbers === 'number' && + } else if (typeof deckNumbers === "number" && Math.floor(deckNumbers) === deckNumbers && isFinite(deckNumbers)) { - this.currentDeck = '[Channel' + deckNumbers + ']'; + this.currentDeck = "[Channel" + deckNumbers + "]"; this.deckNumbers = [deckNumbers]; } } else { - print('ERROR! new Deck() called without specifying any deck numbers'); + print("ERROR! new Deck() called without specifying any deck numbers"); return; } }; @@ -689,9 +689,9 @@ || component.group.search(script.channelRegEx) !== -1) { component.group = newGroup; } else if (component.group.search(script.eqRegEx) !== -1) { - component.group = '[EqualizerRack1_' + newGroup + '_Effect1]'; + component.group = "[EqualizerRack1_" + newGroup + "_Effect1]"; } else if (component.group.search(script.quickEffectRegEx) !== -1) { - component.group = '[QuickEffectRack1_' + newGroup + ']'; + component.group = "[QuickEffectRack1_" + newGroup + "]"; } // Do not alter the Component's group if it does not match any of those RegExs. @@ -699,8 +699,8 @@ // The ControlObjects for assigning decks to effect units // indicate the effect unit with the group and the deck with the key, // so change the key here instead of the group. - component.inKey = 'group_' + newGroup + '_enable'; - component.outKey = 'group_' + newGroup + '_enable'; + component.inKey = "group_" + newGroup + "_enable"; + component.outKey = "group_" + newGroup + "_enable"; } }); }, @@ -729,16 +729,16 @@ // when show_parameters button is clicked in skin. // Otherwise this.previouslyFocusedEffect would always be set to 0 // on the second call. - if (engine.getValue(eu.group, 'show_focus') > 0) { - engine.setValue(eu.group, 'show_focus', 0); + if (engine.getValue(eu.group, "show_focus") > 0) { + engine.setValue(eu.group, "show_focus", 0); eu.previouslyFocusedEffect = engine.getValue(eu.group, "focused_effect"); engine.setValue(eu.group, "focused_effect", 0); } } else { - engine.setValue(eu.group, 'show_focus', 1); + engine.setValue(eu.group, "show_focus", 1); if (eu.previouslyFocusedEffect !== undefined) { - engine.setValue(eu.group, 'focused_effect', + engine.setValue(eu.group, "focused_effect", eu.previouslyFocusedEffect); } } @@ -752,7 +752,7 @@ this.setCurrentUnit = function (newNumber) { this.currentUnitNumber = newNumber; if (allowFocusWhenParametersHidden) { - engine.setValue(this.group, 'show_focus', 0); + engine.setValue(this.group, "show_focus", 0); } else { if (this.showParametersConnection !== undefined) { this.showParametersConnection.disconnect(); @@ -760,17 +760,17 @@ delete this.previouslyFocusedEffect; } - this.group = '[EffectRack1_EffectUnit' + newNumber + ']'; + this.group = "[EffectRack1_EffectUnit" + newNumber + "]"; if (allowFocusWhenParametersHidden) { - engine.setValue(this.group, 'show_focus', 1); + engine.setValue(this.group, "show_focus", 1); } else { // Connect a callback to show_parameters changing instead of // setting show_focus when effectFocusButton is pressed so // show_focus is always in the correct state, even if the user // presses the skin button for show_parameters. this.showParametersConnection = engine.makeConnection(this.group, - 'show_parameters', + "show_parameters", this.onShowParametersChange); this.showParametersConnection.trigger(); } @@ -779,12 +779,12 @@ // so initial values can be loaded from knobs. if (this.hasInitialized === true) { for (var n = 1; n <= 3; n++) { - var effect = '[EffectRack1_EffectUnit' + this.currentUnitNumber + - '_Effect' + n + ']'; - engine.softTakeover(effect, 'meta', true); - engine.softTakeover(effect, 'parameter1', true); - engine.softTakeover(effect, 'parameter2', true); - engine.softTakeover(effect, 'parameter3', true); + var effect = "[EffectRack1_EffectUnit" + this.currentUnitNumber + + "_Effect" + n + "]"; + engine.softTakeover(effect, "meta", true); + engine.softTakeover(effect, "parameter1", true); + engine.softTakeover(effect, "parameter2", true); + engine.softTakeover(effect, "parameter3", true); } } @@ -797,9 +797,9 @@ // update [EffectRack1_EffectUnitX_EffectY] groups var effectMatch = component.group.match(script.individualEffectRegEx); if (effectMatch !== null) { - component.group = '[EffectRack1_EffectUnit' + + component.group = "[EffectRack1_EffectUnit" + eu.currentUnitNumber + - '_Effect' + effectMatch[2] + ']'; + "_Effect" + effectMatch[2] + "]"; } } }); @@ -820,27 +820,27 @@ if (Array.isArray(unitNumbers)) { this.unitNumbers = unitNumbers; this.setCurrentUnit(unitNumbers[0]); - } else if (typeof unitNumbers === 'number' && + } else if (typeof unitNumbers === "number" && Math.floor(unitNumbers) === unitNumbers && isFinite(unitNumbers)) { this.unitNumbers = [unitNumbers]; this.setCurrentUnit(unitNumbers); } } else { - print('ERROR! new EffectUnit() called without specifying any unit numbers!'); + print("ERROR! new EffectUnit() called without specifying any unit numbers!"); return; } this.dryWetKnob = new Pot({ group: this.group, unshift: function () { - this.inKey = 'mix'; + this.inKey = "mix"; // for soft takeover this.disconnect(); this.connect(); }, shift: function () { - this.inKey = 'super1'; + this.inKey = "super1"; // for soft takeover this.disconnect(); this.connect(); @@ -857,7 +857,7 @@ this.enableOnChannelButtons.addButton = function (channel) { this[channel] = new Button({ group: eu.group, - key: 'group_[' + channel + ']_enable', + key: "group_[" + channel + "]_enable", type: Button.prototype.types.toggle, outConnect: false, }); @@ -877,12 +877,12 @@ this.inSetParameter(this.inValueScale(value)); if (this.previousValueReceived === undefined) { - var effect = '[EffectRack1_EffectUnit' + eu.currentUnitNumber + - '_Effect' + this.number + ']'; - engine.softTakeover(effect, 'meta', true); - engine.softTakeover(effect, 'parameter1', true); - engine.softTakeover(effect, 'parameter2', true); - engine.softTakeover(effect, 'parameter3', true); + var effect = "[EffectRack1_EffectUnit" + eu.currentUnitNumber + + "_Effect" + this.number + "]"; + engine.softTakeover(effect, "meta", true); + engine.softTakeover(effect, "parameter1", true); + engine.softTakeover(effect, "parameter2", true); + engine.softTakeover(effect, "parameter3", true); } this.previousValueReceived = value; }; @@ -892,7 +892,7 @@ this.valueAtLastEffectSwitch = this.previousValueReceived; // Floor the threshold to ensure that every effect can be selected this.changeThreshold = Math.floor(this.max / - engine.getValue('[Master]', 'num_effectsavailable')); + engine.getValue("[Master]", "num_effectsavailable")); this.input = function (channel, control, value, status, group) { if (this.MSB !== undefined) { @@ -903,10 +903,10 @@ // this.valueAtLastEffectSwitch can be undefined if // shift was pressed before the first MIDI value was received. || this.valueAtLastEffectSwitch === undefined) { - var effectGroup = '[EffectRack1_EffectUnit' + - eu.currentUnitNumber + '_Effect' + - this.number + ']'; - engine.setValue(effectGroup, 'effect_selector', change); + var effectGroup = "[EffectRack1_EffectUnit" + + eu.currentUnitNumber + "_Effect" + + this.number + "]"; + engine.setValue(effectGroup, "effect_selector", change); this.valueAtLastEffectSwitch = value; } @@ -927,14 +927,14 @@ }, onFocusChange: function (value, group, control) { if (value === 0) { - this.group = '[EffectRack1_EffectUnit' + - eu.currentUnitNumber + '_Effect' + - this.number + ']'; - this.inKey = 'meta'; + this.group = "[EffectRack1_EffectUnit" + + eu.currentUnitNumber + "_Effect" + + this.number + "]"; + this.inKey = "meta"; } else { - this.group = '[EffectRack1_EffectUnit' + eu.currentUnitNumber + - '_Effect' + value + ']'; - this.inKey = 'parameter' + this.number; + this.group = "[EffectRack1_EffectUnit" + eu.currentUnitNumber + + "_Effect" + value + "]"; + this.inKey = "parameter" + this.number; } engine.softTakeoverIgnoreNextValue(this.group, this.inKey); }, @@ -942,8 +942,8 @@ this.EffectEnableButton = function (number) { this.number = number; - this.group = '[EffectRack1_EffectUnit' + eu.currentUnitNumber + - '_Effect' + this.number + ']'; + this.group = "[EffectRack1_EffectUnit" + eu.currentUnitNumber + + "_Effect" + this.number + "]"; Button.call(this); }; this.EffectEnableButton.prototype = new Button({ @@ -954,19 +954,19 @@ if (colors !== undefined) { this.color = colors.unfocused; } - this.group = '[EffectRack1_EffectUnit' + - eu.currentUnitNumber + '_Effect' + - this.number + ']'; - this.inKey = 'enabled'; - this.outKey = 'enabled'; + this.group = "[EffectRack1_EffectUnit" + + eu.currentUnitNumber + "_Effect" + + this.number + "]"; + this.inKey = "enabled"; + this.outKey = "enabled"; } else { if (colors !== undefined) { this.color = colors.focused; } - this.group = '[EffectRack1_EffectUnit' + eu.currentUnitNumber + - '_Effect' + value + ']'; - this.inKey = 'button_parameter' + this.number; - this.outKey = 'button_parameter' + this.number; + this.group = "[EffectRack1_EffectUnit" + eu.currentUnitNumber + + "_Effect" + value + "]"; + this.inKey = "button_parameter" + this.number; + this.outKey = "button_parameter" + this.number; } }, stopEffectFocusChooseMode: function () { @@ -992,10 +992,10 @@ this.trigger(); }; this.shift = function () { - this.group = '[EffectRack1_EffectUnit' + - eu.currentUnitNumber + '_Effect' + - this.number + ']'; - this.inKey = 'enabled'; + this.group = "[EffectRack1_EffectUnit" + + eu.currentUnitNumber + "_Effect" + + this.number + "]"; + this.inKey = "enabled"; }; if (this.isShifted) { this.shift(); @@ -1057,7 +1057,7 @@ }, setColor: function () { if (colors !== undefined) { - if (engine.getValue(this.group, 'focused_effect') === 0) { + if (engine.getValue(this.group, "focused_effect") === 0) { this.color = colors.unfocused; } else { this.color = colors.focused; @@ -1111,7 +1111,7 @@ } }; }, - outKey: 'focused_effect', + outKey: "focused_effect", output: function (value, group, control) { this.send((value > 0) ? this.on : this.off); }, From a991cbccd6a1e640b36245830e2af1997ff89741 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 14 Jan 2020 13:53:46 +0100 Subject: [PATCH 05/16] script/svg: Remove unused variable --- script/svg/__init__.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/script/svg/__init__.js b/script/svg/__init__.js index 8f5d6f570bf5..ee30315ceff5 100644 --- a/script/svg/__init__.js +++ b/script/svg/__init__.js @@ -25,8 +25,7 @@ function isNumber(n) { } svg.getHooksPattern = function(){ - var hookNames = [], - that = this; + var hookNames = []; for( var i in this.templateHooks ) hookNames.push(i); From 3285db6abb2d879b1c837380084831b6139e7ce0 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 17 Jan 2020 11:57:14 +0100 Subject: [PATCH 06/16] Roland DJ-505: Add "_" prefix to unused arguments --- res/controllers/Roland_DJ-505-scripts.js | 76 ++++++++++++------------ 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/res/controllers/Roland_DJ-505-scripts.js b/res/controllers/Roland_DJ-505-scripts.js index 0862793f9c8f..2ec63575019c 100644 --- a/res/controllers/Roland_DJ-505-scripts.js +++ b/res/controllers/Roland_DJ-505-scripts.js @@ -75,7 +75,7 @@ DJ505.trsGroup = "Auxiliary1"; // TR-S input DJ505.init = function () { var i, j; - DJ505.shiftButton = function (channel, control, value, status, group) { + DJ505.shiftButton = function (channel, control, value, _status, _group) { DJ505.deck.concat(DJ505.effectUnit, [DJ505.sampler, DJ505.browseEncoder]).forEach( value ? function (module) { module.shift(); } : function (module) { module.unshift(); } ); @@ -97,7 +97,7 @@ DJ505.init = function () { shift: function () { this.inKey = "eject"; }, - input: function (channel, control, value, status, group) { + input: function (channel, control, value, status, _group) { this.send(this.isPress(channel, control, value, status) ? this.on : this.off); components.Button.prototype.input.apply(this, arguments); }, @@ -117,7 +117,7 @@ DJ505.init = function () { shift: function () { this.inKey = "eject"; }, - input: function (channel, control, value, status, group) { + input: function (channel, control, value, status, _group) { this.send(this.isPress(channel, control, value, status) ? this.on : this.off); components.Button.prototype.input.apply(this, arguments); }, @@ -144,7 +144,7 @@ DJ505.init = function () { DJ505.effectUnit[i].knobs[2].midi = [0xB8 + i, 0x01]; DJ505.effectUnit[i].knobs[3].midi = [0xB8 + i, 0x02]; DJ505.effectUnit[i].dryWetKnob.midi = [0xB8 + i, 0x03]; - DJ505.effectUnit[i].dryWetKnob.input = function (channel, control, value, status, group) { + DJ505.effectUnit[i].dryWetKnob.input = function (channel, control, value, _status, _group) { if (value === 1) { // 0.05 is an example. Adjust that value to whatever works well for your controller. this.inSetParameter(this.inGetParameter() + 0.05); @@ -158,7 +158,7 @@ DJ505.init = function () { } DJ505.effectUnit[i].enableOnChannelButtons.addButton(DJ505.trsGroup); DJ505.effectUnit[i].enableOnChannelButtons[DJ505.trsGroup].midi = [0x98 + i, 0x09]; - DJ505.effectUnit[i].enableOnChannelButtons[DJ505.trsGroup].input = function (channel, control, value, status, group) { + DJ505.effectUnit[i].enableOnChannelButtons[DJ505.trsGroup].input = function (channel, control, value, status, _group) { components.Button.prototype.input.apply(this, arguments); if (this.isPress(channel, control, value, status)) { var enabled = this.inGetValue(); @@ -195,7 +195,7 @@ DJ505.init = function () { } }; -DJ505.autoShowDecks = function (value, group, control) { +DJ505.autoShowDecks = function (_value, _group, _control) { var anyLoaded = engine.getValue("[Channel3]", "track_loaded") || engine.getValue("[Channel4]", "track_loaded"); if (!DJ505.autoShowFourDecks) { return; @@ -267,7 +267,7 @@ DJ505.browseEncoder = new components.Encoder({ } }; }, - input: function (channel, control, value, status, group) { + input: function (channel, control, value, status, _group) { switch (status) { case 0xBF: // Rotate. var rotateValue = (value === 127) ? -1 : ((value === 1) ? 1 : 0); @@ -299,7 +299,7 @@ DJ505.addPrepareButton = new components.Button({ }); -DJ505.sortLibrary = function (channel, control, value, status, group) { +DJ505.sortLibrary = function (channel, control, value, _status, _group) { if (value === 0) { return; } @@ -338,7 +338,7 @@ DJ505.crossfader = new components.Pot({ components.Pot.prototype.input.apply(this, arguments); } }); -DJ505.crossfader.setCurve = function (channel, control, value, status, group) { +DJ505.crossfader.setCurve = function (channel, control, value, _status, _group) { // 0x00 is Picnic Bench, 0x01 is Constant Power and 0x02 is Linear switch(value) { case 0x00: // Picnic Bench / Fast Cut @@ -358,12 +358,12 @@ DJ505.crossfader.setCurve = function (channel, control, value, status, group) { } }; -DJ505.crossfader.setReverse = function (channel, control, value, status, group) { +DJ505.crossfader.setReverse = function (channel, control, value, _status, _group) { // 0x00 is ON, 0x01 is OFF engine.setValue("[Mixer Profile]", "xFaderReverse", (value === 0x00) ? 1 : 0); }; -DJ505.setChannelInput = function (channel, control, value, status, group) { +DJ505.setChannelInput = function (channel, control, value, _status, _group) { var number = (channel === 0x00) ? 0 : 1; var channelgroup = "[Channel" + (number + 1) + "]"; switch(value) { @@ -416,7 +416,7 @@ DJ505.Deck = function (deckNumbers, offset) { // ============================= JOG WHEELS ================================= - this.wheelTouch = function (channel, control, value, status, group) { + this.wheelTouch = function (channel, control, value, _status, _group) { if (value === 0x7F && !this.isShifted) { var alpha = 1.0/8; var beta = alpha/32; @@ -426,7 +426,7 @@ DJ505.Deck = function (deckNumbers, offset) { } }; - this.wheelTurn = function (channel, control, value, status, group) { + this.wheelTurn = function (channel, control, value, _status, _group) { // When the jog wheel is turned in clockwise direction, value is // greater than 64 (= 0x40). If it's turned in counter-clockwise // direction, the value is smaller than 64. @@ -513,7 +513,7 @@ DJ505.Deck = function (deckNumbers, offset) { shift: function () { this.inKey = "rateRange"; this.type = undefined; - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { this.currentRangeIndex++; if (this.currentRangeIndex >= DJ505.tempoRange.length) { @@ -555,11 +555,11 @@ DJ505.Deck = function (deckNumbers, offset) { this.sync = new components.Button({ midi: [0x90 + offset, 0x02], outKey: "sync_enabled", - output: function (value, group, control) { + output: function (value, _group, _control) { midi.sendShortMsg(this.midi[0], value ? 0x02 : 0x03, 0x7F); }, unshift: function () { - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { script.triggerControl(this.group, "beatsync", 1); if (engine.getValue(this.group, "sync_enabled") === 0) { @@ -577,7 +577,7 @@ DJ505.Deck = function (deckNumbers, offset) { }; }, shift: function () { - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, _status, _group) { if (value) { engine.setValue(this.group, "sync_enabled", 0); } @@ -642,7 +642,7 @@ DJ505.Deck = function (deckNumbers, offset) { midi: [0xB0 + offset, 0x1F], group: "[Channel" + deckNumbers + "]", outKey: "VuMeter", - output: function (value, group, control) { + output: function (value, group, _control) { // The red LEDs light up with MIDI values greater than 0x24. The // maximum brightness is reached at value 0x28. Red LEDs should // only be illuminated if the track is clipping. @@ -664,7 +664,7 @@ DJ505.DeckToggleButton = function(options) { components.Button.call(this, options); }; DJ505.DeckToggleButton.prototype = Object.create(components.Button.prototype); -DJ505.DeckToggleButton.prototype.input = function (channel, control, value, status, group) { +DJ505.DeckToggleButton.prototype.input = function (channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { // Button was pressed this.longPressTimer = engine.beginTimer( @@ -766,7 +766,7 @@ DJ505.Sampler = function() { return newdeck; }; - this.syncButtonPressed = function (channel, control, value, status, group) { + this.syncButtonPressed = function (channel, control, value, _status, _group) { if (value !== 0x7f) { return; } @@ -790,14 +790,14 @@ DJ505.Sampler = function() { } }; - this.bpmKnobTurned = function (channel, control, value, status, group) { + this.bpmKnobTurned = function (channel, control, value, _status, _group) { if (this.syncDeck >= 0) { var bpm = ((value << 7) | control) / 10; engine.setValue("[Channel" + (this.syncDeck + 1) + "]", "bpm", bpm); } }; - this.startStopButtonPressed = function (channel, control, value, status, group) { + this.startStopButtonPressed = function (channel, control, value, status, _group) { if (status === 0xFA) { this.playbackCounter = 1; this.playbackTimer = engine.beginTimer(500, function() { @@ -823,7 +823,7 @@ DJ505.Sampler = function() { this.levelKnob = new components.Pot({ group: "[" + DJ505.trsGroup + "]", inKey: "volume", - input: function (channel, control, value, status, group) { + input: function (_channel, _control, _value, _status, _group) { components.Pot.prototype.input.apply(this, arguments); var volume = this.inGetParameter(); for (var i = 1; i <= 16; i++) { @@ -837,7 +837,7 @@ DJ505.Sampler = function() { key: "pfl", type: components.Button.prototype.types.toggle, midi: [0x9F, 0x1D], - input: function (channel, control, value, status, group) { + input: function (_channel, _control, _value, _status, _group) { components.Button.prototype.input.apply(this, arguments); var pfl = this.inGetValue(); for (var i = 1; i <= 16; i++) { @@ -862,7 +862,7 @@ DJ505.SlipModeButton = function (options) { }; DJ505.SlipModeButton.prototype = Object.create(components.Button.prototype); DJ505.SlipModeButton.prototype.unshift = function () { - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, _status, _group) { if (value) { // Button press. this.inSetValue(true); return; @@ -1112,7 +1112,7 @@ DJ505.PadSection.prototype.controlToPadMode = function (control) { return mode; }; -DJ505.PadSection.prototype.padModeButtonPressed = function (channel, control, value, status, group) { +DJ505.PadSection.prototype.padModeButtonPressed = function (channel, control, _value, _status, _group) { this.setPadMode(control); }; @@ -1427,7 +1427,7 @@ DJ505.RollMode = function (deck, offset) { on: DJ505.PadColor.ORANGE, off: DJ505.PadColor.ORANGE + DJ505.PadColor.DIM_MODIFIER, mode: this, - input: function (channel, control, value, status, group) { + input: function (channel, control, value, _status, _group) { if (value) { var jumpSize = engine.getValue(this.group, "beatjump_size"); if (jumpSize > this.mode.minSize) { @@ -1435,7 +1435,7 @@ DJ505.RollMode = function (deck, offset) { } } }, - output: function (value, group, control) { + output: function (value, _group, _control) { this.send((value > this.mode.minSize) ? this.on : this.off); }, }); @@ -1450,7 +1450,7 @@ DJ505.RollMode = function (deck, offset) { on: DJ505.PadColor.ORANGE, off: DJ505.PadColor.ORANGE + DJ505.PadColor.DIM_MODIFIER, mode: this, - input: function (channel, control, value, status, group) { + input: function (channel, control, value, _status, _group) { if (value) { var jumpSize = engine.getValue(this.group, "beatjump_size"); if (jumpSize < this.mode.maxSize) { @@ -1458,7 +1458,7 @@ DJ505.RollMode = function (deck, offset) { } } }, - output: function (value, group, control) { + output: function (value, _group, _control) { this.send((value < this.mode.maxSize) ? this.on : this.off); }, }); @@ -1478,7 +1478,7 @@ DJ505.RollMode = function (deck, offset) { this.paramMinusButton = new components.Button({ midi: [0x94 + offset, 0x28], mode: this, - input: function (channel, control, value, status, group) { + input: function (channel, control, value, _status, _group) { if (value) { if (this.mode.loopSize > this.mode.minSize) { this.mode.setLoopSize(this.mode.loopSize / 2); @@ -1490,7 +1490,7 @@ DJ505.RollMode = function (deck, offset) { this.paramPlusButton = new components.Button({ midi: [0x94 + offset, 0x29], mode: this, - input: function (channel, control, value, status, group) { + input: function (channel, control, value, _status, _group) { if (value) { if (this.mode.loopSize * 8 < this.mode.maxSize) { this.mode.setLoopSize(this.mode.loopSize * 2); @@ -1592,7 +1592,7 @@ DJ505.PitchPlayMode = function (deck, offset) { }, unshift: function() { this.outKey = "pitch_adjust"; - this.output = function (value, group, control) { + this.output = function (_value, _group, _control) { var color = this.mode.color + DJ505.PadColor.DIM_MODIFIER; if ((this.mode.range === PitchPlayRange.UP && this.number === 5) || (this.mode.range === PitchPlayRange.MID && this.number === 1) || @@ -1601,7 +1601,7 @@ DJ505.PitchPlayMode = function (deck, offset) { } this.send(color); }; - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, _status, _group) { if (value > 0) { var pitchAdjust; switch(this.mode.range) { @@ -1634,7 +1634,7 @@ DJ505.PitchPlayMode = function (deck, offset) { }, shift: function() { this.outKey = "hotcue_" + this.number + "_enabled"; - this.output = function (value, group, control) { + this.output = function (value, _group, _control) { var outval = this.outValueScale(value); if (this.colorIdKey !== undefined && outval !== this.off) { this.outputColor(engine.getValue(this.group, this.colorIdKey)); @@ -1642,7 +1642,7 @@ DJ505.PitchPlayMode = function (deck, offset) { this.send(DJ505.PadColor.OFF); } }; - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, _status, _group) { if (value > 0 && this.mode.cuepoint !== this.number && engine.getValue(this.group, "hotcue_" + this.number + "_enabled")) { var previousCuepoint = this.mode.cuepoint; this.mode.cuepoint = this.number; @@ -1676,7 +1676,7 @@ DJ505.PitchPlayMode = function (deck, offset) { this.paramMinusButton = new components.Button({ midi: [0x94 + offset, 0x28], mode: this, - input: function (channel, control, value, status, group) { + input: function (channel, control, value, _status, _group) { if (value) { if (this.mode.range === PitchPlayRange.UP) { this.mode.range = PitchPlayRange.MID; @@ -1695,7 +1695,7 @@ DJ505.PitchPlayMode = function (deck, offset) { this.paramPlusButton = new components.Button({ midi: [0x94 + offset, 0x29], mode: this, - input: function (channel, control, value, status, group) { + input: function (channel, control, value, _status, _group) { if (value) { if (this.mode.range === PitchPlayRange.UP) { this.mode.range = PitchPlayRange.DOWN; From 38f8fef0b1bb9f62d7bbd843db25c9f64d92284a Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 17 Jan 2020 12:43:30 +0100 Subject: [PATCH 07/16] controllers/midi-components: Add "_" prefix to unused arguments --- res/controllers/midi-components-0.0.js | 36 +++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 8955985fcf7d..e67364b28842 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -65,11 +65,11 @@ } }, // map input in the XML file, not inValueScale - input: function (channel, control, value, status, group) { + input: function (channel, control, value, _status, _group) { this.inSetParameter(this.inValueScale(value)); }, outValueScale: function (value) {return value * this.max;}, - output: function (value, group, control) { + output: function (value, _group, _control) { this.send(this.outValueScale(value)); }, outConnect: true, @@ -176,10 +176,10 @@ // in any Buttons that act differently with short and long presses // to keep the timeouts uniform. longPressTimeout: 275, - isPress: function (channel, control, value, status) { + isPress: function (channel, control, value, _status) { return value > 0; }, - input: function (channel, control, value, status, group) { + input: function (channel, control, value, status, _group) { if (this.type === undefined || this.type === this.types.push) { this.inSetValue(this.isPress(channel, control, value, status)); } else if (this.type === this.types.toggle) { @@ -251,7 +251,7 @@ }; SyncButton.prototype = new Button({ unshift: function () { - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { if (engine.getValue(this.group, "sync_enabled") === 0) { engine.setValue(this.group, "beatsync", 1); @@ -369,7 +369,7 @@ }; SamplerButton.prototype = new Button({ unshift: function () { - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { if (engine.getValue(this.group, "track_loaded") === 0) { engine.setValue(this.group, "LoadSelectedTrack", 1); @@ -383,7 +383,7 @@ }; }, shift: function() { - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { if (engine.getValue(this.group, "play") === 1) { engine.setValue(this.group, "play", 0); @@ -397,7 +397,7 @@ } }; }, - output: function (value, group, control) { + output: function (_value, _group, _control) { if (engine.getValue(this.group, "track_loaded") === 1) { if (this.loaded === undefined) { this.send(this.on); @@ -448,7 +448,7 @@ this.firstValueReceived = false; }; Pot.prototype = new Component({ - input: function (channel, control, value, status, group) { + input: function (channel, control, value, _status, _group) { if (this.MSB !== undefined) { value = (this.MSB << 7) + value; } @@ -870,7 +870,7 @@ this.EffectUnitKnob.prototype = new Pot({ group: this.group, unshift: function () { - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, _status, _group) { if (this.MSB !== undefined) { value = (this.MSB << 7) + value; } @@ -894,7 +894,7 @@ this.changeThreshold = Math.floor(this.max / engine.getValue("[Master]", "num_effectsavailable")); - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, _status, _group) { if (this.MSB !== undefined) { value = (this.MSB << 7) + value; } @@ -925,7 +925,7 @@ trigger: function () { this.connections[0].trigger(); }, - onFocusChange: function (value, group, control) { + onFocusChange: function (value, _group, _control) { if (value === 0) { this.group = "[EffectRack1_EffectUnit" + eu.currentUnitNumber + "_Effect" + @@ -949,7 +949,7 @@ this.EffectEnableButton.prototype = new Button({ type: Button.prototype.types.powerWindow, // NOTE: This function is only connected when not in focus choosing mode. - onFocusChange: function (value, group, control) { + onFocusChange: function (value, _group, _control) { if (value === 0) { if (colors !== undefined) { this.color = colors.unfocused; @@ -1005,7 +1005,7 @@ if (colors !== undefined) { this.color = colors.focusChooseMode; } - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { if (engine.getValue(eu.group, "focused_effect") === this.number) { // unfocus and make knobs control metaknobs @@ -1016,7 +1016,7 @@ } } }; - this.output = function (value, group, control) { + this.output = function (value, _group, _control) { this.send((value === this.number) ? this.on : this.off); }; this.connect = function () { @@ -1065,7 +1065,7 @@ } }, unshift: function () { - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, status, _group) { var showParameters = engine.getValue(this.group, "show_parameters"); if (this.isPress(channel, control, value, status)) { this.longPressTimer = engine.beginTimer(this.longPressTimeout, @@ -1105,14 +1105,14 @@ }; }, shift: function () { - this.input = function (channel, control, value, status, group) { + this.input = function (channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { eu.toggle(); } }; }, outKey: "focused_effect", - output: function (value, group, control) { + output: function (value, _group, _control) { this.send((value > 0) ? this.on : this.off); }, outConnect: false, From 77d47467824883a1e8286e3866b40dd00f45cd76 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 17 Jan 2020 12:44:47 +0100 Subject: [PATCH 08/16] controllers/midi-components: Add missing semicolon --- res/controllers/midi-components-0.0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index e67364b28842..eef6828c1dd7 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -814,7 +814,7 @@ index += 1; } this.setCurrentUnit(this.unitNumbers[index]); - } + }; if (unitNumbers !== undefined) { if (Array.isArray(unitNumbers)) { From 1bdff97670a53775c7c493aecdc8ce091ea48bb6 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 17 Jan 2020 17:12:36 +0100 Subject: [PATCH 09/16] Roland DJ-505: Fix spacing after keyword/comma --- res/controllers/Roland_DJ-505-scripts.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/res/controllers/Roland_DJ-505-scripts.js b/res/controllers/Roland_DJ-505-scripts.js index 2ec63575019c..c2d6e3bd3e4b 100644 --- a/res/controllers/Roland_DJ-505-scripts.js +++ b/res/controllers/Roland_DJ-505-scripts.js @@ -131,7 +131,7 @@ DJ505.init = function () { DJ505.sampler = new DJ505.Sampler(); DJ505.effectUnit = []; - for(i = 0; i <= 1; i++) { + for (i = 0; i <= 1; i++) { DJ505.effectUnit[i] = new components.EffectUnit([i + 1, i + 3]); DJ505.effectUnit[i].sendShifted = true; DJ505.effectUnit[i].shiftOffset = 0x0B; @@ -152,7 +152,7 @@ DJ505.init = function () { this.inSetParameter(this.inGetParameter() - 0.05); } }; - for(j = 1; j <= 4; j++) { + for (j = 1; j <= 4; j++) { DJ505.effectUnit[i].enableOnChannelButtons.addButton("Channel" + j); DJ505.effectUnit[i].enableOnChannelButtons["Channel" + j].midi = [0x98 + i, 0x04 + j]; } @@ -162,7 +162,7 @@ DJ505.init = function () { components.Button.prototype.input.apply(this, arguments); if (this.isPress(channel, control, value, status)) { var enabled = this.inGetValue(); - for(var j = 1; j <= 16; j++) { + for (var j = 1; j <= 16; j++) { engine.setValue(this.group, "group_[Sampler" + j + "]_enable", enabled); } } @@ -305,7 +305,7 @@ DJ505.sortLibrary = function (channel, control, value, _status, _group) { } var sortColumn; - switch(control) { + switch (control) { case 0x12: // SONG sortColumn = 1; break; @@ -340,7 +340,7 @@ DJ505.crossfader = new components.Pot({ }); DJ505.crossfader.setCurve = function (channel, control, value, _status, _group) { // 0x00 is Picnic Bench, 0x01 is Constant Power and 0x02 is Linear - switch(value) { + switch (value) { case 0x00: // Picnic Bench / Fast Cut engine.setValue("[Mixer Profile]", "xFaderMode", 0); engine.setValue("[Mixer Profile]", "xFaderCalibration", 0.9); @@ -366,7 +366,7 @@ DJ505.crossfader.setReverse = function (channel, control, value, _status, _group DJ505.setChannelInput = function (channel, control, value, _status, _group) { var number = (channel === 0x00) ? 0 : 1; var channelgroup = "[Channel" + (number + 1) + "]"; - switch(value) { + switch (value) { case 0x00: // PC engine.setValue(channelgroup, "passthrough", 0); break; @@ -1063,7 +1063,7 @@ DJ505.PadSection.prototype = Object.create(components.ComponentContainer.prototy DJ505.PadSection.prototype.controlToPadMode = function (control) { var mode; - switch(control) { + switch (control) { case DJ505.PadMode.HOTCUE: mode = this.modes.hotcue; break; @@ -1121,7 +1121,7 @@ DJ505.PadSection.prototype.paramButtonPressed = function (channel, control, valu return; } var button; - switch(control) { + switch (control) { case 0x2A: // PARAMETER 2 - if (this.currentMode.param2MinusButton) { button = this.currentMode.param2MinusButton; @@ -1351,7 +1351,7 @@ DJ505.CueLoopMode = function (deck, offset) { components.Button.prototype.connect.call(this); // call parent connect if (undefined !== this.group && this.colorIdKey !== undefined) { this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, function (id) { - if (engine.getValue(this.group,this.outKey)) { + if (engine.getValue(this.group, this.outKey)) { this.outputColor(id); } }); @@ -1604,7 +1604,7 @@ DJ505.PitchPlayMode = function (deck, offset) { this.input = function (channel, control, value, _status, _group) { if (value > 0) { var pitchAdjust; - switch(this.mode.range) { + switch (this.mode.range) { case PitchPlayRange.UP: pitchAdjust = this.number + ((this.number <= 4) ? 4 : -5); break; From 21f3208f069568b69ae875e3256f3dcc6a27b891 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 17 Jan 2020 17:28:24 +0100 Subject: [PATCH 10/16] controllers/midi-components: Add more whitespace fixes --- res/controllers/midi-components-0.0.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index eef6828c1dd7..3b5d41f5b645 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -68,7 +68,7 @@ input: function (channel, control, value, _status, _group) { this.inSetParameter(this.inValueScale(value)); }, - outValueScale: function (value) {return value * this.max;}, + outValueScale: function (value) { return value * this.max; }, output: function (value, _group, _control) { this.send(this.outValueScale(value)); }, @@ -92,7 +92,7 @@ engine.setValue(this.group, this.inKey, value); }, inToggle: function () { - this.inSetValue( ! this.inGetValue()); + this.inSetValue(!this.inGetValue()); }, outGetParameter: function () { @@ -108,7 +108,7 @@ engine.setValue(this.group, this.outKey, value); }, outToggle: function () { - this.outSetValue( ! this.outGetValue()); + this.outSetValue(!this.outGetValue()); }, connect: function () { @@ -313,7 +313,7 @@ }, getColor: function() { if (this.colorIdKey !== undefined) { - return color.predefinedColorFromId(engine.getValue(this.group,this.colorIdKey)); + return color.predefinedColorFromId(engine.getValue(this.group, this.colorIdKey)); } else { return null; } @@ -322,7 +322,7 @@ var outval = this.outValueScale(value); // WARNING: outputColor only handles hotcueColors // and there is no hotcueColor for turning the LED - // off. So the `send()` function is responsible for turning the + // off. So the `send()` function is responsible for turning the // actual LED off. if (this.colorIdKey !== undefined && outval !== this.off) { this.outputColor(engine.getValue(this.group, this.colorIdKey)); @@ -350,7 +350,7 @@ Button.prototype.connect.call(this); // call parent connect if (undefined !== this.group && this.colorIdKey !== undefined) { this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, function (id) { - if (engine.getValue(this.group,this.outKey)) { + if (engine.getValue(this.group, this.outKey)) { this.outputColor(id); } }); From b5cad7246148aac64dc5bf814b6bcef299f5e094 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 17 Jan 2020 17:28:44 +0100 Subject: [PATCH 11/16] controllers/midi-components: Fix direct use of prototype builtins --- res/controllers/midi-components-0.0.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 3b5d41f5b645..ac71e8dac41f 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -528,7 +528,7 @@ }; for (var memberName in this) { - if (this.hasOwnProperty(memberName)) { + if (ComponentContainer.prototype.hasOwnProperty.call(this, memberName)) { applyOperationTo(this[memberName]); } } @@ -556,7 +556,7 @@ }; for (var memberName in this) { - if (this.hasOwnProperty(memberName)) { + if (ComponentContainer.prototype.hasOwnProperty.call(this, memberName)) { applyOperationTo(this[memberName]); } } From c8f17f8e0cbaabd68a5957733110f78b2642389a Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 17 Jan 2020 17:37:05 +0100 Subject: [PATCH 12/16] script: Fix various code style issues --- script/console/__init__.js | 15 +++++---- script/svg/__init__.js | 62 ++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/script/console/__init__.js b/script/console/__init__.js index d18a0697f95d..f81b4c105f5e 100644 --- a/script/console/__init__.js +++ b/script/console/__init__.js @@ -2,20 +2,19 @@ __setupPackage__(__extension__); /** * This is a fake Firebug console api. To debug scripts a few more like in * javascript. - * + * * More info : * http://blog.qt.digia.com/blog/2012/03/01/debugging-qt-quick-2-console-api/ - * + * */ - console = { - log : function(){ + "log": function(){ var out = [], i = 0; - for( ; i|:\\' + (delimiter || '') + '-]', - 'g' + "[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\" + (delimiter || "") + "-]", + "g" ), - '\\$&' + "\\$&" ); - } + }; svg.getHooksPattern = function(){ var hookNames = []; - for( var i in this.templateHooks ) + for (var i in this.templateHooks) hookNames.push(i); - + // hook_name( arg1 [, arg2]... ) - if( hookNames.length ){ - var pattern = "("+hookNames.join('|')+")\\(([^\\(\\)]+)\\)\\s*;?"; + if (hookNames.length){ + var pattern = "("+hookNames.join("|")+")\\(([^\\(\\)]+)\\)\\s*;?"; return pattern; } - } + }; var global = this; - svg.templateHooks.variable = function( varName ){ - if( varName in global ){ + svg.templateHooks.variable = function(varName){ + if (varName in global){ return global[varName]; } - return ''; - } + return ""; + }; + + svg.templateHooks.prop = function(propName, varName){ + var out = ""; - svg.templateHooks.prop = function( propName, varName ){ - var out = ''; - - if( (varName in global) ){ + if ((varName in global)){ var value = global[varName]; - - if( isNumber(value) ){ - out = propName + ':' + value + ';'; - } else if( value.length ) { - out = propName + ':' + value + ';'; + + if (isNumber(value)){ + out = propName + ":" + value + ";"; + } else if (value.length) { + out = propName + ":" + value + ";"; } - + } else { - console.log( 'Unable to find ' + varName + ' for prop hook.' ); + console.log("Unable to find " + varName + " for prop hook."); } - + return out; - } + }; })(); - From 2d7947459fc1758f86e14ed1a2288bdcabff0259 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Mon, 20 Jan 2020 00:01:05 +0100 Subject: [PATCH 13/16] script: Fix spacing around (curly) braces --- script/console/__init__.js | 4 ++-- script/svg/__init__.js | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/script/console/__init__.js b/script/console/__init__.js index f81b4c105f5e..2fea8e20e3a5 100644 --- a/script/console/__init__.js +++ b/script/console/__init__.js @@ -9,10 +9,10 @@ __setupPackage__(__extension__); */ console = { - "log": function(){ + "log": function() { var out = [], i = 0; - for (; i|:\\" + (delimiter || "") + "-]", @@ -21,33 +21,33 @@ var isNumber = function(n) { ); }; - svg.getHooksPattern = function(){ + svg.getHooksPattern = function() { var hookNames = []; for (var i in this.templateHooks) hookNames.push(i); // hook_name( arg1 [, arg2]... ) - if (hookNames.length){ + if (hookNames.length) { var pattern = "("+hookNames.join("|")+")\\(([^\\(\\)]+)\\)\\s*;?"; return pattern; } }; var global = this; - svg.templateHooks.variable = function(varName){ - if (varName in global){ + svg.templateHooks.variable = function(varName) { + if (varName in global) { return global[varName]; } return ""; }; - svg.templateHooks.prop = function(propName, varName){ + svg.templateHooks.prop = function(propName, varName) { var out = ""; - if ((varName in global)){ + if ((varName in global)) { var value = global[varName]; - if (isNumber(value)){ + if (isNumber(value)) { out = propName + ":" + value + ";"; } else if (value.length) { out = propName + ":" + value + ";"; From eb96a5fe24a2a22ca8dc38fd23d71bbf6a0c9ba4 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Mon, 20 Jan 2020 00:03:57 +0100 Subject: [PATCH 14/16] Roland DJ-505: Fix remaining spacing issues --- res/controllers/Roland_DJ-505-scripts.js | 214 +++++++++++------------ 1 file changed, 107 insertions(+), 107 deletions(-) diff --git a/res/controllers/Roland_DJ-505-scripts.js b/res/controllers/Roland_DJ-505-scripts.js index c2d6e3bd3e4b..be19c0948962 100644 --- a/res/controllers/Roland_DJ-505-scripts.js +++ b/res/controllers/Roland_DJ-505-scripts.js @@ -72,12 +72,12 @@ DJ505.trsGroup = "Auxiliary1"; // TR-S input // Code. // /////////// -DJ505.init = function () { +DJ505.init = function() { var i, j; - DJ505.shiftButton = function (channel, control, value, _status, _group) { + DJ505.shiftButton = function(channel, control, value, _status, _group) { DJ505.deck.concat(DJ505.effectUnit, [DJ505.sampler, DJ505.browseEncoder]).forEach( - value ? function (module) { module.shift(); } : function (module) { module.unshift(); } + value ? function(module) { module.shift(); } : function(module) { module.unshift(); } ); }; @@ -91,13 +91,13 @@ DJ505.init = function () { DJ505.leftLoadTrackButton = new components.Button({ group: "[Channel1]", midi: [0x9F, 0x02], - unshift: function () { + unshift: function() { this.inKey = "LoadSelectedTrack"; }, - shift: function () { + shift: function() { this.inKey = "eject"; }, - input: function (channel, control, value, status, _group) { + input: function(channel, control, value, status, _group) { this.send(this.isPress(channel, control, value, status) ? this.on : this.off); components.Button.prototype.input.apply(this, arguments); }, @@ -111,13 +111,13 @@ DJ505.init = function () { DJ505.rightLoadTrackButton = new components.Button({ group: "[Channel2]", midi: [0x9F, 0x02], - unshift: function () { + unshift: function() { this.inKey = "LoadSelectedTrack"; }, - shift: function () { + shift: function() { this.inKey = "eject"; }, - input: function (channel, control, value, status, _group) { + input: function(channel, control, value, status, _group) { this.send(this.isPress(channel, control, value, status) ? this.on : this.off); components.Button.prototype.input.apply(this, arguments); }, @@ -144,7 +144,7 @@ DJ505.init = function () { DJ505.effectUnit[i].knobs[2].midi = [0xB8 + i, 0x01]; DJ505.effectUnit[i].knobs[3].midi = [0xB8 + i, 0x02]; DJ505.effectUnit[i].dryWetKnob.midi = [0xB8 + i, 0x03]; - DJ505.effectUnit[i].dryWetKnob.input = function (channel, control, value, _status, _group) { + DJ505.effectUnit[i].dryWetKnob.input = function(channel, control, value, _status, _group) { if (value === 1) { // 0.05 is an example. Adjust that value to whatever works well for your controller. this.inSetParameter(this.inGetParameter() + 0.05); @@ -158,7 +158,7 @@ DJ505.init = function () { } DJ505.effectUnit[i].enableOnChannelButtons.addButton(DJ505.trsGroup); DJ505.effectUnit[i].enableOnChannelButtons[DJ505.trsGroup].midi = [0x98 + i, 0x09]; - DJ505.effectUnit[i].enableOnChannelButtons[DJ505.trsGroup].input = function (channel, control, value, status, _group) { + DJ505.effectUnit[i].enableOnChannelButtons[DJ505.trsGroup].input = function(channel, control, value, status, _group) { components.Button.prototype.input.apply(this, arguments); if (this.isPress(channel, control, value, status)) { var enabled = this.inGetValue(); @@ -195,7 +195,7 @@ DJ505.init = function () { } }; -DJ505.autoShowDecks = function (_value, _group, _control) { +DJ505.autoShowDecks = function(_value, _group, _control) { var anyLoaded = engine.getValue("[Channel3]", "track_loaded") || engine.getValue("[Channel4]", "track_loaded"); if (!DJ505.autoShowFourDecks) { return; @@ -203,7 +203,7 @@ DJ505.autoShowDecks = function (_value, _group, _control) { engine.setValue("[Master]", "show_4decks", anyLoaded); }; -DJ505.shutdown = function () { +DJ505.shutdown = function() { }; @@ -213,7 +213,7 @@ DJ505.browseEncoder = new components.Encoder({ previewSeekEnabled: false, previewSeekHappened: false, unshift: function() { - this.onKnobEvent = function (rotateValue) { + this.onKnobEvent = function(rotateValue) { if (rotateValue !== 0) { if (this.previewSeekEnabled) { var oldPos = engine.getValue("[PreviewDeck1]", "playposition"); @@ -224,12 +224,12 @@ DJ505.browseEncoder = new components.Encoder({ } } }; - this.onButtonEvent = function (value) { + this.onButtonEvent = function(value) { if (value) { this.isLongPressed = false; this.longPressTimer = engine.beginTimer( this.longPressTimeout, - function () { this.isLongPressed = true; }, + function() { this.isLongPressed = true; }, true ); @@ -256,18 +256,18 @@ DJ505.browseEncoder = new components.Encoder({ }; }, shift: function() { - this.onKnobEvent = function (rotateValue) { + this.onKnobEvent = function(rotateValue) { if (rotateValue !== 0) { engine.setValue("[Playlist]", "SelectPlaylist", rotateValue); } }; - this.onButtonEvent = function (value) { + this.onButtonEvent = function(value) { if (value) { script.triggerControl("[Playlist]", "ToggleSelectedSidebarItem"); } }; }, - input: function (channel, control, value, status, _group) { + input: function(channel, control, value, status, _group) { switch (status) { case 0xBF: // Rotate. var rotateValue = (value === 127) ? -1 : ((value === 1) ? 1 : 0); @@ -299,7 +299,7 @@ DJ505.addPrepareButton = new components.Button({ }); -DJ505.sortLibrary = function (channel, control, value, _status, _group) { +DJ505.sortLibrary = function(channel, control, value, _status, _group) { if (value === 0) { return; } @@ -329,7 +329,7 @@ DJ505.crossfader = new components.Pot({ midi: [0xBF, 0x08], group: "[Master]", inKey: "crossfader", - input: function () { + input: function() { // We need a weird max. for the crossfader to make it cut cleanly. // However, components.js resets max. to 0x3fff when the first value is // received. Hence, we need to set max. here instead of within the @@ -338,7 +338,7 @@ DJ505.crossfader = new components.Pot({ components.Pot.prototype.input.apply(this, arguments); } }); -DJ505.crossfader.setCurve = function (channel, control, value, _status, _group) { +DJ505.crossfader.setCurve = function(channel, control, value, _status, _group) { // 0x00 is Picnic Bench, 0x01 is Constant Power and 0x02 is Linear switch (value) { case 0x00: // Picnic Bench / Fast Cut @@ -358,12 +358,12 @@ DJ505.crossfader.setCurve = function (channel, control, value, _status, _group) } }; -DJ505.crossfader.setReverse = function (channel, control, value, _status, _group) { +DJ505.crossfader.setReverse = function(channel, control, value, _status, _group) { // 0x00 is ON, 0x01 is OFF engine.setValue("[Mixer Profile]", "xFaderReverse", (value === 0x00) ? 1 : 0); }; -DJ505.setChannelInput = function (channel, control, value, _status, _group) { +DJ505.setChannelInput = function(channel, control, value, _status, _group) { var number = (channel === 0x00) ? 0 : 1; var channelgroup = "[Channel" + (number + 1) + "]"; switch (value) { @@ -377,7 +377,7 @@ DJ505.setChannelInput = function (channel, control, value, _status, _group) { } }; -DJ505.Deck = function (deckNumbers, offset) { +DJ505.Deck = function(deckNumbers, offset) { components.Deck.call(this, deckNumbers); this.slipModeButton = new DJ505.SlipModeButton({ @@ -391,19 +391,19 @@ DJ505.Deck = function (deckNumbers, offset) { this.tempoFader = new components.Pot({ group: "[Channel" + deckNumbers + "]", midi: [0xB0 + offset, 0x09], - connect: function () { + connect: function() { engine.softTakeover(this.group, "pitch", true); engine.softTakeover(this.group, "rate", true); components.Pot.prototype.connect.apply(this, arguments); }, - unshift: function () { + unshift: function() { this.inKey = "rate"; this.inSetParameter = components.Pot.prototype.inSetParameter; engine.softTakeoverIgnoreNextValue(this.group, "pitch"); }, - shift: function () { + shift: function() { this.inKey = "pitch"; - this.inSetParameter = function (value) { + this.inSetParameter = function(value) { // Scale to interval ]-7…7[; invert direction as per controller // labeling. value = 14 * value - 7; @@ -416,7 +416,7 @@ DJ505.Deck = function (deckNumbers, offset) { // ============================= JOG WHEELS ================================= - this.wheelTouch = function (channel, control, value, _status, _group) { + this.wheelTouch = function(channel, control, value, _status, _group) { if (value === 0x7F && !this.isShifted) { var alpha = 1.0/8; var beta = alpha/32; @@ -426,7 +426,7 @@ DJ505.Deck = function (deckNumbers, offset) { } }; - this.wheelTurn = function (channel, control, value, _status, _group) { + this.wheelTurn = function(channel, control, value, _status, _group) { // When the jog wheel is turned in clockwise direction, value is // greater than 64 (= 0x40). If it's turned in counter-clockwise // direction, the value is smaller than 64. @@ -505,15 +505,15 @@ DJ505.Deck = function (deckNumbers, offset) { shiftOffset: 1, outKey: "keylock", currentRangeIndex: (DJ505.tempoRange.indexOf(engine.getValue("[Channel" + deckNumbers + "]", "rateRange"))) ? DJ505.tempoRange.indexOf(engine.getValue("[Channel" + deckNumbers + "]", "rateRange")) : 0, - unshift: function () { + unshift: function() { this.inKey = "keylock"; this.input = components.Button.prototype.input; this.type = components.Button.prototype.types.toggle; }, - shift: function () { + shift: function() { this.inKey = "rateRange"; this.type = undefined; - this.input = function (channel, control, value, status, _group) { + this.input = function(channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { this.currentRangeIndex++; if (this.currentRangeIndex >= DJ505.tempoRange.length) { @@ -533,7 +533,7 @@ DJ505.Deck = function (deckNumbers, offset) { shiftControl: true, shiftOffset: 4, reverseRollOnShift: false, - input: function (channel, control, value, status, group) { + input: function(channel, control, value, status, group) { components.CueButton.prototype.input.call(this, channel, control, value, status, group); if (value) { return; @@ -555,15 +555,15 @@ DJ505.Deck = function (deckNumbers, offset) { this.sync = new components.Button({ midi: [0x90 + offset, 0x02], outKey: "sync_enabled", - output: function (value, _group, _control) { + output: function(value, _group, _control) { midi.sendShortMsg(this.midi[0], value ? 0x02 : 0x03, 0x7F); }, - unshift: function () { - this.input = function (channel, control, value, status, _group) { + unshift: function() { + this.input = function(channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { script.triggerControl(this.group, "beatsync", 1); if (engine.getValue(this.group, "sync_enabled") === 0) { - this.longPressTimer = engine.beginTimer(this.longPressTimeout, function () { + this.longPressTimer = engine.beginTimer(this.longPressTimeout, function() { engine.setValue(this.group, "sync_enabled", 1); this.longPressTimer = 0; }, true); @@ -576,8 +576,8 @@ DJ505.Deck = function (deckNumbers, offset) { } }; }, - shift: function () { - this.input = function (channel, control, value, _status, _group) { + shift: function() { + this.input = function(channel, control, value, _status, _group) { if (value) { engine.setValue(this.group, "sync_enabled", 0); } @@ -615,13 +615,13 @@ DJ505.Deck = function (deckNumbers, offset) { }); this.tapBPM = new components.Button({ - input: function (channel, control, value, status, group) { + input: function(channel, control, value, status, group) { if (this.isPress(channel, control, value, status, group)) { script.triggerControl(group, "beats_translate_curpos"); script.triggerControl(group, "bpm_tap", 1); this.longPressTimer = engine.beginTimer( this.longPressTimeout, - function () { + function() { script.triggerControl(group, "beats_translate_match_alignment"); }, true @@ -642,7 +642,7 @@ DJ505.Deck = function (deckNumbers, offset) { midi: [0xB0 + offset, 0x1F], group: "[Channel" + deckNumbers + "]", outKey: "VuMeter", - output: function (value, group, _control) { + output: function(value, group, _control) { // The red LEDs light up with MIDI values greater than 0x24. The // maximum brightness is reached at value 0x28. Red LEDs should // only be illuminated if the track is clipping. @@ -664,12 +664,12 @@ DJ505.DeckToggleButton = function(options) { components.Button.call(this, options); }; DJ505.DeckToggleButton.prototype = Object.create(components.Button.prototype); -DJ505.DeckToggleButton.prototype.input = function (channel, control, value, status, _group) { +DJ505.DeckToggleButton.prototype.input = function(channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { // Button was pressed this.longPressTimer = engine.beginTimer( this.longPressTimeout, - function () { this.isLongPressed = true; }, + function() { this.isLongPressed = true; }, true ); this.secondaryDeck = !this.secondaryDeck; @@ -686,7 +686,7 @@ DJ505.DeckToggleButton.prototype.input = function (channel, control, value, stat this.trigger(); }; -DJ505.DeckToggleButton.prototype.trigger = function () { +DJ505.DeckToggleButton.prototype.trigger = function() { this.send(this.secondaryDeck ? this.on : this.off); var newGroup = "[Channel" + (this.secondaryDeck ? this.decks[1] : this.decks[0]) + "]"; if (this.loadTrackButton.group !== newGroup) { @@ -766,7 +766,7 @@ DJ505.Sampler = function() { return newdeck; }; - this.syncButtonPressed = function (channel, control, value, _status, _group) { + this.syncButtonPressed = function(channel, control, value, _status, _group) { if (value !== 0x7f) { return; } @@ -790,14 +790,14 @@ DJ505.Sampler = function() { } }; - this.bpmKnobTurned = function (channel, control, value, _status, _group) { + this.bpmKnobTurned = function(channel, control, value, _status, _group) { if (this.syncDeck >= 0) { var bpm = ((value << 7) | control) / 10; engine.setValue("[Channel" + (this.syncDeck + 1) + "]", "bpm", bpm); } }; - this.startStopButtonPressed = function (channel, control, value, status, _group) { + this.startStopButtonPressed = function(channel, control, value, status, _group) { if (status === 0xFA) { this.playbackCounter = 1; this.playbackTimer = engine.beginTimer(500, function() { @@ -811,7 +811,7 @@ DJ505.Sampler = function() { } }; - this.customSamplePlayback = function (channel, control, value, status, group) { + this.customSamplePlayback = function(channel, control, value, status, group) { if (value) { // Volume has to be re-set because it could have been modified by // the Performance Pads in Velocity Sampler mode @@ -823,7 +823,7 @@ DJ505.Sampler = function() { this.levelKnob = new components.Pot({ group: "[" + DJ505.trsGroup + "]", inKey: "volume", - input: function (_channel, _control, _value, _status, _group) { + input: function(_channel, _control, _value, _status, _group) { components.Pot.prototype.input.apply(this, arguments); var volume = this.inGetParameter(); for (var i = 1; i <= 16; i++) { @@ -837,7 +837,7 @@ DJ505.Sampler = function() { key: "pfl", type: components.Button.prototype.types.toggle, midi: [0x9F, 0x1D], - input: function (_channel, _control, _value, _status, _group) { + input: function(_channel, _control, _value, _status, _group) { components.Button.prototype.input.apply(this, arguments); var pfl = this.inGetValue(); for (var i = 1; i <= 16; i++) { @@ -854,15 +854,15 @@ DJ505.Sampler.prototype = Object.create(components.ComponentContainer.prototype) // Custom components. // //////////////////////// -DJ505.SlipModeButton = function (options) { +DJ505.SlipModeButton = function(options) { components.Button.apply(this, arguments); this.doubleTapTimeout = 500; components.Button.call(this, options); }; DJ505.SlipModeButton.prototype = Object.create(components.Button.prototype); -DJ505.SlipModeButton.prototype.unshift = function () { - this.input = function (channel, control, value, _status, _group) { +DJ505.SlipModeButton.prototype.unshift = function() { + this.input = function(channel, control, value, _status, _group) { if (value) { // Button press. this.inSetValue(true); return; @@ -881,7 +881,7 @@ DJ505.SlipModeButton.prototype.unshift = function () { this.doubleTapTimer = engine.beginTimer( this.doubleTapTimeout, - function () { + function() { this.doubleTapped = false; this.doubleTapTimer = null; }, @@ -895,7 +895,7 @@ DJ505.SlipModeButton.prototype.unshift = function () { this.connect(); this.trigger(); }; -DJ505.SlipModeButton.prototype.shift = function () { +DJ505.SlipModeButton.prototype.shift = function() { this.input = components.Button.prototype.input; this.inKey = "vinylcontrol_enabled"; this.outKey = "vinylcontrol_enabled"; @@ -922,22 +922,22 @@ DJ505.PadMode = { }; DJ505.PadColor = { - OFF: 0x00, - RED: 0x01, - ORANGE: 0x02, - BLUE: 0x03, - YELLOW: 0x04, - APPLEGREEN: 0x05, - MAGENTA: 0x06, - CELESTE: 0x07, - PURPLE: 0x08, - APRICOT: 0x09, - CORAL: 0x0A, - AZURE: 0x0B, - TURQUOISE: 0x0C, - AQUAMARINE: 0x0D, - GREEN: 0x0E, - WHITE: 0x0F, + OFF: 0x00, + RED: 0x01, + ORANGE: 0x02, + BLUE: 0x03, + YELLOW: 0x04, + APPLEGREEN: 0x05, + MAGENTA: 0x06, + CELESTE: 0x07, + PURPLE: 0x08, + APRICOT: 0x09, + CORAL: 0x0A, + AZURE: 0x0B, + TURQUOISE: 0x0C, + AQUAMARINE: 0x0D, + GREEN: 0x0E, + WHITE: 0x0F, DIM_MODIFIER: 0x10, }; @@ -953,7 +953,7 @@ DJ505.PadColorMap = [ DJ505.PadColor.WHITE, ]; -DJ505.PadSection = function (deck, offset) { +DJ505.PadSection = function(deck, offset) { // TODO: Add support for missing modes (flip, slicer, slicerloop) /* * The Performance Pad Section on the DJ-505 apparently have two basic @@ -1061,7 +1061,7 @@ DJ505.PadSection = function (deck, offset) { DJ505.PadSection.prototype = Object.create(components.ComponentContainer.prototype); -DJ505.PadSection.prototype.controlToPadMode = function (control) { +DJ505.PadSection.prototype.controlToPadMode = function(control) { var mode; switch (control) { case DJ505.PadMode.HOTCUE: @@ -1112,11 +1112,11 @@ DJ505.PadSection.prototype.controlToPadMode = function (control) { return mode; }; -DJ505.PadSection.prototype.padModeButtonPressed = function (channel, control, _value, _status, _group) { +DJ505.PadSection.prototype.padModeButtonPressed = function(channel, control, _value, _status, _group) { this.setPadMode(control); }; -DJ505.PadSection.prototype.paramButtonPressed = function (channel, control, value, status, group) { +DJ505.PadSection.prototype.paramButtonPressed = function(channel, control, value, status, group) { if (!this.currentMode) { return; } @@ -1146,7 +1146,7 @@ DJ505.PadSection.prototype.paramButtonPressed = function (channel, control, valu } }; -DJ505.PadSection.prototype.setPadMode = function (control) { +DJ505.PadSection.prototype.setPadMode = function(control) { var newMode = this.controlToPadMode(control); // Exit early if the requested mode is already active or not mapped @@ -1163,7 +1163,7 @@ DJ505.PadSection.prototype.setPadMode = function (control) { // Disable the mode button LED of the currently active mode midi.sendShortMsg(0x94 + this.offset, this.currentMode.ledControl, 0x00); - this.currentMode.forEachComponent(function (component) { + this.currentMode.forEachComponent(function(component) { component.disconnect(); }); } @@ -1190,7 +1190,7 @@ DJ505.PadSection.prototype.setPadMode = function (control) { newMode.unshift(); } - newMode.forEachComponent(function (component) { + newMode.forEachComponent(function(component) { component.connect(); component.trigger(); }); @@ -1198,14 +1198,14 @@ DJ505.PadSection.prototype.setPadMode = function (control) { this.currentMode = newMode; }; -DJ505.PadSection.prototype.padPressed = function (channel, control, value, status, group) { +DJ505.PadSection.prototype.padPressed = function(channel, control, value, status, group) { var i = control - ((control >= 0x1C) ? 0x1C : 0x14); if (this.currentMode) { this.currentMode.pads[i].input(channel, control, value, status, group); } }; -DJ505.HotcueMode = function (deck, offset) { +DJ505.HotcueMode = function(deck, offset) { components.ComponentContainer.call(this); this.ledControl = DJ505.PadMode.HOTCUE; this.color = DJ505.PadColor.WHITE; @@ -1253,7 +1253,7 @@ DJ505.HotcueMode = function (deck, offset) { }; DJ505.HotcueMode.prototype = Object.create(components.ComponentContainer.prototype); -DJ505.CueLoopMode = function (deck, offset) { +DJ505.CueLoopMode = function(deck, offset) { components.ComponentContainer.call(this); this.ledControl = DJ505.PadMode.HOTCUE; this.color = DJ505.PadColor.BLUE; @@ -1277,7 +1277,7 @@ DJ505.CueLoopMode = function (deck, offset) { colors: cueloopColors, outConnect: false, unshift: function() { - this.input = function (channel, control, value, status, group) { + this.input = function(channel, control, value, status, group) { if (value) { var hotcueEnabled = true; if (!engine.getValue(group, "hotcue_" + this.number + "_enabled")) { @@ -1331,7 +1331,7 @@ DJ505.CueLoopMode = function (deck, offset) { this.send(outval); } }, - outputColor: function (id) { + outputColor: function(id) { var color = this.colors[id]; if (color instanceof Array) { if (color.length !== 3) { @@ -1350,7 +1350,7 @@ DJ505.CueLoopMode = function (deck, offset) { connect: function() { components.Button.prototype.connect.call(this); // call parent connect if (undefined !== this.group && this.colorIdKey !== undefined) { - this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, function (id) { + this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, function(id) { if (engine.getValue(this.group, this.outKey)) { this.outputColor(id); } @@ -1379,7 +1379,7 @@ DJ505.CueLoopMode = function (deck, offset) { }; DJ505.CueLoopMode.prototype = Object.create(components.ComponentContainer.prototype); -DJ505.RollMode = function (deck, offset) { +DJ505.RollMode = function(deck, offset) { components.ComponentContainer.call(this); this.ledControl = DJ505.PadMode.ROLL; this.color = DJ505.PadColor.CELESTE; @@ -1427,7 +1427,7 @@ DJ505.RollMode = function (deck, offset) { on: DJ505.PadColor.ORANGE, off: DJ505.PadColor.ORANGE + DJ505.PadColor.DIM_MODIFIER, mode: this, - input: function (channel, control, value, _status, _group) { + input: function(channel, control, value, _status, _group) { if (value) { var jumpSize = engine.getValue(this.group, "beatjump_size"); if (jumpSize > this.mode.minSize) { @@ -1435,7 +1435,7 @@ DJ505.RollMode = function (deck, offset) { } } }, - output: function (value, _group, _control) { + output: function(value, _group, _control) { this.send((value > this.mode.minSize) ? this.on : this.off); }, }); @@ -1450,7 +1450,7 @@ DJ505.RollMode = function (deck, offset) { on: DJ505.PadColor.ORANGE, off: DJ505.PadColor.ORANGE + DJ505.PadColor.DIM_MODIFIER, mode: this, - input: function (channel, control, value, _status, _group) { + input: function(channel, control, value, _status, _group) { if (value) { var jumpSize = engine.getValue(this.group, "beatjump_size"); if (jumpSize < this.mode.maxSize) { @@ -1458,7 +1458,7 @@ DJ505.RollMode = function (deck, offset) { } } }, - output: function (value, _group, _control) { + output: function(value, _group, _control) { this.send((value < this.mode.maxSize) ? this.on : this.off); }, }); @@ -1478,7 +1478,7 @@ DJ505.RollMode = function (deck, offset) { this.paramMinusButton = new components.Button({ midi: [0x94 + offset, 0x28], mode: this, - input: function (channel, control, value, _status, _group) { + input: function(channel, control, value, _status, _group) { if (value) { if (this.mode.loopSize > this.mode.minSize) { this.mode.setLoopSize(this.mode.loopSize / 2); @@ -1490,7 +1490,7 @@ DJ505.RollMode = function (deck, offset) { this.paramPlusButton = new components.Button({ midi: [0x94 + offset, 0x29], mode: this, - input: function (channel, control, value, _status, _group) { + input: function(channel, control, value, _status, _group) { if (value) { if (this.mode.loopSize * 8 < this.mode.maxSize) { this.mode.setLoopSize(this.mode.loopSize * 2); @@ -1501,7 +1501,7 @@ DJ505.RollMode = function (deck, offset) { }); }; DJ505.RollMode.prototype = Object.create(components.ComponentContainer.prototype); -DJ505.RollMode.prototype.setLoopSize = function (loopSize) { +DJ505.RollMode.prototype.setLoopSize = function(loopSize) { this.loopSize = loopSize; var padLoopSize; for (var i = 0; i <= 3; i++) { @@ -1513,7 +1513,7 @@ DJ505.RollMode.prototype.setLoopSize = function (loopSize) { this.reconnectComponents(); }; -DJ505.SamplerMode = function (deck, offset) { +DJ505.SamplerMode = function(deck, offset) { components.ComponentContainer.call(this); this.ledControl = DJ505.PadMode.SAMPLER; this.color = DJ505.PadColor.MAGENTA; @@ -1533,7 +1533,7 @@ DJ505.SamplerMode = function (deck, offset) { }; DJ505.SamplerMode.prototype = Object.create(components.ComponentContainer.prototype); -DJ505.VelocitySamplerMode = function (deck, offset) { +DJ505.VelocitySamplerMode = function(deck, offset) { components.ComponentContainer.call(this); this.ledControl = DJ505.PadMode.SAMPLER; this.color = DJ505.PadColor.PURPLE; @@ -1554,7 +1554,7 @@ DJ505.VelocitySamplerMode = function (deck, offset) { }; DJ505.VelocitySamplerMode.prototype = Object.create(components.ComponentContainer.prototype); -DJ505.PitchPlayMode = function (deck, offset) { +DJ505.PitchPlayMode = function(deck, offset) { components.ComponentContainer.call(this); var PitchPlayRange = { @@ -1592,7 +1592,7 @@ DJ505.PitchPlayMode = function (deck, offset) { }, unshift: function() { this.outKey = "pitch_adjust"; - this.output = function (_value, _group, _control) { + this.output = function(_value, _group, _control) { var color = this.mode.color + DJ505.PadColor.DIM_MODIFIER; if ((this.mode.range === PitchPlayRange.UP && this.number === 5) || (this.mode.range === PitchPlayRange.MID && this.number === 1) || @@ -1601,7 +1601,7 @@ DJ505.PitchPlayMode = function (deck, offset) { } this.send(color); }; - this.input = function (channel, control, value, _status, _group) { + this.input = function(channel, control, value, _status, _group) { if (value > 0) { var pitchAdjust; switch (this.mode.range) { @@ -1634,7 +1634,7 @@ DJ505.PitchPlayMode = function (deck, offset) { }, shift: function() { this.outKey = "hotcue_" + this.number + "_enabled"; - this.output = function (value, _group, _control) { + this.output = function(value, _group, _control) { var outval = this.outValueScale(value); if (this.colorIdKey !== undefined && outval !== this.off) { this.outputColor(engine.getValue(this.group, this.colorIdKey)); @@ -1642,7 +1642,7 @@ DJ505.PitchPlayMode = function (deck, offset) { this.send(DJ505.PadColor.OFF); } }; - this.input = function (channel, control, value, _status, _group) { + this.input = function(channel, control, value, _status, _group) { if (value > 0 && this.mode.cuepoint !== this.number && engine.getValue(this.group, "hotcue_" + this.number + "_enabled")) { var previousCuepoint = this.mode.cuepoint; this.mode.cuepoint = this.number; @@ -1653,7 +1653,7 @@ DJ505.PitchPlayMode = function (deck, offset) { this.connect = function() { components.Button.prototype.connect.call(this); // call parent connect if (undefined !== this.group && this.colorIdKey !== undefined) { - this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, function (id) { + this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, function(id) { if (engine.getValue(this.group, this.outKey)) { this.outputColor(id); } @@ -1676,7 +1676,7 @@ DJ505.PitchPlayMode = function (deck, offset) { this.paramMinusButton = new components.Button({ midi: [0x94 + offset, 0x28], mode: this, - input: function (channel, control, value, _status, _group) { + input: function(channel, control, value, _status, _group) { if (value) { if (this.mode.range === PitchPlayRange.UP) { this.mode.range = PitchPlayRange.MID; @@ -1685,7 +1685,7 @@ DJ505.PitchPlayMode = function (deck, offset) { } else { this.mode.range = PitchPlayRange.UP; } - this.mode.forEachComponent(function (component) { + this.mode.forEachComponent(function(component) { component.trigger(); }); } @@ -1695,7 +1695,7 @@ DJ505.PitchPlayMode = function (deck, offset) { this.paramPlusButton = new components.Button({ midi: [0x94 + offset, 0x29], mode: this, - input: function (channel, control, value, _status, _group) { + input: function(channel, control, value, _status, _group) { if (value) { if (this.mode.range === PitchPlayRange.UP) { this.mode.range = PitchPlayRange.DOWN; @@ -1704,7 +1704,7 @@ DJ505.PitchPlayMode = function (deck, offset) { } else { this.mode.range = PitchPlayRange.MID; } - this.mode.forEachComponent(function (component) { + this.mode.forEachComponent(function(component) { component.trigger(); }); } From e5180058e9f1bd1f9d092871e7aab942a74f87c1 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Mon, 20 Jan 2020 00:51:10 +0100 Subject: [PATCH 15/16] Roland DJ-505: Remove JSHint configuration comment --- res/controllers/Roland_DJ-505-scripts.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/res/controllers/Roland_DJ-505-scripts.js b/res/controllers/Roland_DJ-505-scripts.js index be19c0948962..48d97fc5fef2 100644 --- a/res/controllers/Roland_DJ-505-scripts.js +++ b/res/controllers/Roland_DJ-505-scripts.js @@ -1,12 +1,3 @@ -//////////////////////////////////////////////////////////////////////// -// JSHint configuration // -//////////////////////////////////////////////////////////////////////// -/* global engine */ -/* global script */ -/* global midi */ -/* global components */ -//////////////////////////////////////////////////////////////////////// - /* * The Roland DJ-505 controller has two basic modes: * From 485ee7f7e9ba667795eaf609e109a3e8e70b390a Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Mon, 20 Jan 2020 00:52:51 +0100 Subject: [PATCH 16/16] components/midi-components: Fix spacing before function parentheses --- res/controllers/midi-components-0.0.js | 250 ++++++++++++------------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index ac71e8dac41f..2657bb2176e0 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -26,8 +26,8 @@ * the lodash.mixxx.js file in this directory for details. **/ -(function (global) { - var Component = function (options) { +(function(global) { + var Component = function(options) { if (Array.isArray(options) && typeof options[0] === "number") { this.midi = options; } else { @@ -56,7 +56,7 @@ Component.prototype = { // default attributes // You should probably overwrite at least some of these. - inValueScale: function (value) { + inValueScale: function(value) { // Hack to get exact center of pots to return 0.5 if (value > (this.max / 2)) { return (value - 1) / (this.max - 1); @@ -65,11 +65,11 @@ } }, // map input in the XML file, not inValueScale - input: function (channel, control, value, _status, _group) { + input: function(channel, control, value, _status, _group) { this.inSetParameter(this.inValueScale(value)); }, - outValueScale: function (value) { return value * this.max; }, - output: function (value, _group, _control) { + outValueScale: function(value) { return value * this.max; }, + output: function(value, _group, _control) { this.send(this.outValueScale(value)); }, outConnect: true, @@ -79,39 +79,39 @@ // common functions // In most cases, you should not overwrite these. - inGetParameter: function () { + inGetParameter: function() { return engine.getParameter(this.group, this.inKey); }, - inSetParameter: function (value) { + inSetParameter: function(value) { engine.setParameter(this.group, this.inKey, value); }, - inGetValue: function () { + inGetValue: function() { return engine.getValue(this.group, this.inKey); }, - inSetValue: function (value) { + inSetValue: function(value) { engine.setValue(this.group, this.inKey, value); }, - inToggle: function () { + inToggle: function() { this.inSetValue(!this.inGetValue()); }, - outGetParameter: function () { + outGetParameter: function() { return engine.getParameter(this.group, this.outKey); }, - outSetParameter: function (value) { + outSetParameter: function(value) { engine.setParameter(this.group, this.outKey, value); }, - outGetValue: function () { + outGetValue: function() { return engine.getValue(this.group, this.outKey); }, - outSetValue: function (value) { + outSetValue: function(value) { engine.setValue(this.group, this.outKey, value); }, - outToggle: function () { + outToggle: function() { this.outSetValue(!this.outGetValue()); }, - connect: function () { + connect: function() { /** Override this method with a custom one to connect multiple Mixxx COs for a single Component. Add the connection objects to the this.connections array so they all get disconnected just @@ -126,16 +126,16 @@ this.connections[0] = engine.makeConnection(this.group, this.outKey, this.output); } }, - disconnect: function () { + disconnect: function() { if (this.connections[0] !== undefined) { - this.connections.forEach(function (conn) { + this.connections.forEach(function(conn) { conn.disconnect(); }); } }, trigger: function() { if (this.connections[0] !== undefined) { - this.connections.forEach(function (conn) { + this.connections.forEach(function(conn) { conn.trigger(); }); } @@ -144,7 +144,7 @@ sendShifted: false, shiftChannel: false, shiftControl: false, - send: function (value) { + send: function(value) { if (this.midi === undefined || this.midi[0] === undefined || this.midi[1] === undefined) { return; } @@ -159,7 +159,7 @@ }, }; - var Button = function (options) { + var Button = function(options) { Component.call(this, options); }; Button.prototype = new Component({ @@ -176,10 +176,10 @@ // in any Buttons that act differently with short and long presses // to keep the timeouts uniform. longPressTimeout: 275, - isPress: function (channel, control, value, _status) { + isPress: function(channel, control, value, _status) { return value > 0; }, - input: function (channel, control, value, status, _group) { + input: function(channel, control, value, status, _group) { if (this.type === undefined || this.type === this.types.push) { this.inSetValue(this.isPress(channel, control, value, status)); } else if (this.type === this.types.toggle) { @@ -190,7 +190,7 @@ if (this.isPress(channel, control, value, status)) { this.inToggle(); this.isLongPressed = false; - this.longPressTimer = engine.beginTimer(this.longPressTimeout, function () { + this.longPressTimer = engine.beginTimer(this.longPressTimeout, function() { this.isLongPressed = true; this.longPressTimer = 0; }, true); @@ -206,37 +206,37 @@ } } }, - outValueScale: function (value) { + outValueScale: function(value) { return (value > 0) ? this.on : this.off; }, - shutdown: function () { + shutdown: function() { this.send(this.off); }, }); - var PlayButton = function (options) { + var PlayButton = function(options) { Button.call(this, options); }; PlayButton.prototype = new Button({ - unshift: function () { + unshift: function() { this.inKey = "play"; }, - shift: function () { + shift: function() { this.inKey = "reverse"; }, type: Button.prototype.types.toggle, outKey: "play_indicator", }); - var CueButton = function (options) { + var CueButton = function(options) { Button.call(this, options); }; CueButton.prototype = new Button({ - unshift: function () { + unshift: function() { this.inKey = "cue_default"; }, - shift: function () { + shift: function() { if (this.reverseRollOnShift) { this.inKey = "reverseroll"; } else { @@ -246,16 +246,16 @@ outKey: "cue_indicator", }); - var SyncButton = function (options) { + var SyncButton = function(options) { Button.call(this, options); }; SyncButton.prototype = new Button({ - unshift: function () { - this.input = function (channel, control, value, status, _group) { + unshift: function() { + this.input = function(channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { if (engine.getValue(this.group, "sync_enabled") === 0) { engine.setValue(this.group, "beatsync", 1); - this.longPressTimer = engine.beginTimer(this.longPressTimeout, function () { + this.longPressTimer = engine.beginTimer(this.longPressTimeout, function() { engine.setValue(this.group, "sync_enabled", 1); this.longPressTimer = 0; }, true); @@ -270,7 +270,7 @@ } }; }, - shift: function () { + shift: function() { this.inKey = "quantize"; this.type = Button.prototype.types.toggle; this.input = Button.prototype.input; @@ -278,18 +278,18 @@ outKey: "sync_enabled", }); - var LoopToggleButton = function (options) { + var LoopToggleButton = function(options) { Button.call(this, options); }; LoopToggleButton.prototype = new Button({ inKey: "reloop_exit", - inValueScale: function () { + inValueScale: function() { return 1; }, outKey: "loop_enabled", }); - var HotcueButton = function (options) { + var HotcueButton = function(options) { if (options.number === undefined) { print("ERROR: No hotcue number specified for new HotcueButton."); return; @@ -305,10 +305,10 @@ Button.call(this, options); }; HotcueButton.prototype = new Button({ - unshift: function () { + unshift: function() { this.inKey = "hotcue_" + this.number + "_activate"; }, - shift: function () { + shift: function() { this.inKey = "hotcue_" + this.number + "_clear"; }, getColor: function() { @@ -330,7 +330,7 @@ this.send(outval); } }, - outputColor: function (id) { + outputColor: function(id) { var color = this.colors[id]; if (color instanceof Array) { if (color.length !== 3) { @@ -349,7 +349,7 @@ connect: function() { Button.prototype.connect.call(this); // call parent connect if (undefined !== this.group && this.colorIdKey !== undefined) { - this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, function (id) { + this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, function(id) { if (engine.getValue(this.group, this.outKey)) { this.outputColor(id); } @@ -357,7 +357,7 @@ } }, }); - var SamplerButton = function (options) { + var SamplerButton = function(options) { if (options.number === undefined) { print("ERROR: No sampler number specified for new SamplerButton."); return; @@ -368,8 +368,8 @@ Button.call(this, options); }; SamplerButton.prototype = new Button({ - unshift: function () { - this.input = function (channel, control, value, status, _group) { + unshift: function() { + this.input = function(channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { if (engine.getValue(this.group, "track_loaded") === 0) { engine.setValue(this.group, "LoadSelectedTrack", 1); @@ -383,7 +383,7 @@ }; }, shift: function() { - this.input = function (channel, control, value, status, _group) { + this.input = function(channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { if (engine.getValue(this.group, "play") === 1) { engine.setValue(this.group, "play", 0); @@ -397,7 +397,7 @@ } }; }, - output: function (_value, _group, _control) { + output: function(_value, _group, _control) { if (engine.getValue(this.group, "track_loaded") === 1) { if (this.loaded === undefined) { this.send(this.on); @@ -433,7 +433,7 @@ outKey: null, // hack to get Component constructor to call connect() }); - var EffectAssignmentButton = function (options) { + var EffectAssignmentButton = function(options) { options.key = "group_" + options.group + "_enable"; options.group = "[EffectRack1_EffectUnit" + options.effectUnit + "]"; Button.call(this, options); @@ -442,13 +442,13 @@ type: Button.prototype.types.toggle, }); - var Pot = function (options) { + var Pot = function(options) { Component.call(this, options); this.firstValueReceived = false; }; Pot.prototype = new Component({ - input: function (channel, control, value, _status, _group) { + input: function(channel, control, value, _status, _group) { if (this.MSB !== undefined) { value = (this.MSB << 7) + value; } @@ -463,7 +463,7 @@ } }, // Input handlers for 14 bit MIDI - inputMSB: function (channel, control, value, status, group) { + inputMSB: function(channel, control, value, status, group) { // For the first messages, disregard the LSB in case // the first LSB is received after the first MSB. if (this.MSB === undefined) { @@ -473,41 +473,41 @@ } this.MSB = value; }, - inputLSB: function (channel, control, value, status, group) { + inputLSB: function(channel, control, value, status, group) { // Make sure the first MSB has been received if (this.MSB !== undefined) { this.input(channel, control, value, status, group); } }, - connect: function () { + connect: function() { if (this.firstValueReceived && !this.relative) { engine.softTakeover(this.group, this.inKey, true); } }, - disconnect: function () { + disconnect: function() { if (!this.relative) { engine.softTakeoverIgnoreNextValue(this.group, this.inKey); } }, - trigger: function () {}, + trigger: function() {}, }); /** The generic Component code provides everything to implement an Encoder. This Encoder Component exists so instanceof can be used to separate Encoders from other Components. **/ - var Encoder = function (options) { + var Encoder = function(options) { Component.call(this, options); }; Encoder.prototype = new Component(); - var ComponentContainer = function (initialLayer) { + var ComponentContainer = function(initialLayer) { if (typeof initialLayer === "object") { this.applyLayer(initialLayer); } }; ComponentContainer.prototype = { - forEachComponent: function (operation, recursive) { + forEachComponent: function(operation, recursive) { if (typeof operation !== "function") { print("ERROR: ComponentContainer.forEachComponent requires a function argument"); return; @@ -515,13 +515,13 @@ if (recursive === undefined) { recursive = true; } var that = this; - var applyOperationTo = function (obj) { + var applyOperationTo = function(obj) { if (obj instanceof Component) { operation.call(that, obj); } else if (recursive && obj instanceof ComponentContainer) { obj.forEachComponent(operation); } else if (Array.isArray(obj)) { - obj.forEach(function (element) { + obj.forEach(function(element) { applyOperationTo(element); }); } @@ -533,7 +533,7 @@ } } }, - forEachComponentContainer: function (operation, recursive) { + forEachComponentContainer: function(operation, recursive) { if (typeof operation !== "function") { print("ERROR: ComponentContainer.forEachComponentContainer requires a function argument"); return; @@ -541,7 +541,7 @@ if (recursive === undefined) { recursive = true; } var that = this; - var applyOperationTo = function (obj) { + var applyOperationTo = function(obj) { if (obj instanceof ComponentContainer) { operation.call(that, obj); @@ -549,7 +549,7 @@ obj.forEachComponentContainer(operation); } } else if (Array.isArray(obj)) { - obj.forEach(function (element) { + obj.forEach(function(element) { applyOperationTo(element); }); } @@ -561,8 +561,8 @@ } } }, - reconnectComponents: function (operation, recursive) { - this.forEachComponent(function (component) { + reconnectComponents: function(operation, recursive) { + this.forEachComponent(function(component) { component.disconnect(); if (typeof operation === "function") { operation.call(this, component); @@ -572,9 +572,9 @@ }, recursive); }, isShifted: false, - shift: function () { + shift: function() { // Shift direct child Components - this.forEachComponent(function (component) { + this.forEachComponent(function(component) { // Controls for push type Buttons depend on getting reset to 0 when the // Button is released for correct behavior. If there is a skin button // that lights up with the inKey, the skin button would stay lit if the @@ -600,16 +600,16 @@ }, false); // Shift child ComponentContainers - this.forEachComponentContainer(function (container) { + this.forEachComponentContainer(function(container) { container.shift(); }, false); // Set isShifted for each ComponentContainer recursively this.isShifted = true; }, - unshift: function () { + unshift: function() { // Unshift direct child Components - this.forEachComponent(function (component) { + this.forEachComponent(function(component) { // Refer to comment in ComponentContainer.shift() above for explanation if (typeof component.unshift === "function") { if (component instanceof Button @@ -627,19 +627,19 @@ }, false); // Unshift child ComponentContainers - this.forEachComponentContainer(function (container) { + this.forEachComponentContainer(function(container) { container.unshift(); }, false); // Unset isShifted for each ComponentContainer recursively this.isShifted = false; }, - applyLayer: function (newLayer, reconnectComponents) { + applyLayer: function(newLayer, reconnectComponents) { if (reconnectComponents !== false) { reconnectComponents = true; } if (reconnectComponents === true) { - this.forEachComponent(function (component) { + this.forEachComponent(function(component) { component.disconnect(); }); } @@ -647,14 +647,14 @@ _.merge(this, newLayer); if (reconnectComponents === true) { - this.forEachComponent(function (component) { + this.forEachComponent(function(component) { component.connect(); component.trigger(); }); } }, - shutdown: function () { - this.forEachComponent(function (component) { + shutdown: function() { + this.forEachComponent(function(component) { if (component.shutdown !== undefined && typeof component.shutdown === "function") { component.shutdown(); @@ -663,7 +663,7 @@ }, }; - var Deck = function (deckNumbers) { + var Deck = function(deckNumbers) { if (deckNumbers !== undefined) { if (Array.isArray(deckNumbers)) { // These must be unique to each instance, @@ -682,9 +682,9 @@ } }; Deck.prototype = new ComponentContainer({ - setCurrentDeck: function (newGroup) { + setCurrentDeck: function(newGroup) { this.currentDeck = newGroup; - this.reconnectComponents(function (component) { + this.reconnectComponents(function(component) { if (component.group === undefined || component.group.search(script.channelRegEx) !== -1) { component.group = newGroup; @@ -704,7 +704,7 @@ } }); }, - toggle: function () { + toggle: function() { // cycle through deckNumbers array var index = this.deckNumbers.indexOf(parseInt( script.channelRegEx.exec(this.currentDeck)[1] @@ -718,12 +718,12 @@ } }); - var EffectUnit = function (unitNumbers, allowFocusWhenParametersHidden, colors) { + var EffectUnit = function(unitNumbers, allowFocusWhenParametersHidden, colors) { var eu = this; this.focusChooseModeActive = false; // This is only connected if allowFocusWhenParametersHidden is false. - this.onShowParametersChange = function (value) { + this.onShowParametersChange = function(value) { if (value === 0) { // Prevent this from getting called twice (on button down and button up) // when show_parameters button is clicked in skin. @@ -743,13 +743,13 @@ } } if (eu.enableButtons !== undefined) { - eu.enableButtons.reconnectComponents(function (button) { + eu.enableButtons.reconnectComponents(function(button) { button.stopEffectFocusChooseMode(); }); } }; - this.setCurrentUnit = function (newNumber) { + this.setCurrentUnit = function(newNumber) { this.currentUnitNumber = newNumber; if (allowFocusWhenParametersHidden) { engine.setValue(this.group, "show_focus", 0); @@ -788,7 +788,7 @@ } } - this.reconnectComponents(function (component) { + this.reconnectComponents(function(component) { // update [EffectRack1_EffectUnitX] groups var unitMatch = component.group.match(script.effectUnitRegEx); if (unitMatch !== null) { @@ -805,7 +805,7 @@ }); }; - this.toggle = function () { + this.toggle = function() { // cycle through unitNumbers array var index = this.unitNumbers.indexOf(this.currentUnitNumber); if (index === (this.unitNumbers.length - 1)) { @@ -833,20 +833,20 @@ this.dryWetKnob = new Pot({ group: this.group, - unshift: function () { + unshift: function() { this.inKey = "mix"; // for soft takeover this.disconnect(); this.connect(); }, - shift: function () { + shift: function() { this.inKey = "super1"; // for soft takeover this.disconnect(); this.connect(); // engine.softTakeoverIgnoreNextValue is called // in the knobs' onFocusChange function - eu.knobs.forEachComponent(function (knob) { + eu.knobs.forEachComponent(function(knob) { knob.trigger(); }); }, @@ -854,7 +854,7 @@ }); this.enableOnChannelButtons = new ComponentContainer(); - this.enableOnChannelButtons.addButton = function (channel) { + this.enableOnChannelButtons.addButton = function(channel) { this[channel] = new Button({ group: eu.group, key: "group_[" + channel + "]_enable", @@ -863,14 +863,14 @@ }); }; - this.EffectUnitKnob = function (number) { + this.EffectUnitKnob = function(number) { this.number = number; Pot.call(this); }; this.EffectUnitKnob.prototype = new Pot({ group: this.group, - unshift: function () { - this.input = function (channel, control, value, _status, _group) { + unshift: function() { + this.input = function(channel, control, value, _status, _group) { if (this.MSB !== undefined) { value = (this.MSB << 7) + value; } @@ -887,14 +887,14 @@ this.previousValueReceived = value; }; }, - shift: function () { + shift: function() { engine.softTakeoverIgnoreNextValue(this.group, this.inKey); this.valueAtLastEffectSwitch = this.previousValueReceived; // Floor the threshold to ensure that every effect can be selected this.changeThreshold = Math.floor(this.max / engine.getValue("[Master]", "num_effectsavailable")); - this.input = function (channel, control, value, _status, _group) { + this.input = function(channel, control, value, _status, _group) { if (this.MSB !== undefined) { value = (this.MSB << 7) + value; } @@ -914,18 +914,18 @@ }; }, outKey: "focused_effect", - connect: function () { + connect: function() { this.connections[0] = engine.makeConnection(eu.group, "focused_effect", this.onFocusChange); }, - disconnect: function () { + disconnect: function() { engine.softTakeoverIgnoreNextValue(this.group, this.inKey); this.connections[0].disconnect(); }, - trigger: function () { + trigger: function() { this.connections[0].trigger(); }, - onFocusChange: function (value, _group, _control) { + onFocusChange: function(value, _group, _control) { if (value === 0) { this.group = "[EffectRack1_EffectUnit" + eu.currentUnitNumber + "_Effect" + @@ -940,7 +940,7 @@ }, }); - this.EffectEnableButton = function (number) { + this.EffectEnableButton = function(number) { this.number = number; this.group = "[EffectRack1_EffectUnit" + eu.currentUnitNumber + "_Effect" + this.number + "]"; @@ -949,7 +949,7 @@ this.EffectEnableButton.prototype = new Button({ type: Button.prototype.types.powerWindow, // NOTE: This function is only connected when not in focus choosing mode. - onFocusChange: function (value, _group, _control) { + onFocusChange: function(value, _group, _control) { if (value === 0) { if (colors !== undefined) { this.color = colors.unfocused; @@ -969,7 +969,7 @@ this.outKey = "button_parameter" + this.number; } }, - stopEffectFocusChooseMode: function () { + stopEffectFocusChooseMode: function() { this.type = Button.prototype.types.powerWindow; this.input = Button.prototype.input; this.output = Button.prototype.output; @@ -977,7 +977,7 @@ this.color = colors.unfocused; } - this.connect = function () { + this.connect = function() { this.connections[0] = engine.makeConnection(eu.group, "focused_effect", this.onFocusChange); // this.onFocusChange sets this.group and this.outKey, so trigger it @@ -986,12 +986,12 @@ this.connections[1] = engine.makeConnection(this.group, this.outKey, this.output); }; - this.unshift = function () { + this.unshift = function() { this.disconnect(); this.connect(); this.trigger(); }; - this.shift = function () { + this.shift = function() { this.group = "[EffectRack1_EffectUnit" + eu.currentUnitNumber + "_Effect" + this.number + "]"; @@ -1001,11 +1001,11 @@ this.shift(); } }, - startEffectFocusChooseMode: function () { + startEffectFocusChooseMode: function() { if (colors !== undefined) { this.color = colors.focusChooseMode; } - this.input = function (channel, control, value, status, _group) { + this.input = function(channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { if (engine.getValue(eu.group, "focused_effect") === this.number) { // unfocus and make knobs control metaknobs @@ -1016,10 +1016,10 @@ } } }; - this.output = function (value, _group, _control) { + this.output = function(value, _group, _control) { this.send((value === this.number) ? this.on : this.off); }; - this.connect = function () { + this.connect = function() { // Outside of focus choose mode, the this.connections array // has two members. Connections can be triggered when they // are disconnected, so overwrite the whole array here instead @@ -1045,17 +1045,17 @@ longPressTimer: 0, pressedWhenParametersHidden: false, previouslyFocusedEffect: 0, - startEffectFocusChooseMode: function () { + startEffectFocusChooseMode: function() { if (colors !== undefined) { this.color = colors.focusChooseMode; } this.send(this.on); eu.focusChooseModeActive = true; - eu.enableButtons.reconnectComponents(function (button) { + eu.enableButtons.reconnectComponents(function(button) { button.startEffectFocusChooseMode(); }); }, - setColor: function () { + setColor: function() { if (colors !== undefined) { if (engine.getValue(this.group, "focused_effect") === 0) { this.color = colors.unfocused; @@ -1064,8 +1064,8 @@ } } }, - unshift: function () { - this.input = function (channel, control, value, status, _group) { + unshift: function() { + this.input = function(channel, control, value, status, _group) { var showParameters = engine.getValue(this.group, "show_parameters"); if (this.isPress(channel, control, value, status)) { this.longPressTimer = engine.beginTimer(this.longPressTimeout, @@ -1087,7 +1087,7 @@ if (eu.focusChooseModeActive) { this.setColor(); this.trigger(); - eu.enableButtons.reconnectComponents(function (button) { + eu.enableButtons.reconnectComponents(function(button) { button.stopEffectFocusChooseMode(); }); eu.focusChooseModeActive = false; @@ -1104,30 +1104,30 @@ } }; }, - shift: function () { - this.input = function (channel, control, value, status, _group) { + shift: function() { + this.input = function(channel, control, value, status, _group) { if (this.isPress(channel, control, value, status)) { eu.toggle(); } }; }, outKey: "focused_effect", - output: function (value, _group, _control) { + output: function(value, _group, _control) { this.send((value > 0) ? this.on : this.off); }, outConnect: false, }); this.effectFocusButton.setColor(); - this.init = function () { + this.init = function() { this.knobs.reconnectComponents(); - this.enableButtons.reconnectComponents(function (button) { + this.enableButtons.reconnectComponents(function(button) { button.stopEffectFocusChooseMode(); }); this.effectFocusButton.connect(); this.effectFocusButton.trigger(); - this.enableOnChannelButtons.forEachComponent(function (button) { + this.enableOnChannelButtons.forEachComponent(function(button) { if (button.midi !== undefined) { button.disconnect(); button.connect(); @@ -1135,7 +1135,7 @@ } }); - this.forEachComponent(function (component) { + this.forEachComponent(function(component) { if (component.group === undefined) { component.group = eu.group; }