Schedule [js] Task in absolute ticks?

Apr 10, 2013 at 5:57am

Schedule [js] Task in absolute ticks?

I see that JS Tasks can be scheduled in millisecond delays, but can they be scheduled to fire when the transport reaches an absolute time in ticks?

Flipping through the SDK, I figure I can probably mash up the delay2 and simplejs examples to do something like what I’d like—although I’m not completely certain how to call a JS callback from C.

This is for a Max For Live project. If there’s any other way to have a JS callback fire when the Live transport reaches a specific time, that would work, too.

#67635
Apr 10, 2013 at 6:31am

Quick follow-up question: If there’s a way to schedule events to fire at an absolute tick value in Java with [mxj], that would also be of interest to me.

For what it’s worth, I already have a system for this purpose working using [timepoint], but I’d love to push this scheduling functionality into procedural code—either Java or JavaScript—if possible.

#243383
Apr 10, 2013 at 8:19am

You’ll be lucky to get millisecond timing accuracy in Javascript because it only runs in the UI thread; Java is a better bet.

#243384
Apr 15, 2013 at 11:49pm

Thanks, Nick. I’m actually getting really good results from [js] right now—turnaround times in microseconds. Will persist and post here if I see any major performance problems.

FWIW, I also tried making a system to schedule arbitrary messages at specific times in the future with patcher scripting, by creating instances of a patcher that used [timepoint] and [pv], then removed itself with [thispatcher]. This system is way too slow for my purposes, though—several milliseconds in either [js] or [mxj jruby], mainly caused by presence of [thispatcher]. I’ll revert to my original system, which involves a single event loop feeding upcoming events through a single [timepoint] + [pv] combo.

#243385

You must be logged in to reply to this topic.