node.js and getnamed
Hi,
I've just started working with node.js in Max 8 and I was wondering if it's possible to use the
this.patcher.getnamed
syntax to address named max objects in the patcher?
I've tried it and it doesn't seem to work but maybe there's something I'm missing?
Thanks in advance,
Dennis.
Just realising that the node.js object doesn't communicate with max in the same way that the js object does, so I guess I'm barking up the wrong tree here?
It would be good to have it confirmed either way.
Thanks,
Dennis.
Hey Dennis,
yes the [js] and the [node.script] are different in this regard and the only API available in a node.script JS is what gets exposed through the max-api module. This is due to [node.script] actually being a way to spawn, manage and communicate with a separate Node JS based process from within Max.
Hope that helps.
Florian
Thanks for the clarification Florian.
Just for future reference, is there a list of " what gets exposed through the max-api module" anywhere? Apologies if the answer to this is obvious. I'm new to node.js.
Thanks,
Dennis
Sure! You can check the examples that ship with Max 8 (node.script helpfile, n4m.launcher patch) for some code on how to use the API. The reference material on the "max-api" can be found here https://docs.cycling74.com/nodeformax/api/APICommunicator.html We are currently in the process of cleaning up and improving the latter to make it more readable.
Apart from that we also have a git repository with some further examples: https://github.com/Cycling74/n4m-examples
Florian
I think I would connect a [js handle-node-outlet.js]
to the output of the node-object, that can handle all node outlet output. From there you can do this.patcher.getnamed('foo');
Any plans to integrate the old [js] object with [node.script] in the future?
Would be really great if you could access the patch from [node.script] the same way you could from [js]. I was really excited about [node.script] in Max 8, but was a little disappointed when I found out it wasn't the case that I could access the patch in this way
Hi DO MI,
Have you tried your approach to connect the [js] to the [node.script] out? Does it work for you? Could you provide an example, please?
Thank you
@VVV I don't have any details what the future of these objects looks like.
Currently they serve with different purposes in mind. [node.script] lives in its own process and is entirely asynchronous to whatever is happening within Max while the [js] object is embedded in Max and has access to a completely different API.
Florian