Sending real time data and SOUND between Max/MSP and a web server

SonOfAGlitch's icon

Hello,
I' m working on a musical project that was supposed to be an installation but, due to Corona, I have to find a different solution to present the work.
Therefore, my idea was to send data and audio from Max to a website that people can easily access and enjoy the music from their cozy livingroom at home. The patch works according to the postion of the mouse on the screen, that I detect with the mousestate object; the data that I get from the X and Y axes are then mapped to several parameters such as volumes, frequency and so on.
Now, my questions are:
1. Is it possible to send real time data and AUDIO to a webserver?
2. Should my computer be always on with the patch running in order to transfer data and audio?
I installed the 'Miraweb' package and it seems to work quite well; this packeage was made to interact with the patch from external devices such as laptops, iPads and so on. I'm using it to connect to the Miraweb server and I can share the link with other people.
Thank you for your help,
Marco

Pedro Santos's icon

Yes, I would use OBS for that purpose. See the article on the front page of Cycling's website.

SonOfAGlitch's icon

Hey, thank you very much for your answer!
I checked out OBS but I found out that it is for recording and live streams, while I need something that allows remote interaction with the patch.

Pedro Santos's icon

I was referring only to the audio and video streaming part.
The control would have to be done with something like node.js.

Unfortunately, Miraweb is a solution for control only, it does not communicate audio or video...

SonOfAGlitch's icon

Mmm... I see. I checked out N4M as well but it is not exactly what I'm looking for. MiraWeb would have been perfect if only I could stream the audio :(
Thank you for your time!

Don Hill's icon

Hello, Marco! Like you I'm working on an interactive sound installation (and yes, my project has also been interrupted by the pandemic). Our approach to having arduino sensors triggering MAX content (such as discrete audio, in my case, assigned to 16 speakers or more) creating an interactivity between movement (in your case and mine) as well as other sensors (IFR, Ultrasonic and so forth) daisy-chained, well... I'm a newbie and likely over my head to getting arduino/MAX to talk to each other (in fact, I've been unable to -- I'm using a mac 0SX for MAX 8 -- maybe that's part of my problem?). It's not clear -- to me -- what I'm doing wrong (or right for that matter!). Any assistance -- art guy to art guy -- would be gratefully appreciated.

SonOfAGlitch's icon

Hey Don,
no way that the problem is that u're using OSX, I'm working on a Mac as well.
Here you can find the patch that I used to read data from Arduino into Max:

ArduinotoMaxv2.maxpat
Max Patch

I programmed it following the help document that you can find here and directly in the Max reference under the name of SERIAL COMMUNICATION.
Check it out, open the help patcher and follow the text, it is quite tricky at the beginning but if u read carefully u will understand everything; for sure it explains stuff better that I would eheh.
In a nutshell, what u need to do is:
1. READ DATA FROM ARDUINO THROUGH A SERIAL PORT:
> click on 'print' on top of the patch and the max console will display all the devices that are plugged into your computer via USB and stuff.
> Select the right serial port in the 'serial' object's argument (in my case: port d usbmodem1411) and u' ll be able to read the stream of data from Arduino. Note that data collected from each Arduino pin will be read all together, u' ll have to do some more stuff to separate them.

2. SEPARATE DATA IN ORDER TO USE THEM SINGULARLY
> I'm using the 'zlnth object' to separate the various informations and treat them separately.
Note that in the top-right part of the patch, I copied the data I was receiving into another message box, and I scroll through them with the integer number box to select only those that I want to use (I didn't want aX or | to appear for instance; the small message box at the bottom will display only the value corresponding to the number that u selected in the list).
> Check the number in the list that corresponds to the piece of data that u want to use and write that in the zlnth when u' re in the process of separating them. (EX. aX | 20 ... > aX = 1st in the list, | = 2nd in the list, 20 = 3rd in the list >>>> 20 is what I want to use, therefore I wrote zlnth 3 and the output gives me only the selected value.

I ended up abandoning the sensor system and I built a mini arduino controller with two knobs that allow the user to move on the x and y axis. I basically read the variable resistance in the circuit and I mapped those two values to everything else in the patch.

I hope that this is not too overwehlming and that it can help you, let me know if u need additional support and good luck with your project! :D

Don Hill's icon

You are amazingly helpful, Marco! Many thanks!! I'll follow your detailed instructions (and let you know how it landed on this end -- ha). I'd also be happy to let you know -- in more detail -- what I'm up to (if that's possible off-the-board here), if only to avoid what-not-to-do (ha).

SonOfAGlitch's icon

Yes of course feel free to share it here, I' m interested :D

Don Hill's icon

Thanks, Marco! I'm stumbling along -- not knowing exactly where -- but that's where I'm headed. Kindly forgive if it's a self-answering-question: Does Max receive, can it receive inputs over network sockets? I'm having a concept (ha)...