Help with extternal osc device

I am trying to use the osc Controller App to create an interface. I managed to get the osc messages to my computer (I’m running planetCCRMA) but Supercollider OscFunc is not getting them. I think I’m setting the right parameters:
n = NetAddr.new(“192.168.0.18”, 7532); //same as the setting in the App on my phone
o = OSCFunc({ arg msg, time, addr, recvPort; [msg, time, addr, recvPort].postln; }, ‘/oscControl’,n);
Any suggestions where to look for the problem?
thanks
Oded

n = NetAddr.new(“192.168.0.18”, 7532)

This just creates a network address. You can use it to send OSC messages to that address.

If you want to receive OSC messages, you have to open a UPD port: thisProcess.openUDPPort(7532);

1 Like

The thing about OSC communication is that there are always two settings:

  • The FROM address and port
  • The TO address and port

It seems pretty much inevitable that every user, the first time they try to use OSC, gets these mixed up.

BTW please enclose code blocks within triple-backtick delimiters:

```
n = NetAddr.new("192.168.0.18", 7532);
```

If you look carefully, you’ll see that the quote marks have been broken in your code block – copy the code from your post and try to run it, and you get a syntax error. Code formatting prevents this.

The n in OSCFunc filters sending addresses = FROM.

In TouchOSC app, for instance, the configuration panel has:

  • Host = IP address to send TO
  • Port (outgoing) = port to send TO
  • Port (incoming) = port upon which TouchOSC will receive messages
  • Local IP address (not configurable – the FROM address)

So if your NetAddr references the TouchOSC “host” and “port (outgoing),” it won’t work because the NetAddr should be FROM and you’ve specified TO.

The NetAddr IP address should be the FROM address = the phone’s local address.

What about the NetAddr port? This is a bit unpleasant side of OSC – many apps do not let you configure the port from which the app will send. So you might have no control over the FROM port. For example, my TouchOSC is using the default incoming port 9000, but in SC, I get (see OSCFunc.trace):

OSC Message Received:
	time: 390.010697253
	address: a NetAddr(192.168.2.2, 44581)
	recvPort: 57120
	msg: [ /ping ]

FROM port 44581. I didn’t configure that anywhere, and there’s no way to predict between sessions what it will be.

If I wrote NetAddr("192.168.2.2", 9000) based on the TouchOSC app settings, I wouldn’t receive any messages because the FROM port doesn’t match.

So, in general, it’s best to write NetAddr("ip.address.from.xxx") without a port, or omit the NetAddr altogether.

hjh

Many thanks for the explanation. After I open the udp port I can see the osc messages coming in when I use OSCFunc.trace. But when I try to get an OSCFunc to respond to the incoming message I get nothing. I tried different versions of

o = OSCFunc({ arg msg, time, addr, recvPort; [msg, time, addr, recvPort].postln; }, '/oscControl');

(with the netaddress i get from the trace and without it. With just the ip and with ip+port. with different paths). But it prints nothing. So clearly I’m missing something else as well.
Many thanks
Oded

Can you post the trace? It’s good that the trace is posting the messages… but it’s hard to see the relationship between the incoming messages and your OSCFunc when we can’t see the trace.

Might be useful to share the OSC app settings as well…? Bc this is a bit weird. If you get a trace then OSCFunc should work too.

hjh

here is one trace message
OSC Message Received:
time: 72.966984974
address: a NetAddr(192.168.0.10, 46544)
recvPort: 7532
msg: [ /oscControl/slider2, 0.18419052660465 ]

I am using osc Control App (on android) and setting
ip address 192.168.0.18
port 7532
osc path /oscControl

Is it possible that the format of the path symbol is somehow incompatible? that though the text is the same, somehow the way the App and SC view it is different?
thanks

The message path is /oscControl/slider2 – you have to spell it all out, as it’s all matched at once.

SC doesn’t parse the path into substrings.

hjh

ah, yes, thanks that works