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 10, 2024
1 parent 40be3fe commit 2919461
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 12 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
3 changes: 3 additions & 0 deletions res/controllers/Hercules-DJControl-Inpulse-200-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ DJCi200.kScratchActionSeek = 2;
DJCi200.kScratchActionBend = 3;

DJCi200.init = function() {
if (engine.getValue("[App]", "num_samplers") < 8) {
engine.setValue("[App]", "num_samplers", 8);
}
// Scratch button state
DJCi200.scratchButtonState = true;
// Scratch Action
Expand Down
4 changes: 4 additions & 0 deletions res/controllers/Hercules-DJControl-Inpulse-300-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ DJCi300.vuMeterUpdateDeck = function(value, group, _control, _status) {
};

DJCi300.init = function() {
if (engine.getValue("[App]", "num_samplers") < 16) {
engine.setValue("[App]", "num_samplers", 16);
}

// Scratch button state
DJCi300.scratchButtonState = true;
// Scratch Action
Expand Down
4 changes: 4 additions & 0 deletions res/controllers/Hercules-DJControl-MIX-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class DJCMixClass {
}

init() {
if (engine.getValue("[App]", "num_samplers") < 8) {
engine.setValue("[App]", "num_samplers", 8);
}

this.scratchButtonState = true;
this.scratchAction = {
1: this.kScratchActionNone,
Expand Down
4 changes: 4 additions & 0 deletions res/controllers/Hercules_DJControl_Jogvision-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ var DJCJV = {
"init": function(id) {
print(id+": initializing...");

if (engine.getValue("[App]", "num_samplers") < 8) {
engine.setValue("[App]", "num_samplers", 8);
}

// Prepare some musical constants
if (CFG.fine.beatHelpSensitivity >= 1) {
print(id+": WARNING: variable 'CFG.fine.beatHelpSensitivity' is set to a value equal or bigger than 1 ("+CFG.fine.beatHelpSensitivity+"). Setting it exactly to 0.9");
Expand Down
4 changes: 4 additions & 0 deletions res/controllers/Numark_DJ2GO2_Touch_scripts.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
var DJ2GO2Touch = {};
DJ2GO2Touch.ControllerStatusSysex = [0xF0, 0x00, 0x01, 0x3F, 0x3C, 0x48, 0xF7];
DJ2GO2Touch.padsPerDeck = 4;
DJ2GO2Touch.samplerCount = 2 * DJ2GO2Touch.padsPerDeck;

DJ2GO2Touch.init = function() {
if (engine.getValue("[App]", "num_samplers") < DJ2GO2Touch.samplerCount) {
engine.setValue("[App]", "num_samplers", DJ2GO2Touch.samplerCount);
}
DJ2GO2Touch.leftDeck = new DJ2GO2Touch.Deck([1], 0);
DJ2GO2Touch.rightDeck = new DJ2GO2Touch.Deck([2], 1);
midi.sendSysexMsg(DJ2GO2Touch.ControllerStatusSysex, DJ2GO2Touch.ControllerStatusSysex.length);
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) {
const samplerCount = 16;
if (engine.getValue("[App]", "num_samplers") < samplerCount) {
engine.setValue("[App]", "num_samplers", samplerCount);
}
for (let i = 1; i <= samplerCount; ++i) {
engine.makeConnection("[Sampler" + i + "]", "play", PioneerDDJ400.samplerPlayOutputCallbackFunction);
}

Expand Down
6 changes: 5 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,11 @@ PioneerDDJFLX4.init = function() {
engine.softTakeover("[EffectRack1_EffectUnit1_Effect3]", "meta", true);
engine.softTakeover("[EffectRack1_EffectUnit1]", "mix", true);

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

Expand Down
18 changes: 11 additions & 7 deletions res/controllers/Reloop Terminal Mix 2-4.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,22 @@ TerminalMix.init = function (id,debug) {

// Enable four decks in v1.11.x
engine.setValue("[App]", "num_decks", 4);
const samplerCount = 8;
if (engine.getValue("[App]", "num_samplers") < samplerCount) {
engine.setValue("[App]", "num_samplers", samplerCount);
}

// Set soft-takeover for all Sampler volumes
for (var i=engine.getValue("[App]", "num_samplers"); i>=1; i--) {
for (let i=samplerCount; i>=1; i--) {
engine.softTakeover("[Sampler"+i+"]","pregain",true);
}
// Set soft-takeover for all applicable Deck controls
for (var i=engine.getValue("[App]", "num_decks"); i>=1; i--) {
engine.softTakeover("[Channel"+i+"]","volume",true);
engine.softTakeover("[Channel"+i+"]","filterHigh",true);
engine.softTakeover("[Channel"+i+"]","filterMid",true);
engine.softTakeover("[Channel"+i+"]","filterLow",true);
engine.softTakeover("[Channel"+i+"]","rate",true);
for (let j=engine.getValue("[App]", "num_decks"); j>=1; j--) {
engine.softTakeover("[Channel"+j+"]", "volume", true);
engine.softTakeover("[Channel"+j+"]", "filterHigh", true);
engine.softTakeover("[Channel"+j+"]", "filterMid", true);
engine.softTakeover("[Channel"+j+"]", "filterLow", true);
engine.softTakeover("[Channel"+j+"]", "rate", true);
}

engine.softTakeover("[Master]","crossfader",true);
Expand Down
3 changes: 3 additions & 0 deletions res/controllers/Reloop-Beatmix-2-4-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ ReloopBeatmix24.connectControls = function() {
ReloopBeatmix24.init = function(id, _debug) {
ReloopBeatmix24.id = id;
ReloopBeatmix24.TurnLEDsOff(); // Turn off all LEDs
if (engine.getValue("[App]", "num_samplers") < 8) {
engine.setValue("[App]", "num_samplers", 8);
}
ReloopBeatmix24.connectControls(false);

for (let i = 1; i <= 4; i++) {
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 2919461

Please sign in to comment.