NodeRed dashboard OSC to sonic

nodebutton

Continuing from my previous post, I thought something more useful might be possible. The above node-red example creates a web based dashboard button. This sends the message in the OSC example input in sonic-pi tutorial. Hit the button and it plays the tone. Question is… what would be useful to put in a dashboard that could run (on any lan based system) to send controls (to sonic). Would this have any real use? Something like a drum input board, or volume controls, maybe? Does anyone have any suggestions…?

i don’t know node-red. Does this is the interface to click on ? The button ?
yes it can be used to launch a loop via a sync osc message or to build an web interface to control sonic pi.

May give a try…

in the example, when i pressed the dashboard button it activated the tone in the sonic-pi receiving OSC example in the tutorial. Import the code below into node-red…

[
    {
        "id": "c9c93597.7965c",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "aabc4a61.0f2988",
        "type": "osc",
        "z": "c9c93597.7965c",
        "name": "OSC /trigger/prophet",
        "path": "/trigger/prophet",
        "metadata": false,
        "x": 350,
        "y": 180,
        "wires": [
            [
                "d5e8003c.150b7"
            ]
        ]
    },
    {
        "id": "d5e8003c.150b7",
        "type": "udp out",
        "z": "c9c93597.7965c",
        "name": "",
        "addr": "g.local",
        "iface": "",
        "port": "4560",
        "ipv": "udp4",
        "outport": "4561",
        "base64": false,
        "multicast": "false",
        "x": 490,
        "y": 260,
        "wires": []
    },
    {
        "id": "2841b801.1387d8",
        "type": "ui_button",
        "z": "c9c93597.7965c",
        "name": "button: [70,100,8]",
        "group": "f634f42a.868238",
        "order": 0,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "button",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "icon": "",
        "payload": "[70,100,8]",
        "payloadType": "json",
        "topic": "/trigger/prophet",
        "x": 200,
        "y": 100,
        "wires": [
            [
                "aabc4a61.0f2988"
            ]
        ]
    },
    {
        "id": "f634f42a.868238",
        "type": "ui_group",
        "z": "",
        "name": "Default",
        "tab": "f765b2c2.da2378",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "f765b2c2.da2378",
        "type": "ui_tab",
        "z": "",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

Just found that node-red has a midi interface, it connected successfully with sonic, though that’s as far as I’ve got so far - no sound out yet. Too much to try at once.

you will have to get feedbacks and code for all your researches :slight_smile: sonicipi code with node-red code

I have a midi keyboard - on entering a key it outputs a midi message containing [note, velocity]. On release it sends [note,0]. I found this out by using a node red midi-in to debug. (this is on my pi c.local (a v3))… sending this to sonic on g.local (a pi v4) allows me to play the keyboard into sonic-pi (via midi via osc) . Then I added some buttons to the node red dashboard for a few notes demo.

live_loop :listen do
  use_real_time
  a,b = sync "/osc*/play_note"
  if b
    if b > 0
      synth :prophet, note: a, velocity: b
      #synth :hoover, note: a, velocity: b
      #synth :blade, note: a, velocity: b
    end
  end
  else
    puts " b is null"
  end


nodeDash

I can now hit one of the buttons on the node-red dashboard (needs formatting to look like a keyboard) or play on the real keyboard. Here is the node-red code :-

[
{"id":"19a0a22b.040276","type":"tab","label":"Flow 2","disabled":false,"info":""},
{"id":"f7ae16f8.ccb0c8","type":"midi in","z":"19a0a22b.040276","name":"","midiport":"1","x":90,"y":200,"wires":[["3404345a.3a5434","7046104.ba7f9f","88000eb7.32c38"]]},
{"id":"7046104.ba7f9f","type":"ui_text","z":"19a0a22b.040276","group":"226ff5c9.c476ba","order":6,"width":0,"height":0,"name":"","label":"keyboard","format":"{{msg.payload}}","layout":"row-spread","x":430,"y":200,"wires":[]},
{"id":"3404345a.3a5434","type":"debug","z":"19a0a22b.040276","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":460,"y":280,"wires":[]},
{"id":"88000eb7.32c38","type":"osc","z":"19a0a22b.040276","name":"OSC /play_note","path":"/play_note","metadata":false,"x":430,"y":340,"wires":[["86ea6742.25437"]]},
{"id":"86ea6742.25437","type":"udp out","z":"19a0a22b.040276","name":"","addr":"g.local","iface":"","port":"4560","ipv":"udp4","outport":"4561","base64":false,"multicast":"false","x":690,"y":340,"wires":[]},{"id":"5ba6d45a.9c161c","type":"ui_button","z":"19a0a22b.040276","name":"button : 60","group":"226ff5c9.c476ba","order":0,"width":0,"height":0,"passthru":false,"label":"60","tooltip":"","color":"","bgcolor":"","icon":"","payload":"[60, 50]","payloadType":"json","topic":"","x":130,"y":320,"wires":[["88000eb7.32c38"]]},
{"id":"b7c80f78.4ee298","type":"ui_button","z":"19a0a22b.040276","name":"button : 70","group":"226ff5c9.c476ba","order":0,"width":0,"height":0,"passthru":false,"label":"70","tooltip":"","color":"","bgcolor":"","icon":"","payload":"[70, 50]","payloadType":"json","topic":"","x":130,"y":360,"wires":[["88000eb7.32c38"]]},
{"id":"8e46ef41.e71588","type":"ui_button","z":"19a0a22b.040276","name":"button : 80","group":"226ff5c9.c476ba","order":0,"width":0,"height":0,"passthru":false,"label":"80","tooltip":"","color":"","bgcolor":"","icon":"","payload":"[80,50]","payloadType":"json","topic":"","x":130,"y":400,"wires":[["88000eb7.32c38"]]},
{"id":"1a86de94.2c7619","type":"ui_button","z":"19a0a22b.040276","name":"button : 90","group":"226ff5c9.c476ba","order":0,"width":0,"height":0,"passthru":false,"label":"90","tooltip":"","color":"","bgcolor":"","icon":"","payload":"[ 90,50 ]","payloadType":"json","topic":"","x":130,"y":440,"wires":[["88000eb7.32c38"]]},
{"id":"226ff5c9.c476ba","type":"ui_group","z":"","name":"Default","tab":"7ab897c5.a3168","order":1,"disp":true,"width":"6","collapse":false},
{"id":"7ab897c5.a3168","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}
]

Interesting thing is that the dashboard could be anywhere that supports a browser( mobile, tablet…)

1 Like