summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSwiftb0y <12380386+Swiftb0y@users.noreply.github.com>2023-06-04 14:53:12 +0200
committerSwiftb0y <12380386+Swiftb0y@users.noreply.github.com>2023-06-04 14:53:12 +0200
commit6fb61a62ba3f4d49b6948e3ba6c2784353653adb (patch)
tree4785e3d31385c16ba2adc49401184bca1cdd415a
parent67e51ad029c883ad35f9c788a44ca6349cd508c6 (diff)
fix(ci): silence eslint complaints for common-controller-scripts.js
-rw-r--r--res/controllers/common-controller-scripts.js68
1 files changed, 39 insertions, 29 deletions
diff --git a/res/controllers/common-controller-scripts.js b/res/controllers/common-controller-scripts.js
index c20a54908b..f0d19253ee 100644
--- a/res/controllers/common-controller-scripts.js
+++ b/res/controllers/common-controller-scripts.js
@@ -21,8 +21,8 @@
// Returns an ASCII byte array for the string
String.prototype.toInt = function() {
- var a = new Array();
- for (var i = 0; i < this.length; i++) {
+ const a = new Array();
+ for (let i = 0; i < this.length; i++) {
a[i] = this.charCodeAt(i);
}
return a;
@@ -32,9 +32,11 @@ String.prototype.toInt = function() {
/**
* Prints a message to the terminal and the log file.
+ *
* @param {string} message - The log message.
* @deprecated Use console.log()/console.warn()/console.debug() instead.
*/
+
var print = function(message) {
console.log(message);
};
@@ -44,6 +46,7 @@ var printObject = function(obj, maxdepth) {
print(stringifyObject(obj, maxdepth));
};
+
var stringifyObject = function(obj, maxdepth, checked, prefix) {
if (!maxdepth) { maxdepth = 2; }
try {
@@ -54,9 +57,9 @@ var stringifyObject = function(obj, maxdepth, checked, prefix) {
if (maxdepth > 0 && typeof obj === "object" && obj !== null &&
Object.getPrototypeOf(obj) !== "" && !arrayContains(checked, obj)) {
checked.push(obj);
- var output = "{\n";
- for (var property in obj) {
- var value = obj[property];
+ let output = "{\n";
+ for (const property in obj) {
+ const value = obj[property];
if (typeof value === "function") { continue; }
output += prefix + property + ": "
+ stringifyObject(value, maxdepth - 1, checked, prefix + " ")
@@ -68,8 +71,9 @@ var stringifyObject = function(obj, maxdepth, checked, prefix) {
return obj;
};
+
var arrayContains = function(array, elem) {
- for (var i = 0; i < array.length; i++) {
+ for (let i = 0; i < array.length; i++) {
if (array[i] === elem) { return true; }
}
return false;
@@ -79,7 +83,7 @@ var arrayContains = function(array, elem) {
// eslint-disable-next-line no-unused-vars
var secondstominutes = function(secs) {
- var m = (secs / 60) | 0;
+ const m = (secs / 60) | 0;
return (m < 10 ? "0" + m : m)
+ ":"
@@ -88,9 +92,9 @@ var secondstominutes = function(secs) {
// eslint-disable-next-line no-unused-vars
var msecondstominutes = function(msecs) {
- var m = (msecs / 60000) | 0;
+ const m = (msecs / 60000) | 0;
msecs %= 60000;
- var secs = (msecs / 1000) | 0;
+ const secs = (msecs / 1000) | 0;
msecs %= 1000;
msecs = Math.round(msecs * 100 / 1000);
if (msecs === 100) { msecs = 99; }
@@ -149,7 +153,7 @@ script.midiDebug = function(channel, control, value, status, group) {
// Returns the deck number of a "ChannelN" or "SamplerN" group
script.deckFromGroup = function(group) {
- var deck = 0;
+ let deck = 0;
if (group.substring(2, 8) === "hannel") {
// Extract deck number from the group text
deck = group.substring(8, group.length - 1);
@@ -173,7 +177,7 @@ script.deckFromGroup = function(group) {
Output: none
-------- ------------------------------------------------------ */
script.bindConnections = function(group, controlsToFunctions, remove) {
- var control;
+ let control;
remove = (remove === undefined) ? false : remove;
for (control in controlsToFunctions) {
@@ -255,7 +259,7 @@ script.absoluteLinInverse = function(value, low, high, min, max) {
if (!max) {
max = 127;
}
- var result = (((value - low) * (max - min)) / (high - low)) + min;
+ const result = (((value - low) * (max - min)) / (high - low)) + min;
if (result < min) {
return min;
} else if (result > max) {
@@ -282,7 +286,7 @@ script.absoluteNonLin = function(value, low, mid, high, min, max) {
if (!max) {
max = 127;
}
- var center = (max - min) / 2;
+ const center = (max - min) / 2;
if (value === center || value === Math.round(center)) {
return mid;
} else if (value < center) {
@@ -307,8 +311,8 @@ script.absoluteNonLinInverse = function(value, low, mid, high, min, max) {
if (!max) {
max = 127;
}
- var center = (max - min) / 2;
- var result;
+ const center = (max - min) / 2;
+ let result;
if (value === mid) {
return center;
@@ -390,9 +394,9 @@ script.midiPitch = function(LSB, MSB, status) {
print("Script.midiPitch: Error, not a MIDI pitch (0xEn) message: " + status);
return false;
}
- var value = (MSB << 7) | LSB; // Construct the 14-bit number
+ const value = (MSB << 7) | LSB; // Construct the 14-bit number
// Range is 0x0000..0x3FFF center @ 0x2000, i.e. 0..16383 center @ 8192
- var rate = (value - 8192) / 8191;
+ const rate = (value - 8192) / 8191;
// print("Script.Pitch: MSB="+MSB+", LSB="+LSB+", value="+value+", rate="+rate);
return rate;
};
@@ -460,6 +464,7 @@ script.softStart = function(channel, control, value, status, group, factor) {
};
// bpm - Used for tapping the desired BPM for a deck
+
var bpm = function() {
};
@@ -477,8 +482,8 @@ bpm.tap = []; // Tap sample values
Output: -
-------- ------------------------------------------------------ */
bpm.tapButton = function(deck) {
- var now = new Date() / 1000; // Current time in seconds
- var tapDelta = now - bpm.tapTime;
+ const now = new Date() / 1000; // Current time in seconds
+ const tapDelta = now - bpm.tapTime;
bpm.tapTime = now;
// assign tapDelta in cases where the button has not been pressed previously
@@ -501,19 +506,19 @@ bpm.tapButton = function(deck) {
bpm.tap.push(60 / tapDelta);
// Keep the last 8 samples for averaging
if (bpm.tap.length > 8) { bpm.tap.shift(); }
- var sum = 0;
- for (var i=0; i<bpm.tap.length; i++) {
+ let sum = 0;
+ for (let i=0; i<bpm.tap.length; i++) {
sum += bpm.tap[i];
}
- var average = sum / bpm.tap.length;
+ const average = sum / bpm.tap.length;
- var group = "[Channel" + deck + "]";
+ const group = "[Channel" + deck + "]";
// "bpm" was changed in 1.10 to reflect the *adjusted* bpm, but I presume it
// was supposed to return the tracks bpm (which it did before the change).
// "file_bpm" is supposed to return the set BPM of the loaded track of the
// channel.
- var fRateScale = average/engine.getValue(group, "file_bpm");
+ let fRateScale = average/engine.getValue(group, "file_bpm");
// Adjust the rate:
fRateScale = (fRateScale - 1.) / engine.getValue(group, "rateRange");
@@ -534,11 +539,13 @@ script.individualEffectRegEx = /^\[EffectRack1_EffectUnit(\d+)_Effect(\d+)\]$/;
// ----------------- Object definitions --------------------------
+
var ButtonState = {"released": 0x00, "pressed": 0x7F};
// eslint-disable-next-line no-unused-vars
var LedState = {"off": 0x00, "on": 0x7F};
// Controller
+
var Controller = function() {
this.group = "[Master]";
this.Controls = [];
@@ -547,8 +554,8 @@ var Controller = function() {
Controller.prototype.addButton = function(buttonName, button, eventHandler) {
if (eventHandler) {
- var executionEnvironment = this;
- var handler = function(value) {
+ const executionEnvironment = this;
+ const handler = function(value) {
button.state = value;
executionEnvironment[eventHandler](value);
};
@@ -562,6 +569,7 @@ Controller.prototype.setControlValue = function(control, value) {
};
// Button
+
var Button = function(controlId) {
this.controlId = controlId;
this.state = ButtonState.released;
@@ -571,6 +579,7 @@ Button.prototype.handleEvent = function(value) {
};
// Control
+
var Control = function(mappedFunction, softMode) {
// These defaults are for MIDI controllers
this.minInput = 0;
@@ -587,7 +596,7 @@ var Control = function(mappedFunction, softMode) {
};
Control.prototype.setValue = function(group, inputValue) {
- var outputValue = 0;
+ let outputValue = 0;
if (inputValue <= this.midInput) {
outputValue = this.minOutput
+ ((inputValue - this.minInput) / (this.midInput - this.minInput))
@@ -598,8 +607,8 @@ Control.prototype.setValue = function(group, inputValue) {
* (this.maxOutput - this.midOutput);
}
if (this.softMode) {
- var currentValue = engine.getValue(group, this.mappedFunction);
- var currentRelative = 0.0;
+ const currentValue = engine.getValue(group, this.mappedFunction);
+ let currentRelative = 0.0;
if (currentValue <= this.midOutput) {
currentRelative = this.minInput
+ ((currentValue - this.minOutput) / (this.midOutput - this.minOutput))
@@ -619,6 +628,7 @@ Control.prototype.setValue = function(group, inputValue) {
};
// Deck
+
var Deck = function(deckNumber, group) {
this.deckNumber = deckNumber;
this.group = group;