Skip to content

Commit

Permalink
controllers: fix engine.beginTimer() syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Dec 5, 2023
1 parent 40d23f3 commit 126ca8b
Show file tree
Hide file tree
Showing 33 changed files with 124 additions and 125 deletions.
4 changes: 2 additions & 2 deletions res/controllers/Akai-LPD8-RK-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ LPD8RK.reloopButton = function (channel, control, value, status, group) {
engine.stopTimer(LPD8RK.reloopTimer);
LPD8RK.loopbuttonDown=true;
LPD8RK.doreloop=true;
LPD8RK.reloopTimer = engine.beginTimer(500, "LPD8RK.disablereloop()", true);
LPD8RK.reloopTimer = engine.beginTimer(500, LPD8RK.disablereloop, true);
} else {//button was released
LPD8RK.loopbuttonDown=false;
if (LPD8RK.doreloop===true) {engine.setValue(group, "reloop_exit", 1);};
Expand Down Expand Up @@ -437,7 +437,7 @@ LPD8RK.hotcueBankDial = function (channel, control, value, status, group) {
LPD8RK.oldHotcueBank=LPD8RK.hotcueBank;
//set timer to clear old bank number after 500 msec, so bank indicator light will light up
engine.stopTimer(LPD8RK.oldbanktimer);
LPD8RK.oldbanktimer = engine.beginTimer(500, "LPD8RK.resetOldBank()", true);
LPD8RK.oldbanktimer = engine.beginTimer(500, LPD8RK.resetOldBank, true);

//set timer to restart LED updates in 500 msec
engine.stopTimer(LPD8RK.LEDPauseTimer);
Expand Down
2 changes: 1 addition & 1 deletion res/controllers/American-Audio-VMS2-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ VMS2.playlight = function(value, group, control) {
deck.Buttons.Pause.setLed(LedState.on);
// start a fancy blink timer
deck.switchPlaylightOff = true;
deck.playTimer = engine.beginTimer(500,"VMS2.playlightflash(\""+group+"\")");
deck.playTimer = engine.beginTimer(500, function() { VMS2.playlightflash(group); });
}
};

Expand Down
2 changes: 1 addition & 1 deletion res/controllers/Behringer-BCD3000-Advanced-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ BehringerBCD3000.jogWheel = function (channel, control, value, status, group) {
scratchValue = (value - 0x40);
engine.scratchEnable(deck + 1, 100, 33+1/3, 1.0/8, (1.0/8)/32);
engine.scratchTick(deck + 1, scratchValue);
BehringerBCD3000.scratchTimer[deck] = engine.beginTimer(20, "BehringerBCD3000.stopScratch(" + deck + ")", true);
BehringerBCD3000.scratchTimer[deck] = engine.beginTimer(20, function() { BehringerBCD3000.stopScratch(deck); }, true);

} else if (BehringerBCD3000.onKey) {
if (value > 0x40){
Expand Down
16 changes: 8 additions & 8 deletions res/controllers/DJ-Tech-Kontrol-One-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ KONTROL1.mod["s"]={state:"o",timer:false,doshift:true};
KONTROL1.init = function init(id, debug) { // called when the device is opened & set up
if (KONTROL1.debug>2){print("##function: "+KONTROL1.getFunctionName())};
KONTROL1.updateLEDs();
if(KONTROL1.disableFlash!==true)KONTROL1.ledTimer = engine.beginTimer(1000, "KONTROL1.doLEDs()");//set timer for LED indicator flashes
if(KONTROL1.disableFlash!==true)KONTROL1.ledTimer = engine.beginTimer(1000, KONTROL1.doLEDs);//set timer for LED indicator flashes
engine.connectControl("[Channel1]", "volume", "KONTROL1.testconnect");
};

Expand Down Expand Up @@ -145,7 +145,7 @@ KONTROL1.shiftPress = function shiftPress(){
var knobnum="s";
KONTROL1.modPress(knobnum);//turn mod on
engine.stopTimer(KONTROL1.mod[knobnum]["timer"]);//kill any previous timer
KONTROL1.mod[knobnum]["timer"]=engine.beginTimer(500, "KONTROL1.disableShiftSwitch('"+knobnum+"')", true);
KONTROL1.mod[knobnum]["timer"]=engine.beginTimer(500, function() { KONTROL1.disableShiftSwitch(knobnum); }, true);
}

KONTROL1.shiftRelease = function shiftRelease(){
Expand Down Expand Up @@ -198,7 +198,7 @@ KONTROL1.modRelease = function modRelease(knobnum){
KONTROL1.doLEDs = function doLEDs() {
if (KONTROL1.debug>2){print("##function: "+KONTROL1.getFunctionName())};
engine.stopTimer(KONTROL1.flashTimer);
KONTROL1.flashTimer=engine.beginTimer(30, "KONTROL1.bankIndicators()");
KONTROL1.flashTimer=engine.beginTimer(30, KONTROL1.bankIndicators);
return;
};

Expand Down Expand Up @@ -589,7 +589,7 @@ KONTROL1.cueClear = function cueClear(cue, control, deck){//clear hotcue - OR mo
if(engine.getValue(group, "hotcue_"+cue+"_enabled")!=true){//hotcue not set - prepare to move next hotcue pressed to this button
KONTROL1.cueMoveToNum=cue;
engine.stopTimer(KONTROL1.cueMoveIndicator);
KONTROL1.cueMoveIndicator=engine.beginTimer(100, "KONTROL1.cueMoveIndicatorLEDs("+control+")");//start timer for LED indicator flasher showing the button we're moving to
KONTROL1.cueMoveIndicator=engine.beginTimer(100, function() { KONTROL1.cueMoveIndicatorLEDs(control); });//start timer for LED indicator flasher showing the button we're moving to
return true;
}

Expand Down Expand Up @@ -817,7 +817,7 @@ KONTROL1.reloopButton = function reloopButton(value, deck) {//reloop/exit button
engine.stopTimer(KONTROL1.reloopTimer);
KONTROL1.loopbuttonDown=true;
KONTROL1.doreloop=true;
KONTROL1.reloopTimer = engine.beginTimer(500, "KONTROL1.disablereloop()", true);
KONTROL1.reloopTimer = engine.beginTimer(500, KONTROL1.disablereloop, true);
} else {//button was released
KONTROL1.loopbuttonDown=false;
if (KONTROL1.doreloop===true) {
Expand Down Expand Up @@ -881,7 +881,7 @@ KONTROL1.loopIn = function loopIn(value, deck) {
if (value>0){//button was pressed
KONTROL1.loopinbuttonDown=true;
KONTROL1.doloopin=true;
KONTROL1.loopinbuttonTimer = engine.beginTimer(500, "KONTROL1.disableloopin()", true);
KONTROL1.loopinbuttonTimer = engine.beginTimer(500, KONTROL1.disableloopin, true);
} else {//button was released
KONTROL1.loopinbuttonDown=false;
if (KONTROL1.doloopin===true) {engine.setValue(group, "loop_in", 1);engine.setValue(group, "loop_in", 0);};
Expand All @@ -900,7 +900,7 @@ KONTROL1.loopOut = function loopOut(value, deck) {
if (value>0){//button was pressed
KONTROL1.loopoutbuttonDown=true;
KONTROL1.doloopout=true;
KONTROL1.loopoutbuttonTimer = engine.beginTimer(500, "KONTROL1.disableloopout()", true);
KONTROL1.loopoutbuttonTimer = engine.beginTimer(500, KONTROL1.disableloopout, true);
} else {//button was released
KONTROL1.loopoutbuttonDown=false;
if (KONTROL1.doloopout===true) {engine.setValue(group, "loop_out", 1);};
Expand Down Expand Up @@ -1307,7 +1307,7 @@ KONTROL1.test = function test(channel, control, value, status, group) {
};


//KONTROL1.ledTimer = engine.beginTimer(250, "KONTROL1.testflash()");
//KONTROL1.ledTimer = engine.beginTimer(250, KONTROL1.testflash);
//midi.sendShortMsg(status, ctrl, state);
//engine.stopTimer(KONTROL1.ledTimer);

Expand Down
2 changes: 1 addition & 1 deletion res/controllers/DJ-Tech-i-Mix-Reload-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ DJTechiMixReload.init = function(ID)
DJTechiMixReload.setbutton["[Channel2]"] = false;

DJTechiMixReload.allleadson();
engine.beginTimer(4000,"DJTechiMixReload.allleadsoff()",true);
engine.beginTimer(4000, DJTechiMixReload.allleadsoff, true);
for(var deck = 1; deck <= 2; deck++){
engine.connectControl("[Channel" + deck + "]","play","DJTechiMixReload.deck" + deck + "play");
engine.connectControl("[Channel" + deck + "]","cue_default","DJTechiMixReload.deck" + deck + "cue");
Expand Down
20 changes: 10 additions & 10 deletions res/controllers/Denon-DN-SC2000.midi.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ DenonDNSC2000.newValue = function(currentVal,min,max,increment,ticksCount) {

DenonDNSC2000.flanger = function (midino, control, value, status, group) {
DenonDNSC2000.toggleBinaryValue(group,'flanger');
engine.beginTimer(100, 'DenonDNSC2000.handleFlangerLed("'+group+'")', true);
engine.beginTimer(100, function() { DenonDNSC2000.handleFlangerLed("'+group+'"); }, true);
}

DenonDNSC2000.changeDepth = function (midino, control, value, status, group) {
Expand Down Expand Up @@ -100,7 +100,7 @@ DenonDNSC2000.loadSelectedTrack = function (midino, control, value, status, grou
}
else {
engine.setValue(group, 'LoadSelectedTrack', 1);
engine.beginTimer(1500, 'DenonDNSC2000.handleLeds("'+group+'")', true);
engine.beginTimer(1500, function() { DenonDNSC2000.handleLeds("'+group+'"); }, true);
}
}

Expand Down Expand Up @@ -170,7 +170,7 @@ DenonDNSC2000.hotcue = function(cueIndex, group, value, shift) {
else
engine.setValue(group, 'hotcue_' + cueIndex + '_clear',1);
}
engine.beginTimer(100, 'DenonDNSC2000.handleLoopAndHotcuesLeds("'+group+'")', true);
engine.beginTimer(100, function() { DenonDNSC2000.handleLoopAndHotcuesLeds("'+group+'"); }, true);
}

DenonDNSC2000.loopIn = function(group, value, shift) {
Expand All @@ -179,7 +179,7 @@ DenonDNSC2000.loopIn = function(group, value, shift) {
}
else
engine.setValue(group, 'loop_in', 1);
engine.beginTimer(100, 'DenonDNSC2000.handleLoopAndHotcuesLeds("'+group+'")', true);
engine.beginTimer(100, function() { DenonDNSC2000.handleLoopAndHotcuesLeds("'+group+'"); }, true);
}

DenonDNSC2000.loopOut = function(group, value, shift) {
Expand All @@ -190,7 +190,7 @@ DenonDNSC2000.loopOut = function(group, value, shift) {
}
else
engine.setValue(group, 'loop_out', 1);
engine.beginTimer(100, 'DenonDNSC2000.handleLoopAndHotcuesLeds("'+group+'")', true);
engine.beginTimer(100, function() { DenonDNSC2000.handleLoopAndHotcuesLeds("'+group+'"); }, true);
}

DenonDNSC2000.reloop = function(group, value, shift) {
Expand Down Expand Up @@ -221,7 +221,7 @@ DenonDNSC2000.reloop = function(group, value, shift) {
engine.setValue(group, 'reloop_exit', 1);
}
}
engine.beginTimer(100, 'DenonDNSC2000.handleLoopAndHotcuesLeds("'+group+'")', true);
engine.beginTimer(100, function() { DenonDNSC2000.handleLoopAndHotcuesLeds("'+group+'"); }, true);
}

DenonDNSC2000.resizeLoop = function(midino, control, value, status, group) {
Expand Down Expand Up @@ -267,7 +267,7 @@ DenonDNSC2000.resizeLoop = function(midino, control, value, status, group) {
newLoopOutPosition = Math.max(0,newLoopOutPosition - newLoopOutPosition % 2);
engine.setValue(group, 'loop_end_position', newLoopOutPosition);
}
engine.beginTimer(100, 'DenonDNSC2000.handleLoopAndHotcuesLeds("'+group+'")', true);
engine.beginTimer(100, function() { DenonDNSC2000.handleLoopAndHotcuesLeds("'+group+'"); }, true);
}

DenonDNSC2000.moveLoopLeft = function(midino, control, value, status, group) {
Expand Down Expand Up @@ -311,7 +311,7 @@ DenonDNSC2000.play = function (midino, control, value, status, group) {
DenonDNSC2000.toggleBinaryValue(group,'play');
}
}
engine.beginTimer(100, 'DenonDNSC2000.handlePlayLed("'+group+'")', true);
engine.beginTimer(100, function() { DenonDNSC2000.handlePlayLed("'+group+'"); }, true);
}

DenonDNSC2000.cue = function (midino, control, value, status, group) {
Expand All @@ -330,14 +330,14 @@ DenonDNSC2000.cue = function (midino, control, value, status, group) {
DenonDNSC2000.keyLock = function (midino, control, value, status, group) {
if ((status & 0xF0) == 0x90) {
DenonDNSC2000.toggleBinaryValue(group,'keylock');
engine.beginTimer(100, 'DenonDNSC2000.handleKeyLockLed("'+group+'")', true);
engine.beginTimer(100, function() { DenonDNSC2000.handleKeyLockLed("'+group+'"); }, true);
}
}

DenonDNSC2000.beatSync = function (midino, control, value, status, group) {
if ((status & 0xF0) == 0x90) {
DenonDNSC2000.toggleBinaryValue(group,'beatsync');
engine.beginTimer(100, 'DenonDNSC2000.handleBeatSyncLed("'+group+'")', true);
engine.beginTimer(100, function() { DenonDNSC2000.handleBeatSyncLed("'+group+'"); }, true);
}
}

Expand Down
3 changes: 1 addition & 2 deletions res/controllers/Electrix-Tweaker-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,7 @@ ElectrixTweaker.arrowSide = function(channel, control, value, status, group) {
group = ElectrixTweaker.deck[group];
if (value) {
if (ElectrixTweaker.topShift) {
engine.setValue(group, "eject", 1);
engine.beginTimer(250, "engine.setValue(\""+group+"\", \"eject\", 0)", true);
script.triggerControl(group, "eject", 250);
} else {
engine.setValue(group, "LoadSelectedTrack", 1);
}
Expand Down
2 changes: 1 addition & 1 deletion res/controllers/Gemini-FirstMix-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ firstmix.preview = function (channel, control, value, status, group) {
engine.setValue("[Sampler4]", "volume", 0);
engine.setValue("[Sampler4]", "pfl", 1);
engine.setValue("[Sampler4]", "LoadSelectedTrack", 1);
engine.beginTimer(250,"engine.setValue(\"[Sampler4]\", \"play\", 1)",true); // I had to add a delay because this wouldn't work otherwise
engine.beginTimer(250, function() { engine.setValue("[Sampler4]", "play", 1); }, true); // I had to add a delay because this wouldn't work otherwise
firstmix.setLED(firstmix.leds[0]["preview"], 0x7f);
firstmix.previewButton = true;
}
Expand Down
2 changes: 1 addition & 1 deletion res/controllers/Hercules DJ Control MP3 e2-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ HerculesMP3e2.holdButton = function (group, value, first, second) {
if (value) {
engine.setValue(group, first, 1); // Set "On" the first function
holdTimerID = engine.beginTimer(2000, "HerculesMP3e2.holdTimer(\""+group+"\", \""+first+"\", \""+second+"\")", true);
holdTimerID = engine.beginTimer(2000, function() { HerculesMP3e2.holdTimer(group, first, second); }, true);
}
else {
if (holdButtonFlag) {
Expand Down
2 changes: 1 addition & 1 deletion res/controllers/Hercules-DJ-Console-Mk1-hid-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ HerculesMk1Hid.scroll_tracks = function(g, e, v) {
if (v > 0) {
engine.setValue("[Playlist]", e == "track_next_a" ? "SelectNextTrack" : "SelectPrevTrack", 1);
if (!HerculesMk1Hid.scroll_timer) {
HerculesMk1Hid.scroll_timer = engine.beginTimer(150, 'HerculesMk1Hid.scroll_tracks("[Playlist]","' + e + '",' + v + ')');
HerculesMk1Hid.scroll_timer = engine.beginTimer(150, function() { HerculesMk1Hid.scroll_tracks("[Playlist]","' + e + '",' + v + '); });
}
}
else {
Expand Down
2 changes: 1 addition & 1 deletion res/controllers/Hercules-DJ-Console-Mk2-hid-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ HerculesMk2Hid.scroll_tracks = function(g, e, v) {
if (v > 0) {
engine.setValue("[Playlist]", e == "track_next_a" ? "SelectNextTrack" : "SelectPrevTrack", 1);
if (!HerculesMk2Hid.scroll_timer) {
HerculesMk2Hid.scroll_timer = engine.beginTimer(150, 'HerculesMk2Hid.scroll_tracks("[Playlist]","' + e + '",' + v + ')');
HerculesMk2Hid.scroll_timer = engine.beginTimer(150, function() { HerculesMk2Hid.scroll_tracks("[Playlist]","' + e + '",' + v + '); });
}
}
else {
Expand Down
10 changes: 5 additions & 5 deletions res/controllers/Hercules-DJ-Console-RMX-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ HerculesRMX.Button.prototype.setLed = function(ledState, blink) {
midi.sendShortMsg(0xB0,this.controlId,LedState.off);
}
if(blink) {
engine.beginTimer(20, "midi.sendShortMsg(0xB0," + (this.controlId + 0x30) + ", " + LedState.on + ")", true);
engine.beginTimer(20, function() { midi.sendShortMsg(0xB0,(this.controlId + 0x30), LedState.on); }, true);
} else {
engine.beginTimer(20, "midi.sendShortMsg(0xB0," + (this.controlId + 0x30) + ", " + LedState.off + ")", true);
engine.beginTimer(20, function() { midi.sendShortMsg(0xB0,(this.controlId + 0x30), LedState.off); }, true);
}
};

Expand Down Expand Up @@ -158,7 +158,7 @@ HerculesRMX.Deck.prototype.jogMove = function(jogValue) {
engine.stopTimer(this.scratchTimer);
}
engine.scratchTick(this.deckNumber, jogValue);
this.scratchTimer = engine.beginTimer(20, "HerculesRMX.GetDeck('" + this.group + "').stopScratching()", true);
this.scratchTimer = engine.beginTimer(20, function() { HerculesRMX.GetDeck(this.group).stopScratching(); }, true);
} else {
engine.setValue(this.group,"jog", jogValue);
}
Expand Down Expand Up @@ -875,11 +875,11 @@ HerculesRMX.rateChange = function (value, group) {
HerculesRMX.Decks.Left.Buttons.Sync.setLed(LedState.off);
}
if (HerculesRMX.Decks.Right.Buttons.Sync.state != ButtonState.pressed) {
engine.beginTimer(25, "HerculesRMX.Decks.Right.Buttons.Sync.setLed(LedState.off)", true);
engine.beginTimer(25, function() { HerculesRMX.Decks.Right.Buttons.Sync.setLed(LedState.off); }, true);
}
if (value != 0.0) {
var deck = HerculesRMX.GetDeck(group);
engine.beginTimer(30, "HerculesRMX.GetDeck('" + group + "').Buttons.PitchReset.setLed(LedState.off)", true);
engine.beginTimer(30, function() { HerculesRMX.GetDeck(group).Buttons.PitchReset.setLed(LedState.off); }, true);
}
};

Expand Down
12 changes: 6 additions & 6 deletions res/controllers/Hercules-DJ-Control-MP3-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ HerculesMp3.init = function (id) { // called when the device is opened & set up
// a timer and a buffer will rectify this.
// Setting it to 20ms instead of 11ms as this first is the lowest value accepted for a timer.

engine.beginTimer(20, "HerculesMp3.ledhelper()");
engine.beginTimer(20, HerculesMp3.ledhelper);


// Be the leds!

HerculesMp3.leds(true);
engine.beginTimer(500, "HerculesMp3.leds(false)",true);
engine.beginTimer(500, function() { HerculesMp3.leds(false); },true);

// Connect leds here and not in xml. This is to avoid an annoying bug (maybe) in controller drivers.

Expand Down Expand Up @@ -193,7 +193,7 @@ HerculesMp3.leds = function (onoff) {
HerculesMp3.ledblink = function (control,onoff){
if(onoff) {
actual_status = HerculesMp3.controls.outputs[control].status;
blinktimer[control] = engine.beginTimer(300,"HerculesMp3.ledblinkhelper("+control+")");
blinktimer[control] = engine.beginTimer(300, function() { HerculesMp3.ledblinkhelper(control); });
HerculesMp3.controls.outputs[control].isblinking = true;
}
else
Expand Down Expand Up @@ -287,7 +287,7 @@ HerculesMp3.loophold = function (deck) {
HerculesMp3.loop = function (deck, control, value) {
if(value) {
is_hold_loop[deck] = false;
timerloopID[deck] = engine.beginTimer(700,"HerculesMp3.loophold("+deck+")",true);
timerloopID[deck] = engine.beginTimer(700, function() { HerculesMp3.loophold(deck); }, true);
}
else {
engine.stopTimer(timerloopID[deck]);
Expand Down Expand Up @@ -329,7 +329,7 @@ HerculesMp3.hotcue = function (deck, control, value) {
hotcue_string = HerculesMp3.fxbutton(HerculesMp3.controls.inputs[control].name);
if(value){
is_hold_hotcue[control] = false;
timerhotcueID[control] = engine.beginTimer(500,"HerculesMp3.hchold("+deck+","+control+","+"\""+hotcue_string+"\")",true);
timerhotcueID[control] = engine.beginTimer(500, function() { HerculesMp3.hchold(deck, control, hotcue_string); }, true);
}
else {
engine.stopTimer(timerhotcueID[control]);
Expand Down Expand Up @@ -556,7 +556,7 @@ HerculesMp3.jog_wheel = function (group, control, value, status) {
if(engine.getValue(Deck[n],"scratch2_enable"))
{
//when not moved for 200 msecs, probably we are not touching the wheel anymore
scratch_timer[n] = engine.beginTimer(200,"HerculesMp3.jog_wheelhelper("+n+")",true);
scratch_timer[n] = engine.beginTimer(200, function() { HerculesMp3.jog_wheelhelper(n); }, true);
scratch_timer_on[n] = true;
}
}
Expand Down
Loading

0 comments on commit 126ca8b

Please sign in to comment.