Hi Bela team, @giuliomoro and bela folks!

This year I am coordinating a residency for a quartet of Knurls. 3 cellists were selected in an open call and with me they are going to compose a collective composition with 4 belas to be premiered at Gaudeamus festival on the 9th September 2023.

alt text

In each Knurl I have programmend its own ethernet connection and wifi hotspot. We will use different ports but at the moment, I have programmed the same ip address for each (192.168.30.1). I wonder if that can be a problem if all knurls are connected at the same space since last times all the knurls were on, we noticed some malfunctions in the osc communication between our ipads and bela.

Thanks in advance!

are you connecting all of the Belas to the same network, or is each of them broadcasting its own network? In the first case, you need each of them to have a unique address, in the second case, then it's fine to have all of them on the same IP, as they won't "see each other" as they are each on a separate network.

    7 days later

    giuliomoro Hi Giulio, thanks for your reaction!

    Last week I took some time to investigate it and the reason why some Knurls weren’t not connecting was because I forgot to check their computer’s ip address (classic error using OSC 😛 ).

    The option I am using at the moment is the second: every Knurl has its own network.

    giuliomoro @nescivi @jonathan @Adampultz :
    I do have another question and topic subthread regarding adding a restart button on the Bela sc code. (I added some people that might be interested to know about this topics 🙂)

    I noticed the need for the cellists to have a restart button on their Knurls, I designed to possible approaches for it:

    1) They can press the white restart button at Bela
    2) They can press a button design a the TouchOSC Patch designed for Knurl , where the system send a OSC messages that asks Bela to reboot its system.

    For the first option I found a way to make the Bela reboot and by running this code:

    ServerQuit.add({ s.reboot;  s.waitForBoot({("_main.scd".load)}) });

    For the second option, It didn’t seemed to work using the same code, but it was working when TOUCHOSC sends by the click of the button this specific message:

    /knurl/reset 1

    to this specific OSCdef to run it:

    OSCdef.new(\virusreset, { arg msg,time,addr,port;
    	var state = msg[1]; 
    	~reset = state;
    
    if(~reset == 1 ) { 
    	"reset".postln;
    	s.reboot;  
    };
    }, '/knurl/reset');

    However, all the Knurl players have notice that the TouchOSC Patch stops to receive information from the instrument after sometime. I did some tests recently and I believe it is causing a break of protocol or on the order of booting things on Bela. I can get messages such as :

    A BelaSeverOptions
    A BelaSeverOptions
    A BelaSeverOptions
    Bela disconnected from the system

    I wonder if you would have a suggestion how to make this second one works as well, since it is quite handy to have this feature.

      I do also have another question regarding CPU data from the bela mini.

      On the bela ipadress, you are always able to check how much CPU your bela is using through the webbrowser platform. For the cellists, this might become to much things to do and to set up in the future. I wonder if there is a way to capture this information using supercollider and send to the TouchOSC patch that they will be looking at.

      I tried "s.avgCPU" but that does seem to give me only 0.0.
      Does anyone has an idea how to make this work?

      Thanks in advance! 🙂

        RafaeleAndrade On the bela ipadress, you are always able to check how much CPU your bela is using through the webbrowser platform. For the cellists, this might become to much things to do and to set up in the future. I wonder if there is a way to capture this information using supercollider and send to the TouchOSC patch that they will be looking at.

        I tried "s.avgCPU" but that does seem to give me only 0.0.

        One can easily get the CPU usage of a single-threaded Bela program by running awk '/bela-audio/ { print $8};' /proc/xenomai/sched/stat
        if you could run this command on the board and somehow pass its output to TouchOSC, that would be you sorted. It can be done with a simplified/modified version of the program I suggest here https://forum.bela.io/d/2944-realtime-functionality-outside-of-the-bela-context , e.g.:

        #include <unistd.h>
        #include <libraries/UdpClient/UdpClient.h>
        #include <oscpkt.hh>
        UdpClient udpClient;
        
        int main()
        {
        	int port = 1234;
        	const char* ip = "192.168.7.1";
        	float periodSeconds = 1;
        	bool ret = udpClient.setup(port, ip); // use 192.168.7.1 to send to host or 192.168.7.2 to send to other program on Bela
        	if(!ret) {
        		fprintf(stderr, "Unable to connect to remote\n");
        		return 1;
        	}
        	printf("Connected to %s:%d, sending data every %.3f seconds\n", ip, port, periodSeconds);
        
        	while(1)
        	{
        		// popen/pclose code courtesy of https://stackoverflow.com/a/646254
        		FILE *fp;
        		char path[1035];
        
        		/* Open the command for reading. */
        		fp = popen("awk '/bela-audio/ { print $8};' /proc/xenomai/sched/stat", "r");
        		if (fp == NULL) {
        			printf("Failed to run command\n" );
        			exit(1);
        		}
        
        		oscpkt::Message msg("/address/path");
        		/* Read the output a line at a time - output it. */
        		// should be just one line
        		if(fgets(path, sizeof(path), fp) != NULL)
        			msg.pushFloat(atof(path));
        		else
        			msg.pushFloat(0);
        		/* close */
        		pclose(fp);
        
        		oscpkt::PacketWriter pw;
        		pw.init().addMessage(msg);
        		udpClient.send(	pw.packetData(), pw.packetSize());
        		usleep(periodSeconds * 1000000);
        	}
        	return 0;
        }

        This project will send a float to /address/path representing the percentage CPU usage.

        You should run this as an additional service on the board, see https://learn.bela.io/using-bela/bela-techniques/running-a-program-as-a-service/. So, you'd create a project in the IDE, called e.g.: cpu-osc, put this file in there, build it once, and then follow the instructions at the URL above, replacing O2O with cpu-osc.

        RafaeleAndrade However, all the Knurl players have notice that the TouchOSC Patch stops to receive information from the instrument after sometime.

        is this because the instrument becomes too busy with audio that it can no longer send out OSC?

        RafaeleAndrade etime. I did some tests recently and I believe it is causing a break of protocol or on the order of booting things on Bela. I can get messages such as :

        A BelaSeverOptions
        A BelaSeverOptions
        A BelaSeverOptions
        Bela disconnected from the system

        where do you see that?

          8 days later

          giuliomoro Hi Giulio,

          Thanks for your reply. The code of Knurl is entirely written in Sc. I wonder if there is a way to achieve the same result mentioned above with this programming language. Perhaps a new UGen class would be the solution in this instance?

            giuliomoro

            giuliomoro RafaeleAndrade etime. I did some tests recently and I believe it is causing a break of protocol or on the order of booting things on Bela. I can get messages such as :

            A BelaSeverOptions
            A BelaSeverOptions
            A BelaSeverOptions
            Bela disconnected from the system

            I get this code at the console.

              giuliomoro

              giuliomoro giuliomoro is this because the instrument becomes too busy with audio that it can no longer send out OSC?

              Perhaps but I dont see the instrument CPU problems during this process. I am going to experiment further about this

              RafaeleAndrade Thanks for your reply. The code of Knurl is entirely written in Sc. I wonder if there is a way to achieve the same result mentioned above with this programming language. Perhaps a new UGen class would be the solution in this instance?

              The code I posted can run as a separate process, alongside Supercollider. While it could be modified to become a ugen, I see no good reason to do that.

              RafaeleAndrade Bela disconnected from the system

              I don't think this is the literal line you get?

                a month later

                Hey giuliomoro !

                It is taking sometime to experiment with all these questions, but the most important to solve for now is the reset button.

                The cellists feel the need to have one button to restart the patch. I believe the funcionallity of the white button on my bela covers the problem but unfortunately that is not accessible and a bit unsafe to touch it all the time.

                For that I want to confirm with you some info I found at learn.bela.io:

                1. Is the pin p2.34 the same digital pin used for the white button from mini bela?

                2. Would I connect this new button as a similar normal digital button set up? Such as:

                3v bela - button leg
                GND bela - resistor 10k - button leg
                P2.34 - button leg

                1. Do I need to change anything in the automatic script from mini bela for it?

                Ps:This button should have the same funcionallity: resetting the whole bela if a short click
                Stopping the bela when pressed long.

                  RafaeleAndrade Is the pin p2.34 the same digital pin used for the white button from mini bela?

                  yes

                  RafaeleAndrade Would I connect this new button as a similar normal digital button set up?

                  sort of. There is an internal pull-up resistor, so you'd connect P2.34 to a switch and the other side of the switch to ground. Then, when pressing the switch it will behave exactly as it would if you were to press the button on the Bela Mini cape.

                  RafaeleAndrade Do I need to change anything in the automatic script from mini bela for it?

                  so no