Sending messages from juce to maxmsp

First of all, I'm new to juce, and not extremely experienced with programming either. My goal is to use a few different sliders to simply send numbers to Max/msp for the audio processing. I know you can create a UI with Max, but I'm using juce instead. I've looked into DatagramSocket, InterprocessConnection, and piping, but I have no idea which is what I want or how any of them actually work. I don't know how servers or ports or anything work, and haven't been able to find a good tutorial online either. I was wondering if someone might be able to help me out?

I think I'd know how to handle it on the Max side, there is a udpReceive function that takes a port as an argument. I just have no idea how to get the message there. The message just needs to be a number. If there's an easier method that I just don't know about, I'm open to that too.

Here's what I'm doing now:

 

In header:

DatagramSocket *port2;

char buffer[3];

 

In code:

port2 = new DatagramSocket(7402, true);

port2->connect("127.0.0.1", 7402);

int num = 120;

itoa(num, buffer, 10);

const void *vbuffer = (void*)buffer;

port2->write(vbuffer, 3);

 

In Max I have a udpReceive object listening on port 7402. As you can probably tell I really don't know what I'm doing, thanks for the help!

 

Before attempting to connect to Max, I reccommend that you write both the sender and receiver code using JUCE, so that you control the entire communications chain, during the time you are trying to figure out how to use the DatagramSocket class. Once you have success with this, you will have more confidence in your basic code while working out any issues in connecting with Max.

 

 

Thanks, I will definitely do that. I am still having a hard time finding any info on actually implementing something like this. I have never done anything web-based and don't exactly understand how I would go about making a server if that's what I need. 

Also, the DatagramSocket::read function seems to only accept 3 arguments, where the documentation says it needs 5. In my code it isn't asking for the host name or port number for some reason, it says I have too many arguments if I include those.

I did some experiments there ( https://github.com/nicolasdanet/Jojo ).
Have a look on “jojoSlave / jojoInterprocess / jojoPipe1 / jojoPipe2 / jojoIPC1 / jojoIPC2…” if that helps. Nothing about socket actually.

Edit: Oops that’s Mac only. Sorry i should have noticed that it is a Window question :wink:

Sorry for the confusion on DatagramSocket::read. The interface was just updated yesterday and you were probably still using the old version. See the following commit. Read will now take 5 arguments.

https://github.com/julianstorer/JUCE/commit/45a0cf35abd9f824bc777920b41fda717b37dac4

Quickly added a basic example about sending udp from an App to Max/MSP ( https://github.com/nicolasdanet/Jojo/blob/master/Projects/JojoSocket/Source/Main.cpp ).

Note that the [sadam.udpReceiver] object from Ádám Siska ( http://www.sadam.hu/software ) is needed if you want to go that way (to avoid all the OSC machinery involved in the native [udpreceive] object).

Thanks, I will try that!

You might want to consider using danlin's modules to help with this: https://github.com/danlin/danlin_modules/tree/master/modules , which package up oscpack and juce-ify it. If you use OSC over UDP, it will be very easy to patch up in Max.

I'm using this in the latest version of ScopeSync and it was really easy to get working.

Do you mean that you successfully sent data to the [udpreceive] object in Max/MSP (seems that ScopeSyncOSCServer do the job) or it might be? Thanks anyway.

Yes, I successfully used it with both udpsend and udpreceive objects. Another guy working on the project also hooked it up to Reaktor successfully.

The main solution is actually for communicating between multiple ScopeSync instances at this stage, which works very well.

P.S. I only really used the danlin modules (apart from the packaging of oscpack) as a start point for the ScopeSyncOSCServer class, as it was less complete when I picked it up. He's updated it since and it looks to be closer to what I would have needed.

Good to know. After searching on cycling74 website the format of udp objects in Max/MSP was still not obvious for me :wink: