njh / node-red-contrib-osc

Open Sound Control (OSC) support for Node-RED
http://flows.nodered.org/node/node-red-contrib-osc
Apache License 2.0
21 stars 14 forks source link

Integer data type #17

Open smadds opened 6 years ago

smadds commented 6 years ago

Like @nfavrod I am also trying to control a Behringer X32 with this node.

Some commands need the response defined as an integer - e.g.: /ch/01/mix/on ,i 0

It seems to fail with the ,f number type. Is there any way to force the ,i prefix when outputting data from the OSC node?

smadds commented 6 years ago

I think I've found a partial answer to this, by sending a json payload to OSC in this format: {"type":"i","value":0}

image

Yay - this works!, but I have yet to figure out how to send multiple values without OSC thinking it's a return message from the device. e.g. these both fail: {"type":"si","value":"scene 0"} {"type":"si","value":["scene", 0]}

Any ideas??

njh commented 6 years ago

I am sorry it has taken so many months to respond. I don't seem to have received an email when this issue was created.

That Behringer X32 mixer looks like fun! Did you manage to get it to work?

JavaScript / JSON does not make a distinction between Floats and Integers and it looks like the osc.js library defaults to using floats. Some client implementations (eg. liblo) will auto cast a float to an integer if it is expecting an integer.

The syntax for sending both a string and an integer is:

[
  {
    "type": "s",
    "value": "scene"
  },
  {
    "type": "i",
    "value": 0
  }
]

This is documentation on this formatting in the osc.js README: https://github.com/colinbdclark/osc.js

I just did some tests using Node-RED and oscdump and got the output:

ded9633a.358d25ed /foo/bar si "scene" 0
terwarf commented 3 years ago

Hello and thanks for the nice plugin. I can confirm the x32 accepts this format. Tested with [ { "type": "s", "value": "/ch/01/mix/fader" }, { "type": "i", "value": 30 } ] with topic /subscribe subscribes to value on first fader for the next 10 seconds (the integer limits the amount of messages the mixer sends back).

alexszilagyi commented 1 year ago

@terwarf : Thanks for the input!

Can you share maybe the node-red flow? I would be highly interested to see how you've set it up. I am trying to setup the following OSC command:

/load ,si scene 00

But I was unable to do that using the following flow:

[
    {
        "id": "da099c9102c4e8ab",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "08c102dd8ef2d7a8",
        "type": "inject",
        "z": "da099c9102c4e8ab",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 160,
        "wires": [
            [
                "e86b9f9871d5e9f6"
            ]
        ]
    },
    {
        "id": "220366b7f70d5845",
        "type": "osc",
        "z": "da099c9102c4e8ab",
        "name": "",
        "path": "",
        "metadata": true,
        "x": 490,
        "y": 160,
        "wires": [
            [
                "b33821c7c260cf81"
            ]
        ]
    },
    {
        "id": "b33821c7c260cf81",
        "type": "udp out",
        "z": "da099c9102c4e8ab",
        "name": "",
        "addr": "192.168.1.10",
        "iface": "",
        "port": "10023",
        "ipv": "udp4",
        "outport": "",
        "base64": false,
        "multicast": "false",
        "x": 730,
        "y": 160,
        "wires": []
    },
    {
        "id": "e86b9f9871d5e9f6",
        "type": "function",
        "z": "da099c9102c4e8ab",
        "name": "",
        "func": "msg.payload = { \"packets\": [{ \"type\": \"s\", \"value\": \"scene\" }, { \"type\": \"i\", \"value\": 0 }] };\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 310,
        "y": 160,
        "wires": [
            [
                "220366b7f70d5845",
                "49a46685da1b43cc"
            ]
        ]
    },
    {
        "id": "51eb5aa2fd856f3e",
        "type": "comment",
        "z": "da099c9102c4e8ab",
        "name": "Send a bundle over OSC",
        "info": "",
        "x": 170,
        "y": 120,
        "wires": []
    },
    {
        "id": "49a46685da1b43cc",
        "type": "debug",
        "z": "da099c9102c4e8ab",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 440,
        "y": 80,
        "wires": []
    }
]

Any thoughts?

terwarf commented 1 year ago

@alexszilagyi I remember trying to switch scenes, but i couldn't get it to work. So I gave up on this topic and stopped controlling the mixer with node-red.

If I remember correctly, i just used an injection node for the test mentioned above.