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.

          @LiamDonovan sorry, just realized you were looking at the backup index.js, but the active one was already sending integer and float

          When I run, it shoots this error up and made the node server unresponsive after (had to pkill and reset to try again).

          nx 71 changed to value undefined
          
          /root/Bela/projects/NexusUITest/node_modules/osc-min/lib/osc-utilities.js:265          
          
          throw new Error("expected number");          
          ^
          Error: expected number    
          at Object.oscTypeCodes.f.toArg (/root/Bela/projects/NexusUITest/node_modules/osc-min/lib/osc-utilities.js:265:17)

          Then a big lists all along the chain where the error persists. You are definitely right about it not sending the correct type of data, I will keep trying to figure out osc-min thanks

          @adowty did you get this working with osc-min and libpd? do you have examples of your code?

            gingygingyging could you post the full output of the error, including particularly the output of the line console.log('nx', data.id, 'changed to value', data.value);.

            What is suspect is happening is that data.value is being sent across from the browser as undefined which is causing errors within osc-min. I would also check inside index.html that the data.value field there in the nexus button callback is defined.

            nx 39 changed to value undefined is the full line for the console log.

            from index.html:

            nx.onload = function() {
            ...//many other buttons w same function, different id number and canvas/nexusUI id
            button27.on('*',function(data){socket.emit('nx', {id:39, value: data.value})});
            ...//other buttons
            };

            Is it that they're all sending to nx in {socket.emit('nx'?

            For the record, the buttons appear properly in 192.168.7.2:3000

              gingygingyging Ok yes it looks like the problem is with the data.value in index.html. Try replacing that line above with the following:

              button27.on('*',function(data){ console.log(data) });

              Hopefully there will be another field in the data object not called value, which actually holds the value of the button, and which you will need to send in the value field of the web socket message.