Receiving OSC from a monome/serialosc

Hi

I am trying to use Sonic Pi with an old monome 40h (with serialosc)
I can get SP to send OSC to the monome and light LEDs etc., however I cant receive OSc from the monome. Nothing shows up in the cues window.

Does anyone know how to tell serialosc the correct port for SP?

thanks

Just a thought. Have you enabled receive remote OSC messages on Sonic Pi IO prefs panel?

presumably you have read this site.

https://monome.org/docs/osc/

thanks robin,

yes I’ve tried switching on the receive remote OSC prefs but with no joy.

Also I’ve tried sending messages direct to serialosc from SPi but i get nothing back. Somehow I need to get seriaosc to set the right destination port.

Hi @whirecordings, to get the monome (via serialosc) to send messages to Sonic Pi, you must configure it to send to port 4559.

This can be done in one of two ways.

Edit config file

Firstly, you can edit the config file for your monome directly. This is stored in ~/Library/Preferences/org.monome.serialosc on macOS. Within that directory you should find a .conf file for your monome (or multiple files if you have multiple monomes). My file looks like this:

server {
  port = 15503
}
application {
  osc_prefix = "/monome/128"
  host = "127.0.0.1"
  port = 4559
}
device {
  rotation = 0
}

Note, that the application port has been set to 4559. This is the important part. Then you may need to reset serialosc to reflect the changes. By far the easiest way to do this is to restart your machine.

Talk via OSC API

The other approach is to dynamically talk to serialosc via the OSC API. This is documented here: https://monome.org/docs/osc/. This can be achieved using use_osc and osc in Sonic Pi. See their respective docs for further information.

I hope that this helps.

Finally, please do consider supporting further development (and support) for Sonic Pi on Patreon: https://patreon.com/samaaron

2 Likes

Hi Sam,

Many thanks, thats exactly what i was looking for! Works now.
I changed the port number in the config file.

thanks again!

1 Like

Hi @samaaron,

as I did not manage to use the standard serialoscd with my Adafruit Unztrument grid (I did spent quite some time with it, it seems to involve flashing the FTDI chip, which I did not succeed in), I am currently using node-serialoscd by Szymon Kaliski; I havn’t found out all the details, but basically it works. Unfortunately according to Szymon it does not yet allow to configure the destination port for the grid via a configuration file.

So I am hoping to go the other way - talking via the OSC API - but after looking at the specification I don’t see how to go on. I have confirmation from Szymon that basically all should work like described at Redirecting….

While experimenting I can see that node has many ports in use. I also can reliably sent information to the grid as well as get button presses coming from the grid, which I can see in debug mode at the command line, so I have bidirectional communication. What I can’t see is, to which port the grid is sending its information to. (And - as already mentioned - I don’t have the option to set the destination port for the grid to 4559 via some config file.)

Do you see a chance to give some more information so that I can go on?

@Martin My interpretation after reviewing the monome OSC docs and the node code for a few minutes is that if you send it /serialosc/list then it will return a /serialosc/device message, part of which contains the port it will use for communication. Wild guess, hope that helps.

Hi @perpetual_monday,

yes, I think that’s what I found out today. This is how I can communicate with the grid device (and it works :slight_smile: ).

But: I need to know if there’s any chance to receive messages with Sonic Pi. Right now I do see messages comming from the device, but they don’t reach Sonic Pi because they do not have the destination port 4559 (but some other, which I don’t know).

I understand the following:

  • the oscserver, which (node-)serialoscd provides, listens on port 12002
  • the port the grid device gets can be queried with “/serialosc/list”
  • the port where the application (in this case Sonic Pi) listens is fixed: 4559

So as far as I see I 1. have to find out, to which port my grid resp. node-serialoscd is sending, and 2. if I cando something to direct these messages to port 4559. Not sure if this analysis is correct but it is what I assume so far…

Or did I missunderstood any of what you said?

You’re right, I was thinking that the Sonic Pi receive port could still be overridden at runtime somehow.

Wild guess #2: If you change deviceOscPort to 4559 on this line: https://github.com/szymonkaliski/node-serialoscd/blob/master/index.js#L120 then it should send to the SPi OSC port.

Thanks!

I’ll try that tomorrow… and let you know how wild your guess was :wink:

1 Like

Hi @perpetual_monday,

tried it but unfortunately this does not work. Szymon wrote, “there’s no way to set the port currently, and the way the serialosc works is kinda funky tbh, it opens few different connections, so I dunno”. This does not look like an easy thing.

What I am slightly confused about: I do not even know how to find out the port, the Unztrument is sending to. Using netstat -lntup | grep node I can see quite a few ports being used by node, so I assume it must be one of these… I am mentioning that because I thought it might be possible to forward the port my device is sending to to 4559 (?).

I’m thinking there may be a good amount of general shared misunderstanding between all of us :slight_smile:

Did you already try using /sys/port 4559 to update the destination port?

More generally (to Szymon’s response), the code that is using a random UDP port could instead use a specified port. It may be that the author doesn’t want to change their code, and that’s OK, but this is a solvable problem IMO.

yes, very likely…

And yes, tried the /sys/port command with no effect.

To be fair, the author was of great help to me and said also, he might look into it but this could take a while.

Dang, sorry for leading you to dead ends. I’ll continue chipping away at it, I’ve actually installed node-serialoscd now and though I don’t have any of the hardware I should be able to fake the important bits opening up sockets in a Python script/console. I also read through this thread again - I understand better now what differences you’re encountering with your hardware (which is not a monome).

You said you’re able to see bi-directional comms in the debug output, so I’ll look for a way to override the handler for messages from the device and direct them to localhost:4559.

Wow, that is very kind of you!

Actually I’m at my wits’ end (looked that one up, hope it’s real English) for now. Did spent quite some time to get the Unztrument running since a few months and am kind of frustrated; so I can really use some help.

Meanwhile I am going to optimise my mlq application … :wink:

Hi @perpetual_monday,

gave it a second try (I don’t know what went wrong the first time). That’s how it works:

# Report port where Unztrument is listening:
osc_send "127.0.0.1", 12002, "/serialosc/list", "localhost", 12002

# This is the output of node-serialoscd:
# >>> master
# {
#   "path": "/serialosc/device",
#   "typetag": "ssi",
#   "params": [
#     "monome",
#     "monome",
#     58946 <---- This is the destination port of the Unztrument
#   ]
# }

Then I can set the destination port for Sonic Pi:

# Set (Sonic Pi) destination port for Unztrument to use
osc_send "127.0.0.1", 58946, "/sys/port", 4559

This is somehow complicated and I am still looking to sort of automate this process, but: It works!!! (Finally I can use the Unztrument for monome programming :wink:

1 Like