adowty glad to hear you got your board before Christmas!

When I made the scope-sliders example for Bela I considered using nexusOSC to do it, but I decided against it for the following reasons:

  • AJAX is much slower and less efficient than a websocket, especially over a local connection
  • I don't like PHP, I'm not sure its even installed on the Bela image by default, and all of the Bela web server code is programmed in node.js so I didn't want to add another language to the mix.

When you change the scope-sliders, some js running in the browser sends the data over a websocket to node.js on the board which then relays it over OSC to Bela. My recommendation would be to do something similar, using the OSC example here as a starting point. You could still use nexusUI for the GUI objects with this method. We are actually planning on separating the sliders from the scope at some point which would make this all a lot easier, though that hasn't happened yet.

That said, the nexusOSC route should work fine, and yes I think you should see your OSC messages printed to the IDE console if everything is set up right, though it will only work if the format of your OSC messages is exactly as the code expects.

Once you've got it working with the C++ example hopefully @giuliomoro can point you to some advice on getting it working with PD.

    Hi guys, I want to set up a symbolic link to the public folder to make development faster.
    what is the path to the files I see in BELABOOT, the volume I see on my desktop?

    ln -s ~/Bela/IDE/public/mywebfolder /path/to/BELABOOT

    it's /boot/uboot. I am working now on netsend/neterceive on libpd.

    hello,
    I implemented a properly threaded [netreceive]. It works for UDP (-u) and with or without -b. No TCP at the moment.
    Pd's original object would check for new data on the socket from within the audio thread (pure evil!), this one checks for new data in a separate thread (which is handled by the Bela program, so you will need a new default_libpd_render.cpp to account for this ) and adds the data to a ring buffer. It then requires a bang in order to output its data. Upon bang, it reads from the thread-safe ringbuffer and outputs the data.
    Let me know if you want to access this version or you prefer to wait till I implement an "auto-timer" so that you do not need to bang it (and it goes back to being fully compatible with the "regular" [netreceive])

    Note: this [netsend] requires a `bang` to poll for received data

    Actually: done.
    UDP should be working fine, but not TCP.
    I don't think [netsend] is working at the moment.

    You need to update your board to this version of the core code (note - in case you were using a custom render.cpp file - you will need to apply these changes to your file as well).
    See here for info on how to update to an "experimental release".

    Happy New Year guys. I'm knee deep in this now.
    I did the update. (f.y.i. it erased my little webpage, so i had to re-copy it back to the public folder)
    Giulio, your last two posts seemed to indicate that at first, you had [netreceive] sort of fixed and then you posted again suggesting that you had it all the way fixed.
    Just to clarify, do I need to replace my default_libpd_render.cpp or did the update cover that?
    (I'm not even sure what this is and thus, haven't created a custom one yet)
    Also, do I need to [metro]>[bang] the [netreceive] or did that get fixed for the distro linked to above.
    I'm getting sound out of the board. (good)
    osc is not yet working. links to the socket.io, jquery, and nexusUI libraries are good.
    The NexusUI node.js example I linked to the other day has this line where address is defined:
    var socket = io.connect('http://127.0.0.1:7562');

    would you say that was correct?

    Then I have a pd patch called osc_test that looks like this:
    [metro 100]
    |
    {listen 7562}
    |
    [netreceive -u -b]
    |

    • |
      [oscparse]
      |
      [print]

      pd print messages should go to the ide message board, correct?

      Hello,

      it erased my little webpage

      that's expected, the update script currently replaces all the following files/folders:

      core include Makefile lib examples Doxyfile IDE

      in fact, an "advanced user" placing/editing files there is supposed to know this. A warning pops up when you do the update but we may want to make it more clear.

      This updated version of libpd does not require the [metro]--[bang], it will automatically send a message to its output when a new input comes in.
      The default_libpd_render.cpp and libpd are automatically updated.
      default_libpd_render.cpp is used as the default wrapper around your Pd patch when using libpd. You don't have to know about it unless you want to change something about it (e.g.: for a custom application). In that case, you'd use it as a template to craft your own. I mentioned it here because in case you had your own custom rende.cpp, then in order to get [netreceive] to work, you would have needed to apply to your file those changes I applied to the default one. But it seems like you don't need to worry.

      Try with

      [netreceive -u -b 7562]
      |
      [print]

      and see if anything gets printed to the console.
      If it does, and it looks too much like gibberish, then nexusUI (which I know nothing about) may not be sending binary but plain text, so try removing the -b (which stands for "binary").

      nothing yet. I have looked through all other mentions of osc on the forum.
      I'm not an an advanced user by any stretch. I'm an instrument builder. I need to make an audio effect, I learn PD; I need to cut a complex shape out of wood, I learn CNC; I need to make a webpage, I learn web languages. I am reading about node, npm, socket.io and server side js but I am not really getting it yet. However, I am pretty determined to get this to work and I don't want to install php if you don't think it will be a good idea. I don't expect you to support anyone else's products or work.

      From my reading, it appears I need to set up a custom "nx" server by running a small js file server side.
      For the scope sliders, it appears there is a js file called scope-worker.js which has similar code to what I need to run but with different parameters. I can see that it is running in my browser console, but it is not called from the html file. Is scope-worker.js called when node.js starts up or when the scope is started? Is there an ini file somewhere that starts it? and finally, should I use different ports in my script to avoid conflicts with the scope?

        Oh wait I see what your issue is:

        adowty var socket = io.connect('http://127.0.0.1:7562');

        If you are trying to send OSC over the websocket, then the Bela program will not be able to handle it, because it does not support websocket or TCP. Even when I'll fix the TCP in [netreceive], it will not be enough: websocket is built on top of TCP and some additional patching is required, see e.g. this patch which does not even use [netereceive], rather it uses [mrpeach/tcpserver].

        Long story short: I'd suggest NOT to try and handle a websocket connection from within libpd:

        LiamDonovan When you change the scope-sliders, some js running in the browser sends the data over a websocket to node.js on the board which then relays it over OSC to Bela.

        As Liam suggests, the easiest way to handle a websocket connection with the browser (assuming it is what you want) is to have node handle the websocket with the browser and relay the messages to the Bela program over UDP.

        Not sure about how scope-worker.js is loaded, but you may want to start your experiments with running your script in a stand-alone script, in a different node process, it is surely going to make debugging easier in the beginning: make it an entirely different script and run it with node yourscript . As long as you listen on different ports than the ones used by the Bela IDE, your stand-alone script should work fine, the script will be fast at starting / stopping and development is easier.

        adowty sorry for the slow christmas-time response.

        I decided to set up a quick example of communication from a NexusUI slider to Bela via websocket and OSC, it is here. Hopefully the README should contain all the instructions, but feel free to ask if anything isn't clear.

        To get the example onto your board, update to the dev-nexusUI branch following these instructions (note this will delete your files from IDE/public again).

        That's outstanding! Thank you.

        6 days later

        The update went fine but when starting the node server from the NexusUI project folder as indicated in readme.txt i get this error.

        module.js:440    throw err; 
        ^Error: Cannot find module 'debug'    
        at Function.Module._resolveFilename (module.js:438:15)    
        at Function.Module._load (module.js:386:25)    
        at Module.require (module.js:466:17)   
        at require (internal/module.js:20:19)    
        at Object. 
        (/root/Bela/projects/NexusUI/node_modules/finalhandler/index.js:14:13)    
        at Module._compile (module.js:541:32)    
        at Object.Module._extensions..js (module.js:550:10)    
        at Module.load (module.js:456:32)    
        at tryModuleLoad (module.js:415:12)    
        at Function.Module._load (module.js:407:3)

          adowty

          by installing this, I was able to get the node server started:
          npm install debug --save-dev

          Hey, sorry about that it was a weird bug involving .gitignore paths in the repo. Should be fixed now, if you re-update to the latest dev-nexusUI branch.

          7 days later

          (for anyone else who takes this path)
          If index.js reads like this from lines 27 to 42, then sliders as well as all the rest of the nexus ui widgets will be received in libpd using the vanilla netreceive, oscparse and route objects:

          socket.on('nx', data => {

            sendOSC({
          		address	: '/nexus-ui',
          		args	: [
          			{
          				type	: 'string',
          				value	: data.oscName
          			},
          			{
          				type	: '*',
          				value	: data.value
          			}
          		]
          	});
          });

          });

          ...then in index,html nx.sendsTo("node"); covers all objects, no need for:
          slider1.on('*', data => socket.emit('slider', {id:1, value: data.value}) );

          Thank you Giulio and Liam.
          Over and Out!!!

          25 days later

          Hi all

          Big props on the bela, I've been having a lot of fun hacking away with it, learning my way around it still. I'm having a tough time connecting libPD to nexusUI on the node server. I'm a fairly novice C++ programmer, still trying to get my head around the OSCPKT Message handling.

          Here's a clone of the proj file (excuse messiness): https://github.com/gingyg/NexusUITest

          Originally I made a Nexus UI matrix object to add to the example from above (https://github.com/BelaPlatform/Bela/tree/dev-nexusUI/examples/05-Communication/NexusUI). It's in the backup folder of the repository. I can only get bela to read that a message is being sent to /nexus-ui/, but not the contents of the message. I also tried modifying the osc message parsing code to the example from this: https://github.com/BelaPlatform/Bela/blob/master/examples/05-Communication/OSC/render.cpp

          Afterwards I tried building a huge matrix of NexusUI buttons in case it was something weird about the matrix class. Still didn't work

          The node console confirms that there is value data coming in (numbers are read). Also I suspect I am not handling the bundling of data correctly?

          Also let me know how to hyperlink text here so that I don't have to pull full links... can't seem to find a button (sorry)

          Thanks!
          -b

            Hi, as far as links are concerned you can use markdown syntax: [your text here](http://your-link.com/here).
            You can inline code snippets using single backticks: `your code here ` and insert code blocks enclosing your blocks in triple backticks (on their own line):
            ```
            your block of
            many lines
            of code
            H e R e
            ```

            For the rest, I think @LiamDonovan is a better candidate to answer your questions!

            gingygingyging I think the problem is probably with the type field of your OSC messages.

            On line 31 of your index.js you are sending an OSC message with two arguments, the first is a string and the second a wildcard, however on line 48 of your render.cpp you are trying to parse an OSC message with an integer argument followed by a float argument. If the number of arguments in the OSC message you are sending or their types differ from what you try to parse in your c++ code, the line

            msg.match("/nexus-ui/").popInt32(intArg).popFloat(floatArg).isOkNoMoreArgs()

            will return false and you won't be able to parse the message. You either need to modify render.cpp to expect the correct arguments or (somewhat easier in my opinion) modify your index.js to send an integer and a float, as in the original nexusUI example.