Comment 0 for bug 368992

Revision history for this message
Sean M. Pappalardo (pegasus-renegadetech) wrote :

We should probably implement a way for certain MIDI script functions to be called at regular intervals whether or not the controller was manipulated or a ControlObject::valueChanged signal was fired. This would be useful for spontaneous reactions (like flashing LEDs.) Scripts could set up these timers by calling engine.initTimer(<timer name>,<interval in ms>,<function name>) and destroy them with engine.removeTimer(<timer name>). Then engine.startTimer(<timer name>) and engine.stopTimer(<timer name>) would do what they imply.

A few script developers have asked about this functionality.

The current workaround involves connecting a function to [ChannelX] playposition (whose valueChanged signal fires every latency period) and setting/checking a global variable with the current time in milliseconds like so:

if (StantonSCS1m.displayFlash[deck]==-1) StantonSCS1m.displayFlash[deck] = new Date();
if (new Date() - StantonSCS1m.displayFlash[deck]>500) {
     StantonSCS1m.displayFlash[deck] = new Date();
     ...
}

It works, but feels wrong to me. What do you all think?