How can I send a slider value from Max to a local website (in real-time)?
Hi everyone,
I'm trying to send a changing slider value from Max (Max/MSP) to a local website (e.g., localhost:8080
) in real-time, so that I can use it in JavaScript—for example, to drive visuals or update an interface.
What I have so far:
A slider in Max whose value changes continuously.
A basic website running locally where I can use JavaScript.
Some experience with
node.script
and WebSockets inside Max, but I’m also open to any simpler or more reliable alternatives (e.g., HTTP requests, OSC to browser, etc.).
My questions:
What’s the simplest and most stable way to get a slider value from Max to a local website in real-time?
Do I need to use
node.script
for this, or is there a better approach?How should I receive and use the data on the web side (JavaScript)?
Bonus points for a minimal working example patch or setup 😄
Thanks in advance!
Two possible approaches:
If you're fine running your website inside of your Max patch, the simplest solution is by far [jweb] to display your website, to which you can send data directly via patching. See here to get how to receive messages from the Max patch in your website's js code.
If you want to be able to run your website on a dedicated browser (or from another device), then you'll need to run a web server, possibly with [node.script], send your slider data to this server via messages to [node.script], and handle yourself the server code to make it send the received slider data to your website, for example through Server-Sent Events (SSE) or websocket.
If you choose second option (website running outside of Max) then yes, or other tool that allow you to run a web server (standalone nodejs, python, etc.), depending on what you're the most comfortable with.
Briefly answered in 1.