From f13630edd3ddd94c701669e15a9be70fc410c71d Mon Sep 17 00:00:00 2001 From: Joerg Date: Mon, 27 Nov 2023 22:04:42 +0100 Subject: [PATCH 1/2] Reformatted code to modern ES6 class structure --- res/controllers/Traktor-Kontrol-Z1-scripts.js | 401 +++++++++--------- 1 file changed, 203 insertions(+), 198 deletions(-) diff --git a/res/controllers/Traktor-Kontrol-Z1-scripts.js b/res/controllers/Traktor-Kontrol-Z1-scripts.js index 152d9f41abd..bde7fca988a 100644 --- a/res/controllers/Traktor-Kontrol-Z1-scripts.js +++ b/res/controllers/Traktor-Kontrol-Z1-scripts.js @@ -5,244 +5,249 @@ // Author: djantti // -var KontrolZ1 = new function() { - this.controller = new HIDController(); +class TraktorZ1Class { + constructor() { + this.controller = new HIDController(); - // Modifier state - this.modePressed = false; + // Modifier state + this.modePressed = false; - // VuMeter - this.vuLeftConnection = {}; - this.vuRightConnection = {}; - this.vuMeterThresholds = {"vu-30": (1 / 7), "vu-15": (2 / 7), "vu-6": (3 / 7), "vu-3": (4 / 7), "vu0": (5 / 7), "vu3": (6 / 7), "vu6": (7 / 7)}; -}; + // VuMeter + this.vuLeftConnection = {}; + this.vuRightConnection = {}; + this.vuMeterThresholds = {"vu-30": (1 / 7), "vu-15": (2 / 7), "vu-6": (3 / 7), "vu-3": (4 / 7), "vu0": (5 / 7), "vu3": (6 / 7), "vu6": (7 / 7)}; + } -KontrolZ1.init = function(_id) { - KontrolZ1.id = _id; - KontrolZ1.registerInputPackets(); - KontrolZ1.registerOutputPackets(); - console.log(KontrolZ1.id + " initialized"); -}; + init(_id) { + this.id = _id; + this.registerInputPackets(); + this.registerOutputPackets(); + console.log(this.id + " initialized"); + } -KontrolZ1.registerInputPackets = function() { - const message = new HIDPacket("message", 0x1, this.messageCallback); + registerInputPackets() { + const message = new HIDPacket("message", 0x1, this.messageCallback); - // Mode button - this.registerInputButton(message, "[ControlX]", "!mode", 0x1D, 0x2, this.modeHandler); + // Mode button + this.registerInputButton(message, "[ControlX]", "!mode", 0x1D, 0x2, this.modeHandler); - // Headphone buttons - this.registerInputButton(message, "[Channel1]", "!pfl", 0x1D, 0x10, this.headphoneHandler); - this.registerInputButton(message, "[Channel2]", "!pfl", 0x1D, 0x1, this.headphoneHandler); + // Headphone buttons + this.registerInputButton(message, "[Channel1]", "!pfl", 0x1D, 0x10, this.headphoneHandler); + this.registerInputButton(message, "[Channel2]", "!pfl", 0x1D, 0x1, this.headphoneHandler); - // FX buttons - this.registerInputButton(message, "[Channel1]", "!fx", 0x1D, 0x4, this.fxHandler); - this.registerInputButton(message, "[Channel2]", "!fx", 0x1D, 0x8, this.fxHandler); + // FX buttons + this.registerInputButton(message, "[Channel1]", "!fx", 0x1D, 0x4, this.fxHandler); + this.registerInputButton(message, "[Channel2]", "!fx", 0x1D, 0x8, this.fxHandler); - // EQ knobs - this.registerInputScaler(message, "[EqualizerRack1_[Channel1]_Effect1]", "parameter3", 0x3, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[EqualizerRack1_[Channel1]_Effect1]", "parameter2", 0x5, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[EqualizerRack1_[Channel1]_Effect1]", "parameter1", 0x7, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[EqualizerRack1_[Channel2]_Effect1]", "parameter3", 0xD, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[EqualizerRack1_[Channel2]_Effect1]", "parameter2", 0xF, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[EqualizerRack1_[Channel2]_Effect1]", "parameter1", 0x11, 0xFFFF, this.parameterHandler); + // EQ knobs + this.registerInputScaler(message, "[EqualizerRack1_[Channel1]_Effect1]", "parameter3", 0x3, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[EqualizerRack1_[Channel1]_Effect1]", "parameter2", 0x5, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[EqualizerRack1_[Channel1]_Effect1]", "parameter1", 0x7, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[EqualizerRack1_[Channel2]_Effect1]", "parameter3", 0xD, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[EqualizerRack1_[Channel2]_Effect1]", "parameter2", 0xF, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[EqualizerRack1_[Channel2]_Effect1]", "parameter1", 0x11, 0xFFFF, this.parameterHandler); - // FX knobs - this.registerInputScaler(message, "[QuickEffectRack1_[Channel1]]", "super1", 0x9, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[QuickEffectRack1_[Channel2]]", "super1", 0x13, 0xFFFF, this.parameterHandler); + // FX knobs + this.registerInputScaler(message, "[QuickEffectRack1_[Channel1]]", "super1", 0x9, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[QuickEffectRack1_[Channel2]]", "super1", 0x13, 0xFFFF, this.parameterHandler); - // Gain knobs - this.registerInputScaler(message, "[Channel1]", "pregain", 0x1, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[Channel2]", "pregain", 0xB, 0xFFFF, this.parameterHandler); + // Gain knobs + this.registerInputScaler(message, "[Channel1]", "pregain", 0x1, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[Channel2]", "pregain", 0xB, 0xFFFF, this.parameterHandler); - // Headphone mix - this.registerInputScaler(message, "[Master]", "headMix", 0x15, 0xFFFF, this.parameterHandler); + // Headphone mix + this.registerInputScaler(message, "[Master]", "headMix", 0x15, 0xFFFF, this.parameterHandler); - // Volume faders - this.registerInputScaler(message, "[Channel1]", "volume", 0x17, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[Channel2]", "volume", 0x19, 0xFFFF, this.parameterHandler); + // Volume faders + this.registerInputScaler(message, "[Channel1]", "volume", 0x17, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[Channel2]", "volume", 0x19, 0xFFFF, this.parameterHandler); - // Crossfader - this.registerInputScaler(message, "[Master]", "crossfader", 0x1B, 0xFFFF, this.parameterHandler); + // Crossfader + this.registerInputScaler(message, "[Master]", "crossfader", 0x1B, 0xFFFF, this.parameterHandler); - this.controller.registerInputPacket(message); + this.controller.registerInputPacket(message); - // Soft takeover for all knobs and faders - engine.softTakeover("[EqualizerRack1_[Channel1]_Effect1]", "parameter3", true); - engine.softTakeover("[EqualizerRack1_[Channel1]_Effect1]", "parameter2", true); - engine.softTakeover("[EqualizerRack1_[Channel1]_Effect1]", "parameter1", true); + // Soft takeover for all knobs and faders + engine.softTakeover("[EqualizerRack1_[Channel1]_Effect1]", "parameter3", true); + engine.softTakeover("[EqualizerRack1_[Channel1]_Effect1]", "parameter2", true); + engine.softTakeover("[EqualizerRack1_[Channel1]_Effect1]", "parameter1", true); - engine.softTakeover("[EqualizerRack1_[Channel2]_Effect1]", "parameter3", true); - engine.softTakeover("[EqualizerRack1_[Channel2]_Effect1]", "parameter2", true); - engine.softTakeover("[EqualizerRack1_[Channel2]_Effect1]", "parameter1", true); + engine.softTakeover("[EqualizerRack1_[Channel2]_Effect1]", "parameter3", true); + engine.softTakeover("[EqualizerRack1_[Channel2]_Effect1]", "parameter2", true); + engine.softTakeover("[EqualizerRack1_[Channel2]_Effect1]", "parameter1", true); - engine.softTakeover("[QuickEffectRack1_[Channel1]]", "super1", true); - engine.softTakeover("[QuickEffectRack1_[Channel2]]", "super1", true); + engine.softTakeover("[QuickEffectRack1_[Channel1]]", "super1", true); + engine.softTakeover("[QuickEffectRack1_[Channel2]]", "super1", true); - engine.softTakeover("[Channel1]", "pregain", true); - engine.softTakeover("[Channel2]", "pregain", true); - - engine.softTakeover("[Master]", "headMix", true); - - engine.softTakeover("[Channel1]", "volume", true); - engine.softTakeover("[Channel2]", "volume", true); - - engine.softTakeover("[Master]", "crossfader", true); -}; - -KontrolZ1.registerInputButton = function(message, group, name, offset, bitmask, callback) { - message.addControl(group, name, offset, "B", bitmask); - message.setCallback(group, name, callback); -}; - -KontrolZ1.registerInputScaler = function(message, group, name, offset, bitmask, callback) { - message.addControl(group, name, offset, "H", bitmask); - message.setCallback(group, name, callback); -}; - -KontrolZ1.registerOutputPackets = function() { - const output = new HIDPacket("output", 0x80); - - output.addOutput("[ControlX]", "mode", 0x13, "B"); - - output.addOutput("[Channel1]", "pfl", 0xF, "B"); - output.addOutput("[Channel2]", "pfl", 0x10, "B"); - - output.addOutput("[Channel1]", "play_indicator", 0x11, "B"); - output.addOutput("[Channel2]", "play_indicator", 0x14, "B"); - - output.addOutput("[QuickEffectRack1_[Channel1]]", "enabled", 0x12, "B"); - output.addOutput("[QuickEffectRack1_[Channel2]]", "enabled", 0x15, "B"); - - output.addOutput("[Channel1]", "vu-30", 0x1, "B"); - output.addOutput("[Channel1]", "vu-15", 0x2, "B"); - output.addOutput("[Channel1]", "vu-6", 0x3, "B"); - output.addOutput("[Channel1]", "vu-3", 0x4, "B"); - output.addOutput("[Channel1]", "vu0", 0x5, "B"); - output.addOutput("[Channel1]", "vu3", 0x6, "B"); - output.addOutput("[Channel1]", "vu6", 0x7, "B"); - - output.addOutput("[Channel2]", "vu-30", 0x8, "B"); - output.addOutput("[Channel2]", "vu-15", 0x9, "B"); - output.addOutput("[Channel2]", "vu-6", 0xA, "B"); - output.addOutput("[Channel2]", "vu-3", 0xB, "B"); - output.addOutput("[Channel2]", "vu0", 0xC, "B"); - output.addOutput("[Channel2]", "vu3", 0xD, "B"); - output.addOutput("[Channel2]", "vu6", 0xE, "B"); - - this.controller.registerOutputPacket(output); - - engine.makeConnection("[QuickEffectRack1_[Channel1]]", "enabled", this.outputHandler); - engine.makeConnection("[QuickEffectRack1_[Channel2]]", "enabled", this.outputHandler); + engine.softTakeover("[Channel1]", "pregain", true); + engine.softTakeover("[Channel2]", "pregain", true); - engine.makeConnection("[Channel1]", "pfl", this.outputHandler); - engine.makeConnection("[Channel2]", "pfl", this.outputHandler); - - this.vuLeftConnection = engine.makeUnbufferedConnection("[Channel1]", "vu_meter", this.vuMeterHandler); - this.vuRightConnection = engine.makeUnbufferedConnection("[Channel2]", "vu_meter", this.vuMeterHandler); - - KontrolZ1.lightDeck(false); -}; + engine.softTakeover("[Master]", "headMix", true); -KontrolZ1.modeHandler = function(field) { - KontrolZ1.modePressed = field.value; - KontrolZ1.outputHandler(field.value, field.group, "mode"); -}; + engine.softTakeover("[Channel1]", "volume", true); + engine.softTakeover("[Channel2]", "volume", true); -KontrolZ1.headphoneHandler = function(field) { - if (field.value === 0) { - return; + engine.softTakeover("[Master]", "crossfader", true); } - // Go to cue and stop when modifier is active - if (KontrolZ1.modePressed) { - engine.setValue(field.group, "cue_gotoandstop", field.value); - } else { - script.toggleControl(field.group, "pfl"); + + registerInputButton(message, group, name, offset, bitmask, callback) { + message.addControl(group, name, offset, "B", bitmask); + message.setCallback(group, name, callback); } -}; -KontrolZ1.fxHandler = function(field) { - if (field.value === 0) { - // Always clear play indicator on button release - KontrolZ1.controller.setOutput(field.group, "play_indicator", 0x0, true); - return; + registerInputScaler(message, group, name, offset, bitmask, callback) { + message.addControl(group, name, offset, "H", bitmask); + message.setCallback(group, name, callback); } - // Control playback when modifier is active - if (KontrolZ1.modePressed) { - // Match play indicator (red led) brightness to fx indicator (blue led) - const current = engine.getValue("[QuickEffectRack1_" + field.group + "]", "enabled") ? 0x7F : 0xA; - KontrolZ1.controller.setOutput(field.group, "play_indicator", current, true); - script.toggleControl(field.group, "play"); - } else { - script.toggleControl("[QuickEffectRack1_" + field.group + "]", "enabled"); + + registerOutputPackets() { + const output = new HIDPacket("output", 0x80); + + output.addOutput("[ControlX]", "mode", 0x13, "B"); + + output.addOutput("[Channel1]", "pfl", 0xF, "B"); + output.addOutput("[Channel2]", "pfl", 0x10, "B"); + + output.addOutput("[Channel1]", "play_indicator", 0x11, "B"); + output.addOutput("[Channel2]", "play_indicator", 0x14, "B"); + + output.addOutput("[QuickEffectRack1_[Channel1]]", "enabled", 0x12, "B"); + output.addOutput("[QuickEffectRack1_[Channel2]]", "enabled", 0x15, "B"); + + output.addOutput("[Channel1]", "vu-30", 0x1, "B"); + output.addOutput("[Channel1]", "vu-15", 0x2, "B"); + output.addOutput("[Channel1]", "vu-6", 0x3, "B"); + output.addOutput("[Channel1]", "vu-3", 0x4, "B"); + output.addOutput("[Channel1]", "vu0", 0x5, "B"); + output.addOutput("[Channel1]", "vu3", 0x6, "B"); + output.addOutput("[Channel1]", "vu6", 0x7, "B"); + + output.addOutput("[Channel2]", "vu-30", 0x8, "B"); + output.addOutput("[Channel2]", "vu-15", 0x9, "B"); + output.addOutput("[Channel2]", "vu-6", 0xA, "B"); + output.addOutput("[Channel2]", "vu-3", 0xB, "B"); + output.addOutput("[Channel2]", "vu0", 0xC, "B"); + output.addOutput("[Channel2]", "vu3", 0xD, "B"); + output.addOutput("[Channel2]", "vu6", 0xE, "B"); + + this.controller.registerOutputPacket(output); + + engine.makeConnection("[QuickEffectRack1_[Channel1]]", "enabled", this.outputHandler); + engine.makeConnection("[QuickEffectRack1_[Channel2]]", "enabled", this.outputHandler); + + engine.makeConnection("[Channel1]", "pfl", this.outputHandler); + engine.makeConnection("[Channel2]", "pfl", this.outputHandler); + + this.vuLeftConnection = engine.makeUnbufferedConnection("[Channel1]", "vu_meter", this.vuMeterHandler); + this.vuRightConnection = engine.makeUnbufferedConnection("[Channel2]", "vu_meter", this.vuMeterHandler); + + this.lightDeck(false); + } + + modeHandler(field) { + this.modePressed = field.value; + this.outputHandler(field.value, field.group, "mode"); } -}; - -KontrolZ1.vuMeterHandler = function(value, group, _key) { - const vuKeys = Object.keys(KontrolZ1.vuMeterThresholds); - for (let i = 0; i < vuKeys.length; ++i) { - // Avoid spamming HID by only sending last LED update - const last = i === (vuKeys.length - 1); - if (KontrolZ1.vuMeterThresholds[vuKeys[i]] > value) { - KontrolZ1.controller.setOutput(group, vuKeys[i], 0x00, last); + + headphoneHandler(field) { + if (field.value === 0) { + return; + } + // Go to cue and stop when modifier is active + if (this.modePressed) { + engine.setValue(field.group, "cue_gotoandstop", field.value); } else { - KontrolZ1.controller.setOutput(group, vuKeys[i], 0x7E, last); + script.toggleControl(field.group, "pfl"); } } -}; -KontrolZ1.parameterHandler = function(field) { - engine.setParameter(field.group, field.name, field.value / 4095); -}; + fxHandler(field) { + if (field.value === 0) { + // Always clear play indicator on button release + this.controller.setOutput(field.group, "play_indicator", 0x0, true); + return; + } + // Control playback when modifier is active + if (this.modePressed) { + // Match play indicator (red led) brightness to fx indicator (blue led) + const current = engine.getValue("[QuickEffectRack1_" + field.group + "]", "enabled") ? 0x7F : 0xA; + this.controller.setOutput(field.group, "play_indicator", current, true); + script.toggleControl(field.group, "play"); + } else { + script.toggleControl("[QuickEffectRack1_" + field.group + "]", "enabled"); + } + } -KontrolZ1.outputHandler = function(value, group, key) { - let ledValue; - if (value === 0 || value === false) { - // Off value (dimmed) - ledValue = 0xA; - } else if (value === 1 || value === true) { - // On value - ledValue = 0x7F; + vuMeterHandler(value, group, _key) { + const vuKeys = Object.keys(this.vuMeterThresholds); + for (let i = 0; i < vuKeys.length; ++i) { + // Avoid spamming HID by only sending last LED update + const last = i === (vuKeys.length - 1); + if (this.vuMeterThresholds[vuKeys[i]] > value) { + this.controller.setOutput(group, vuKeys[i], 0x00, last); + } else { + this.controller.setOutput(group, vuKeys[i], 0x7E, last); + } + } } - KontrolZ1.controller.setOutput(group, key, ledValue, true); -}; -KontrolZ1.lightDeck = function(switchOff) { - let softLight = 0xA; - let fullLight = 0x7F; - let current; - if (switchOff) { - softLight = 0x00; - fullLight = 0x00; + parameterHandler(field) { + engine.setParameter(field.group, field.name, field.value / 4095); } - KontrolZ1.controller.setOutput("[ControlX]", "mode", softLight, true); + outputHandler(value, group, key) { + let ledValue; + if (value === 0 || value === false) { + // Off value (dimmed) + ledValue = 0xA; + } else if (value === 1 || value === true) { + // On value + ledValue = 0x7F; + } + this.controller.setOutput(group, key, ledValue, true); + } - current = engine.getValue("[QuickEffectRack1_[Channel1]]", "enabled") ? fullLight : softLight; - KontrolZ1.controller.setOutput("[QuickEffectRack1_[Channel1]]", "enabled", current, true); - current = engine.getValue("[QuickEffectRack1_[Channel2]]", "enabled") ? fullLight : softLight; - KontrolZ1.controller.setOutput("[QuickEffectRack1_[Channel2]]", "enabled", current, true); + lightDeck(switchOff) { + let softLight = 0xA; + let fullLight = 0x7F; + let current; - current = engine.getValue("[Channel1]", "pfl") ? fullLight : softLight; - KontrolZ1.controller.setOutput("[Channel1]", "pfl", current, true); - current = engine.getValue("[Channel2]", "pfl") ? fullLight : softLight; - KontrolZ1.controller.setOutput("[Channel2]", "pfl", current, true); -}; + if (switchOff) { + softLight = 0x00; + fullLight = 0x00; + } + + this.controller.setOutput("[ControlX]", "mode", softLight, true); + + current = engine.getValue("[QuickEffectRack1_[Channel1]]", "enabled") ? fullLight : softLight; + this.controller.setOutput("[QuickEffectRack1_[Channel1]]", "enabled", current, true); + current = engine.getValue("[QuickEffectRack1_[Channel2]]", "enabled") ? fullLight : softLight; + this.controller.setOutput("[QuickEffectRack1_[Channel2]]", "enabled", current, true); + + current = engine.getValue("[Channel1]", "pfl") ? fullLight : softLight; + this.controller.setOutput("[Channel1]", "pfl", current, true); + current = engine.getValue("[Channel2]", "pfl") ? fullLight : softLight; + this.controller.setOutput("[Channel2]", "pfl", current, true); + } -KontrolZ1.messageCallback = function(packet, data) { - for (const name in data) { - if (Object.hasOwnProperty.call(data, name)) { - KontrolZ1.controller.processButton(data[name]); + messageCallback(packet, data) { + for (const name in data) { + if (Object.hasOwnProperty.call(data, name)) { + this.controller.processButton(data[name]); + } } } -}; -KontrolZ1.shutdown = function() { - // Deactivate all LEDs - KontrolZ1.lightDeck(true); - console.log(KontrolZ1.id + " shut down"); -}; + shutdown() { + // Deactivate all LEDs + this.lightDeck(true); + console.log(this.id + " shut down"); + } + + incomingData(data, length) { + this.controller.parsePacket(data, length); + } +} -KontrolZ1.incomingData = function(data, length) { - KontrolZ1.controller.parsePacket(data, length); -}; +var TraktorZ1 = new TraktorZ1Class; // eslint-disable-line no-var, no-unused-vars From cfc642bf91e9e97d562828ba7d21a64ce7ac3695 Mon Sep 17 00:00:00 2001 From: Joerg Date: Wed, 6 Dec 2023 23:44:27 +0100 Subject: [PATCH 2/2] Append .bind(this) to all the callback functions --- res/controllers/Traktor-Kontrol-Z1-scripts.js | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/res/controllers/Traktor-Kontrol-Z1-scripts.js b/res/controllers/Traktor-Kontrol-Z1-scripts.js index bde7fca988a..e27905a2c0d 100644 --- a/res/controllers/Traktor-Kontrol-Z1-scripts.js +++ b/res/controllers/Traktor-Kontrol-Z1-scripts.js @@ -26,44 +26,44 @@ class TraktorZ1Class { } registerInputPackets() { - const message = new HIDPacket("message", 0x1, this.messageCallback); + const message = new HIDPacket("message", 0x1, this.messageCallback.bind(this)); // Mode button - this.registerInputButton(message, "[ControlX]", "!mode", 0x1D, 0x2, this.modeHandler); + this.registerInputButton(message, "[ControlX]", "!mode", 0x1D, 0x2, this.modeHandler.bind(this)); // Headphone buttons - this.registerInputButton(message, "[Channel1]", "!pfl", 0x1D, 0x10, this.headphoneHandler); - this.registerInputButton(message, "[Channel2]", "!pfl", 0x1D, 0x1, this.headphoneHandler); + this.registerInputButton(message, "[Channel1]", "!pfl", 0x1D, 0x10, this.headphoneHandler.bind(this)); + this.registerInputButton(message, "[Channel2]", "!pfl", 0x1D, 0x1, this.headphoneHandler.bind(this)); // FX buttons - this.registerInputButton(message, "[Channel1]", "!fx", 0x1D, 0x4, this.fxHandler); - this.registerInputButton(message, "[Channel2]", "!fx", 0x1D, 0x8, this.fxHandler); + this.registerInputButton(message, "[Channel1]", "!fx", 0x1D, 0x4, this.fxHandler.bind(this)); + this.registerInputButton(message, "[Channel2]", "!fx", 0x1D, 0x8, this.fxHandler.bind(this)); // EQ knobs - this.registerInputScaler(message, "[EqualizerRack1_[Channel1]_Effect1]", "parameter3", 0x3, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[EqualizerRack1_[Channel1]_Effect1]", "parameter2", 0x5, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[EqualizerRack1_[Channel1]_Effect1]", "parameter1", 0x7, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[EqualizerRack1_[Channel2]_Effect1]", "parameter3", 0xD, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[EqualizerRack1_[Channel2]_Effect1]", "parameter2", 0xF, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[EqualizerRack1_[Channel2]_Effect1]", "parameter1", 0x11, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[EqualizerRack1_[Channel1]_Effect1]", "parameter3", 0x3, 0xFFFF, this.parameterHandler.bind(this)); + this.registerInputScaler(message, "[EqualizerRack1_[Channel1]_Effect1]", "parameter2", 0x5, 0xFFFF, this.parameterHandler.bind(this)); + this.registerInputScaler(message, "[EqualizerRack1_[Channel1]_Effect1]", "parameter1", 0x7, 0xFFFF, this.parameterHandler.bind(this)); + this.registerInputScaler(message, "[EqualizerRack1_[Channel2]_Effect1]", "parameter3", 0xD, 0xFFFF, this.parameterHandler.bind(this)); + this.registerInputScaler(message, "[EqualizerRack1_[Channel2]_Effect1]", "parameter2", 0xF, 0xFFFF, this.parameterHandler.bind(this)); + this.registerInputScaler(message, "[EqualizerRack1_[Channel2]_Effect1]", "parameter1", 0x11, 0xFFFF, this.parameterHandler.bind(this)); // FX knobs - this.registerInputScaler(message, "[QuickEffectRack1_[Channel1]]", "super1", 0x9, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[QuickEffectRack1_[Channel2]]", "super1", 0x13, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[QuickEffectRack1_[Channel1]]", "super1", 0x9, 0xFFFF, this.parameterHandler.bind(this)); + this.registerInputScaler(message, "[QuickEffectRack1_[Channel2]]", "super1", 0x13, 0xFFFF, this.parameterHandler.bind(this)); // Gain knobs - this.registerInputScaler(message, "[Channel1]", "pregain", 0x1, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[Channel2]", "pregain", 0xB, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[Channel1]", "pregain", 0x1, 0xFFFF, this.parameterHandler.bind(this)); + this.registerInputScaler(message, "[Channel2]", "pregain", 0xB, 0xFFFF, this.parameterHandler.bind(this)); // Headphone mix - this.registerInputScaler(message, "[Master]", "headMix", 0x15, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[Master]", "headMix", 0x15, 0xFFFF, this.parameterHandler.bind(this)); // Volume faders - this.registerInputScaler(message, "[Channel1]", "volume", 0x17, 0xFFFF, this.parameterHandler); - this.registerInputScaler(message, "[Channel2]", "volume", 0x19, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[Channel1]", "volume", 0x17, 0xFFFF, this.parameterHandler.bind(this)); + this.registerInputScaler(message, "[Channel2]", "volume", 0x19, 0xFFFF, this.parameterHandler.bind(this)); // Crossfader - this.registerInputScaler(message, "[Master]", "crossfader", 0x1B, 0xFFFF, this.parameterHandler); + this.registerInputScaler(message, "[Master]", "crossfader", 0x1B, 0xFFFF, this.parameterHandler.bind(this)); this.controller.registerInputPacket(message); @@ -132,14 +132,14 @@ class TraktorZ1Class { this.controller.registerOutputPacket(output); - engine.makeConnection("[QuickEffectRack1_[Channel1]]", "enabled", this.outputHandler); - engine.makeConnection("[QuickEffectRack1_[Channel2]]", "enabled", this.outputHandler); + engine.makeConnection("[QuickEffectRack1_[Channel1]]", "enabled", this.outputHandler.bind(this)); + engine.makeConnection("[QuickEffectRack1_[Channel2]]", "enabled", this.outputHandler.bind(this)); - engine.makeConnection("[Channel1]", "pfl", this.outputHandler); - engine.makeConnection("[Channel2]", "pfl", this.outputHandler); + engine.makeConnection("[Channel1]", "pfl", this.outputHandler.bind(this)); + engine.makeConnection("[Channel2]", "pfl", this.outputHandler.bind(this)); - this.vuLeftConnection = engine.makeUnbufferedConnection("[Channel1]", "vu_meter", this.vuMeterHandler); - this.vuRightConnection = engine.makeUnbufferedConnection("[Channel2]", "vu_meter", this.vuMeterHandler); + this.vuLeftConnection = engine.makeUnbufferedConnection("[Channel1]", "vu_meter", this.vuMeterHandler.bind(this)); + this.vuRightConnection = engine.makeUnbufferedConnection("[Channel2]", "vu_meter", this.vuMeterHandler.bind(this)); this.lightDeck(false); }