OSC 2 MQTT with IanniX

Converting OSC to MQTT, and back.

This example uses the IanniX sequencer to generate a stream of OSC packages, send them to an MQTT broker, receive them again, then send them as OSC packages to a Processing Sketch for visualization.
As MQTT topic we use the OSC-path with a unique prefix.

MQTT brokers

The flow is preconfigured with three different MQTT brokers:

  • localhost
  • test.mosquitto.org
  • mqtt.eclipse.org

Visualization

Use the processing sketch included in the IanniX Patches folder. You can find it on github. The sketch should also come with your Iannix install. For OSX this is: /Applications/IanniX.app/Contents/Resources/Patches/Processing

Make sure to change the OSC port in the processing sketch from 57120 to 57121.

Requirements

[{"id":"1bd2b382.4dd4f4","type":"tab","label":"OSC 2 MQTT with IanniX","disabled":false,"info":"Converting OSC to MQTT, and back.\n\nThis example uses the [IanniX](https://www.iannix.org/en/) sequencer to generate a stream of OSC packages, send them to an MQTT broker, receive them again, then send them as OSC packages to a Processing Sketch for visualization.  \nAs MQTT topic we use the OSC-path with a unique prefix.\n\n## MQTT brokers\n\nThe flow is preconfigured with three different MQTT brokers:\n\n* localhost\n* test.mosquitto.org\n* mqtt.eclipse.org\n\n## Visualization\n\nUse the processing sketch included in the IanniX Patches folder.  You can find it [on github](https://github.com/buzzinglight/IanniX/tree/master/Patches/Processing). The sketch should also come with your Iannix install. For OSX this is:   `/Applications/IanniX.app/Contents/Resources/Patches/Processing`\n\nMake sure to change the OSC port in the processing sketch from 57120 to 57121.\n\n## Requirements\n\n* [node-red-contrib-osc](https://flows.nodered.org/node/node-red-contrib-osc)"},{"id":"a4f954b.ada4d28","type":"mqtt-broker","z":"","name":"localhost","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"8ea55f65.a37958","type":"mqtt-broker","z":"","name":"mqtt.eclipse.org","broker":"mqtt.eclipse.org","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"1dd4851e.412ce3","type":"mqtt-broker","z":"","name":"test.mosquitto.org","broker":"test.mosquitto.org","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"9e0b1c81.2cfd58","type":"osc","z":"1bd2b382.4dd4f4","name":"","path":"","metadata":false,"x":250,"y":200,"wires":[["377f7eea.8bab4a"]]},{"id":"1e240763.dd1161","type":"udp in","z":"1bd2b382.4dd4f4","name":"","iface":"","port":"57120","ipv":"udp4","multicast":"false","group":"","datatype":"buffer","x":100,"y":200,"wires":[["9e0b1c81.2cfd58"]]},{"id":"3f085b2c.3d462c","type":"mqtt out","z":"1bd2b382.4dd4f4","name":"","topic":"","qos":"","retain":"","broker":"a4f954b.ada4d28","x":890,"y":200,"wires":[]},{"id":"f390cb1f.223058","type":"mqtt in","z":"1bd2b382.4dd4f4","name":"","topic":"plab/feeds/iannix/#","qos":"0","datatype":"json","broker":"a4f954b.ada4d28","x":130,"y":300,"wires":[["68caace7.b2aa64"]]},{"id":"377f7eea.8bab4a","type":"change","z":"1bd2b382.4dd4f4","name":"add prefix","rules":[{"t":"set","p":"topic","pt":"msg","to":"$join([$flowContext(\"prefix\"), topic])","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":200,"wires":[["10e8f26d.b035ee","3f085b2c.3d462c"]]},{"id":"b2f9d670.9038b8","type":"inject","z":"1bd2b382.4dd4f4","name":"","topic":"","payload":"plab/feeds/iannix","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":150,"y":100,"wires":[["f2cbadc0.4d87e8"]]},{"id":"f2cbadc0.4d87e8","type":"change","z":"1bd2b382.4dd4f4","name":"set prefix","rules":[{"t":"set","p":"prefix","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":100,"wires":[[]]},{"id":"f696638b.0c69d8","type":"comment","z":"1bd2b382.4dd4f4","name":"set topic prefix","info":"","x":120,"y":60,"wires":[]},{"id":"259ef9e3.cf8046","type":"comment","z":"1bd2b382.4dd4f4","name":"receive OSC messages from IanniX","info":"","x":180,"y":160,"wires":[]},{"id":"65a5b34f.9f0e0c","type":"comment","z":"1bd2b382.4dd4f4","name":"... send MQTT messages to the broker","info":"","x":750,"y":160,"wires":[]},{"id":"132ce4b7.b27cbb","type":"comment","z":"1bd2b382.4dd4f4","name":"receive MQTT messages from the broker ...","info":"","x":210,"y":260,"wires":[]},{"id":"68caace7.b2aa64","type":"change","z":"1bd2b382.4dd4f4","name":"remove prefix","rules":[{"t":"set","p":"topic","pt":"msg","to":"$replace(topic, $flowContext('prefix'), '')","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":300,"wires":[["ba16d961.6125a"]]},{"id":"ba16d961.6125a","type":"osc","z":"1bd2b382.4dd4f4","name":"","path":"","metadata":false,"x":650,"y":300,"wires":[["cc273a95.3d417"]]},{"id":"cc273a95.3d417","type":"udp out","z":"1bd2b382.4dd4f4","name":"","addr":"localhost","iface":"","port":"57121","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":840,"y":300,"wires":[]},{"id":"e2a164e8.afa0b8","type":"comment","z":"1bd2b382.4dd4f4","name":"... send OSC messages to processing","info":"","x":750,"y":260,"wires":[]},{"id":"10e8f26d.b035ee","type":"delay","z":"1bd2b382.4dd4f4","d":true,"name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"100","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":680,"y":100,"wires":[["3f085b2c.3d462c"]]},{"id":"86c16ce6.395528","type":"comment","z":"1bd2b382.4dd4f4","name":"use the lmiter if you want ...","info":"","x":720,"y":60,"wires":[]}]

Collection Info

prev

Flow Info

Created 4 years, 11 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x3)
  • comment (x6)
  • delay (x1)
  • inject (x1)
  • mqtt in (x1)
  • mqtt out (x1)
  • mqtt-broker (x3)
  • udp in (x1)
  • udp out (x1)
Other
  • osc (x2)
  • tab (x1)

Tags

  • MQTT
  • OSC
  • IanniX
  • sequencer
  • processing
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option