Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traktor S3: fixes and updates #12409

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions res/controllers/Traktor-Kontrol-S3-hid-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ TraktorS3.Controller = class {
this.fxButtonState = {1: false, 2: false, 3: false, 4: false, 5: false};

this.masterVuMeter = {
"VuMeterL": {
"vu_meter_left": {
connection: null,
updated: false,
value: 0
},
"VuMeterR": {
"vu_meter_right": {
connection: null,
updated: false,
value: 0
Expand Down Expand Up @@ -281,9 +281,9 @@ TraktorS3.Controller = class {
const chanob = this.Channels[ch];
engine.makeConnection(ch, "playposition",
TraktorS3.Channel.prototype.playpositionChanged.bind(chanob));
engine.connectControl(ch, "track_loaded",
engine.makeConnection(ch, "track_loaded",
TraktorS3.Channel.prototype.trackLoadedHandler.bind(chanob));
engine.connectControl(ch, "end_of_track",
engine.makeConnection(ch, "end_of_track",
TraktorS3.Channel.prototype.endOfTrackHandler.bind(chanob));
}

Expand Down Expand Up @@ -496,17 +496,17 @@ TraktorS3.Controller = class {
};
for (const ch in VuOffsets) {
for (let i = 0; i < 14; i++) {
outputB.addOutput(ch, "!" + "VuMeter" + i, VuOffsets[ch] + i, "B");
outputB.addOutput(ch, "!" + "vu_meter" + i, VuOffsets[ch] + i, "B");
}
}

const MasterVuOffsets = {
"VuMeterL": 0x3D,
"VuMeterR": 0x46
"vu_meter_left": 0x3D,
"vu_meter_right": 0x46
};
for (let i = 0; i < 8; i++) {
outputB.addOutput("[Master]", "!" + "VuMeterL" + i, MasterVuOffsets.VuMeterL + i, "B");
outputB.addOutput("[Master]", "!" + "VuMeterR" + i, MasterVuOffsets.VuMeterR + i, "B");
outputB.addOutput("[Main]", "!" + "vu_meter_left" + i, MasterVuOffsets.vu_meter_left + i, "B");
outputB.addOutput("[Main]", "!" + "vu_meter_right" + i, MasterVuOffsets.vu_meter_right + i, "B");
}

outputB.addOutput("[Main]", "peak_indicator_left", 0x45, "B");
Expand All @@ -527,13 +527,13 @@ TraktorS3.Controller = class {
this.Channels[idx].linkOutputs();
}

engine.connectControl("[Microphone]", "pfl", this.pflOutput);
engine.makeConnection("[Microphone]", "pfl", this.pflOutput);

engine.connectControl("[Skin]", "show_maximized_library", TraktorS3.Controller.prototype.maximizeLibraryOutput.bind(this));
engine.makeConnection("[Skin]", "show_maximized_library", TraktorS3.Controller.prototype.maximizeLibraryOutput.bind(this));

// Master VuMeters
this.masterVuMeter.VuMeterL.connection = engine.makeConnection("[Main]", "vu_meter_left", TraktorS3.Controller.prototype.masterVuMeterHandler.bind(this));
this.masterVuMeter.VuMeterR.connection = engine.makeConnection("[Main]", "vu_meter_right", TraktorS3.Controller.prototype.masterVuMeterHandler.bind(this));
this.masterVuMeter.vu_meter_left.connection = engine.makeConnection("[Main]", "vu_meter_left", TraktorS3.Controller.prototype.masterVuMeterHandler.bind(this));
this.masterVuMeter.vu_meter_right.connection = engine.makeConnection("[Main]", "vu_meter_right", TraktorS3.Controller.prototype.masterVuMeterHandler.bind(this));
this.linkChannelOutput("[Main]", "peak_indicator_left", TraktorS3.Controller.prototype.peakOutput.bind(this));
this.linkChannelOutput("[Main]", "peak_indicator_right", TraktorS3.Controller.prototype.peakOutput.bind(this));
this.guiTickConnection = engine.makeConnection("[App]", "gui_tick_50ms_period_s", TraktorS3.Controller.prototype.guiTickHandler.bind(this));
Expand Down Expand Up @@ -764,15 +764,15 @@ TraktorS3.Controller = class {

for (const vu in this.masterVuMeter) {
if (this.masterVuMeter[vu].updated) {
this.vuMeterOutput(this.masterVuMeter[vu].value, "[Master]", vu, 8);
this.vuMeterOutput(this.masterVuMeter[vu].value, "[Main]", vu, 8);
this.masterVuMeter[vu].updated = false;
gotUpdate = true;
}
}
for (let ch = 1; ch <= 4; ch++) {
const chan = this.Channels["[Channel" + ch + "]"];
if (chan.vuMeterUpdated) {
this.vuMeterOutput(chan.vuMeterValue, chan.group, "VuMeter", 14);
this.vuMeterOutput(chan.vuMeterValue, chan.group, "vu_meter", 14);
chan.vuMeterUpdated = false;
gotUpdate = true;
}
Expand Down Expand Up @@ -1449,11 +1449,11 @@ TraktorS3.Deck = class {
switch (this.deckNumber) {
case 1:
this.controller.hid.linkOutput("deck1", key, "[Channel1]", key, callback);
engine.connectControl("[Channel3]", key, callback);
engine.makeConnection("[Channel3]", key, callback);
break;
case 2:
this.controller.hid.linkOutput("deck2", key, "[Channel2]", key, callback);
engine.connectControl("[Channel4]", key, callback);
engine.makeConnection("[Channel4]", key, callback);
break;
}
}
Expand Down Expand Up @@ -1516,7 +1516,7 @@ TraktorS3.Deck = class {
}

lightHotcue(number) {
const loaded = engine.getValue(this.activeChannel, "hotcue_" + number + "_enabled");
const loaded = engine.getValue(this.activeChannel, "hotcue_" + number + "_status");
const active = engine.getValue(this.activeChannel, "hotcue_" + number + "_activate");
let ledValue = this.controller.hid.LEDColors.WHITE;
if (loaded) {
Expand Down Expand Up @@ -1695,7 +1695,7 @@ TraktorS3.Channel = class {
this.clipConnection = engine.makeConnection(this.group, "peak_indicator", TraktorS3.Controller.prototype.peakOutput.bind(this.controller));
this.controller.linkChannelOutput(this.group, "pfl", TraktorS3.Controller.prototype.pflOutput.bind(this.controller));
for (let j = 1; j <= 8; j++) {
this.hotcueCallbacks.push(engine.makeConnection(this.group, "hotcue_" + j + "_enabled",
this.hotcueCallbacks.push(engine.makeConnection(this.group, "hotcue_" + j + "_status",
TraktorS3.Channel.prototype.hotcuesOutput.bind(this)));
this.hotcueCallbacks.push(engine.makeConnection(this.group, "hotcue_" + j + "_activate",
TraktorS3.Channel.prototype.hotcuesOutput.bind(this)));
Expand Down Expand Up @@ -2402,17 +2402,17 @@ TraktorS3.QuickFxControl = class {

// This changes the lighting of the five FX Select buttons and maybe
// also the FX Enable buttons
engine.connectControl("[QuickEffectRack1_[Channel1]]", "loaded_chain_preset", this.quickEffectChainLoadHandler.bind(this));
engine.connectControl("[QuickEffectRack1_[Channel2]]", "loaded_chain_preset", this.quickEffectChainLoadHandler.bind(this));
engine.connectControl("[QuickEffectRack1_[Channel3]]", "loaded_chain_preset", this.quickEffectChainLoadHandler.bind(this));
engine.connectControl("[QuickEffectRack1_[Channel4]]", "loaded_chain_preset", this.quickEffectChainLoadHandler.bind(this));
engine.makeConnection("[QuickEffectRack1_[Channel1]]", "loaded_chain_preset", this.quickEffectChainLoadHandler.bind(this));
engine.makeConnection("[QuickEffectRack1_[Channel2]]", "loaded_chain_preset", this.quickEffectChainLoadHandler.bind(this));
engine.makeConnection("[QuickEffectRack1_[Channel3]]", "loaded_chain_preset", this.quickEffectChainLoadHandler.bind(this));
engine.makeConnection("[QuickEffectRack1_[Channel4]]", "loaded_chain_preset", this.quickEffectChainLoadHandler.bind(this));

// The FX enable buttons can directly be bound to the quick effect chain
// enabled status as their lighting doesn't depend on other factors
engine.connectControl("[QuickEffectRack1_[Channel1]]", "enabled", value => this.lightFxEnable(1, value === 1));
engine.connectControl("[QuickEffectRack1_[Channel2]]", "enabled", value => this.lightFxEnable(2, value === 1));
engine.connectControl("[QuickEffectRack1_[Channel3]]", "enabled", value => this.lightFxEnable(3, value === 1));
engine.connectControl("[QuickEffectRack1_[Channel4]]", "enabled", value => this.lightFxEnable(4, value === 1));
engine.makeConnection("[QuickEffectRack1_[Channel1]]", "enabled", value => this.lightFxEnable(1, value === 1));
engine.makeConnection("[QuickEffectRack1_[Channel2]]", "enabled", value => this.lightFxEnable(2, value === 1));
engine.makeConnection("[QuickEffectRack1_[Channel3]]", "enabled", value => this.lightFxEnable(3, value === 1));
engine.makeConnection("[QuickEffectRack1_[Channel4]]", "enabled", value => this.lightFxEnable(4, value === 1));
}

// Input handling
Expand Down
12 changes: 6 additions & 6 deletions res/controllers/common-hid-packet-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2077,9 +2077,9 @@ class HIDController {
continue;
}
const bitControlGroup = this.resolveGroup(bit.mapped_group);
engine.connectControl(
engine.makeConnection(
bitControlGroup, bit.mapped_name, bit.mapped_callback, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeConnection has not 4th parameter as connectControl. See

* Connects a specified Mixxx Control with a callback function, which is executed if the value of the control changes
*
* This connection has a FIFO buffer - all value change events are processed in serial order.
*
* @param group Group of the control e.g. "[Channel1]"
* @param name Name of the control e.g. "play_indicator"
* @param callback JS function, which will be called every time, the value of the connected control changes.
* @returns Returns script connection object on success, otherwise 'undefined''
*/
function makeConnection(group: string, name: string, callback: CoCallback): ScriptConnection |undefined;

vs.
/**
* This function is a legacy version of makeConnection with several alternate
* ways of invoking it. The callback function can be passed either as a string of
* JavaScript code that evaluates to a function or an actual JavaScript function.
*
* @param group Group of the control e.g. "[Channel1]"
* @param name Name of the control e.g. "vu_meter"
* @param callback JS function, which will be called every time, the value of the connected control changes.
* @param disconnect If "true", all connections to the ControlObject are removed. [default = false]
* @returns Returns script connection object on success, otherwise 'undefined' or 'false' depending on the error cause.
* @deprecated Use {@link makeConnection} instead
*/
function connectControl(group: string, name: string, callback: CoCallback, disconnect?: boolean): ScriptConnection | boolean | undefined;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh that's the difference! I was wondering

engine.connectControl(new_group, bit.mapped_name, bit.mapped_callback);
engine.makeConnection(new_group, bit.mapped_name, bit.mapped_callback);
const value = engine.getValue(new_group, bit.mapped_name);
console.log(`Bit ${bit.group}.${bit.name} value ${value}`);
if (value) {
Expand All @@ -2100,9 +2100,9 @@ class HIDController {
continue;
}
const fieldControlGroup = this.resolveGroup(field.mapped_group);
engine.connectControl(
engine.makeConnection(
fieldControlGroup, field.mapped_name, field.mapped_callback, true);
engine.connectControl(new_group, field.mapped_name, field.mapped_callback);
engine.makeConnection(new_group, field.mapped_name, field.mapped_callback);
const value = engine.getValue(new_group, field.mapped_name);
if (value) {
this.setOutput(
Expand Down Expand Up @@ -2145,7 +2145,7 @@ class HIDController {
field.mapped_group = m_group;
field.mapped_name = m_name;
field.mapped_callback = callback;
engine.connectControl(controlgroup, m_name, callback);
engine.makeConnection(controlgroup, m_name, callback);
if (engine.getValue(controlgroup, m_name)) {
this.setOutput(m_group, m_name, this.LEDColors.on);
} else {
Expand All @@ -2169,7 +2169,7 @@ class HIDController {
return;
}
const controlgroup = this.resolveGroup(field.mapped_group);
engine.connectControl(controlgroup, field.mapped_name, callback, true);
engine.makeConnection(controlgroup, field.mapped_name, callback, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

field.mapped_group = undefined;
field.mapped_name = undefined;
field.mapped_callback = undefined;
Expand Down