is there a workaround to avoid liveAPI constructors inside callbacks?

deuns0615's icon

Hi everyone,

i'd like to code in a JS object the minimum required to get some grid information in max for live (tracks, scenes, clip slots, clips).

i can't find the good method to avoid the "method-pushcontextframepopcontextframe" warning...

i understand that the bottom line is i shouldn't put a liveAPI constructor inside a callback, but then how can i automatically get the ids of the new clip_slots created after a track list change? (or scenes, whatever creates new clip_slots).

For example, if there's an observer on the "tracks" property of "live_set", i will get a return from that observer in the form of an updated tracks ids list whenever there's a newly created track, but then how do i monitor it's clip_slots informations?

what's your technique to automatically get information on newly created elements whithout embedding liveAPI constructors in callbacks?

thanks for your help!

hollyhook's icon

in the callback you can outlet all data you need, and connect in max the outlet to the inlet, potentially deferred or defer-lowed. This way you get into the proper js context, and you can use LiveAPI constructor etc.

deuns0615's icon

aha!

i woud not have expected it to be that twisted...

i suppose getting out and back in is the only solution, as there's no such thing as a "defer" funcion in javascript?

thanks

hollyhook's icon

no, javascript is single threaded. There is only a Task object which you could trigger, but then you end up with code in the context of the task, which is also limited.

deuns0615's icon

ok well now i have something to try! Thank you very much!