Using node.script in Midi Generator for Ableton 12

Justin Schwinghamer's icon

Howdy,

Is it possible to use node.script while building new Midi Generators for Ableton 12? Thus far I keep receiving this error in Ableton:

Received a Note dictionary asynchronously. Make sure that the dictionary is synchronous.

Is it possible to somehow run the output of the node.script object in a way that is synchronous?

Thanks!

JPS

atomicafro's icon

+1 on this. Specifically I would like to run gen-ai MIDI generators through the new MIDI Generator Max For Live type (via wrapping in Node python).

atomicafro's icon

A workaround I just figured out. More than a little clunky, but basically, the live.miditool.in object can send the intended notes dictionary to the node.script object in the first trigger of "Transform", then send the output dictionary to a "dict" object to be stored. You will see the asynchronous error message, but if you then have a trigger bang set from live.miditool.in to the bang input of the dict where the output of the script was stored, the output will be sent to the live.miditool.out synchronously as expected.

It's a workable temp solution if you really need to process something async with node that can't be implemented in vanilla js object (for instance AI models).


Obviously this is slightly less clunky with generators in that you can just "bang" trigger the generation, set up a visual indicator to know when the result is ready before clicking "Generate" to push the resulting dict out into the miditool out.

James Bradbury's icon

The node.script object runs node in a separate process, so when you pass Max messages to it can return "sometime" later. MIDI Tools on the other hand require everything to happen in a single transaction so to speak, to ensure that the MIDI transformation or generation happens before something else can. This avoids situations where for example you initiated a transformation, some computation happened asynchronously, and between getting something back you deleted the clip or moved the notes for example. This creates a resolution problem which is non-trivial to solve.

Unfortunately, the mixture of synchronous requirements of Live and async node puts the two things at ends with each other and we're thinking about solutions to this. We definitely thought "what if node could run synchronously" among other things. In any case, we aren't oblivious to the general feature request :)

atomicafro's icon

Thanks James for the clear confirmation of this behavior as expected. I'll proceed with my workaround which I think is fine for freeware usage in a generator. I'm planning on translating this huggingface space into a generator plugin which is going to require alot of documentation and clunkiness anyway from the user to set it up (given python involved). So one extra step to have the user click "run" button then wait 30 seconds before clicking "Generate" shouldn't be that big of a deal for my freeware proof-of-concept.