Accessing ~buffer object from node.script
Hi guys,
I want to access an audio buffer from Node for Max. It seemed the easiest to me to just create a new named Buffer object, as is suggested in the Javascript tab in ~buffer help. However, the documentation points out that the Max js API and the Node for Max environments are different meaning I cannot use the Buffer object in this way. So this little bump got me more interested in the whole subject of the two different Javascript environment in Max.
After a bit more digging, this thread https://cycling74.com/forums/any-plans-to-update-support-for-recent-versions-of-js discusses the presumptively static situation of the Javascript version in the js object, however I was wondering what is the development status surrounding Node for Max? Specifically:
1. Are there plans for integrating Max JS API functionality into Node for Max?
2. And for now, anyone got a suggestion on alternative ways of getting buffer data into Node for Max?
Thanks.
For anyone that might be interested, I figured this out by creating a custom jspatcher that directly accesses the Buffer using the built-in API and then outputs and forwards a list of values to the node.script object.
The issue your facing is that Node for Max and the JS object work in a fundamentally different way: Node is an outside-of-max process that max communicates with over the local network and the js is a max external implemented in C, with the js engine executing in the Max process. These each have pros and cons. The node process can do things without you having to worry about blocking max (open big files, make network requests, etc), but also can not directly access max data structures. What you're doing is one version of what you'll have to do: access buffer in max and communicate it with Node somehow.
Yea I figured that out by now. It turned out to be rather hacky to do spectral processing in Node for Max, nonetheless the solution I wrote above seems to work best (compared to writing files to a temporary directory and reading them back in).
In case you are thinking of trying it, buffer access in the C SDK is quite easy. I'm also adding it to the next release of Scheme-for-Max, which runs in process like the js object.