Skip to content

Commit

Permalink
controllers: ensure required samplers are created
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Feb 9, 2024
1 parent 40be3fe commit 67a0e7d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions res/controllers/Denon-MC7000-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ MC7000.init = function() {
}
}
// Sampler Mode LEDs and Velocity Sampler Mode LEDs
if (engine.getValue("[App]", "num_samplers") < MC7000.SamplerQty) {
engine.setValue("[App]", "num_samplers", MC7000.SamplerQty);
}
for (let samplerIdx = 1; samplerIdx <= MC7000.SamplerQty; samplerIdx++) {
engine.makeConnection("[Sampler"+samplerIdx+"]", "track_loaded", MC7000.SamplerLED);
engine.makeConnection("[Sampler"+samplerIdx+"]", "play", MC7000.SamplerLED);
Expand Down
6 changes: 5 additions & 1 deletion res/controllers/Pioneer-DDJ-400-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ PioneerDDJ400.init = function() {
engine.softTakeover("[EffectRack1_EffectUnit1_Effect3]", "meta", true);
engine.softTakeover("[EffectRack1_EffectUnit1]", "mix", true);

for (let i = 1; i <= 16; ++i) {

if (engine.getValue("[App]", "num_samplers") < 16) {
engine.setValue("[App]", "num_samplers", 16);
}
for (let i = 1; i <= engine.getValue("[App]", "num_samplers"); ++i) {
engine.makeConnection("[Sampler" + i + "]", "play", PioneerDDJ400.samplerPlayOutputCallbackFunction);
}

Expand Down
5 changes: 4 additions & 1 deletion res/controllers/Pioneer-DDJ-FLX4-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ PioneerDDJFLX4.init = function() {
engine.softTakeover("[EffectRack1_EffectUnit1_Effect3]", "meta", true);
engine.softTakeover("[EffectRack1_EffectUnit1]", "mix", true);

for (var i = 1; i <= 16; ++i) {
if (engine.getValue("[App]", "num_samplers") < 16) {
engine.setValue("[App]", "num_samplers", 16);
}
for (var i = 1; i <= engine.getValue("[App]", "num_samplers"); ++i) {
engine.makeConnection("[Sampler" + i + "]", "play", PioneerDDJFLX4.samplerPlayOutputCallbackFunction);
}

Expand Down
10 changes: 7 additions & 3 deletions res/controllers/Traktor-Kontrol-S2-MK3-hid-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var TraktorS2MK3 = new function() {
this.vuMeterThresholds = {"vu-18": (1 / 6), "vu-12": (2 / 6), "vu-6": (3 / 6), "vu0": (4 / 6), "vu6": (5 / 6)};

// Sampler callbacks
this.samplerCount = 16;
this.samplerCallbacks = [];
this.samplerHotcuesRelation = {
"[Channel1]": {
Expand Down Expand Up @@ -220,7 +221,10 @@ TraktorS2MK3.registerInputPackets = function() {
engine.softTakeover("[Master]", "headMix", true);
engine.softTakeover("[Master]", "headGain", true);

for (let i = 1; i <= 16; ++i) {
if (engine.getValue("[App]", "num_samplers") < TraktorS2MK3.samplerCount) {
engine.setValue("[App]", "num_samplers", TraktorS2MK3.samplerCount);
}
for (let i = 1; i <= TraktorS2MK3.samplerCount; ++i) {
engine.softTakeover("[Sampler" + i + "]", "pregain", true);
}

Expand Down Expand Up @@ -605,7 +609,7 @@ TraktorS2MK3.parameterHandler = function(field) {
TraktorS2MK3.samplerPregainHandler = function(field) {
// Map sampler gain knob of all sampler together.
// Dirty hack, but the best we can do for now.
for (let i = 1; i <= 16; ++i) {
for (let i = 1; i <= TraktorS2MK3.samplerCount; ++i) {
engine.setParameter("[Sampler" + i + "]", field.name, field.value / 4095);
}
};
Expand Down Expand Up @@ -904,7 +908,7 @@ TraktorS2MK3.registerOutputPackets = function() {
this.clipRightConnection = engine.makeConnection("[Channel2]", "peak_indicator", this.peakOutputHandler.bind(this));

// Sampler callbacks
for (let i = 1; i <= 16; ++i) {
for (let i = 1; i <= TraktorS2MK3.samplerCount; ++i) {
this.samplerCallbacks.push(engine.makeConnection("[Sampler" + i + "]", "track_loaded", this.samplesOutputHandler.bind(this)));
this.samplerCallbacks.push(engine.makeConnection("[Sampler" + i + "]", "play", this.samplesOutputHandler.bind(this)));
}
Expand Down

0 comments on commit 67a0e7d

Please sign in to comment.