On TimerTick

I’ve seen a few examples in the forums of people using an “On TimerTick” callback, but for the life of me I can’t find the documentation for it.

I’m sure I’m looking in the wrong place, but I am at Introduction to GPScript for Gig Performer 4 and I don’t get any search results for “TimerTick”, “timertick”, “timer”, or “tick”. I also scanned through the entire Callbacks chapter and didn’t find it.

Thanks in advance.

Yeah, it seems to be missing in the docs.

This is the most basic use of the callback I’ve found in the forum. You just need to start the timer with SetTimersRunning(true)

After that, the callback will be called every 50ms or so (can’t recall the exact timing)

2 Likes

Thanks! And is it advisable to turn it off when it’s not needed?

Every cpu cycle counts, so yes. Furthermore I would keep the processing in the timer as little as needed. As far as I can see, gpscript runs on the gui-thread (@dhj will know for sure) and there is only one. But you should not have sleepless nights about it :grinning:

1 Like

Yes, but this is a good advice for any other callback. :wink:

1 Like

I use it in a script and do quite some functionality inside, like checking peak values of sixteen channels and change widget properties based on it. Of course for a computer this is still not much.

Also the time is not exactly fifty seconds, as far as I can remember the time varies a lot.

You could also try to use a ramp callback which is more precise, but I haven’t tried that myself. This callback is useful when you need exact period callbacks.

The timer may stop (and not restart) when you open the options dialog (for instance to check midi ports or audio).

‘Recompile all scripts’ can resolve that, but that is not always desirable

No, it doesn’t.

3 Likes

That’s nice. Takes some burden away. :slightly_smiling_face:

1 Like

Note however, that certain functions require running on the GUI thread which is why there can be some asynchronous behavior

1 Like