I have programmed a bela unit to function as a 10 track record / playback box (8 analog i/o + stereo audio) that performs three operations. The three operations are (1) go to frame and enter idle mode, (2) enter play mode, and (3) enter record mode.

What I am now considering is whether it is possible to use the digital I/O lines to effectively multiply the number of analog i/o channels by multiplying the number of bela units used.

My thought is that a digital go signal can start multiple bela units playing, but the specific frame number within an 8 frame block in which the digital go is received is not guaranteed. Thus the belas may commence playback at slightly different times.

An expert opinion on an approach to the simultaneous starting of playback on multiple belas is welcome.

    9 days later

    I'll re-state the question more concisely: How can I trigger two or more BELA devices so that the audio and analog buffers are starting their buffering cycles at as close to simultaneously as possible?

    As I mentioned previously, a digital go signal can start multiple bela units playing audio, but the specific frame number within an 8 frame block in which the digital go is received is not guaranteed. Thus the belas may commence playback at slightly different times.

    take my answer with a grain of salt, i am not a BELA dev or an expert on the field..

    my understanding would be that playback of the audio is also block based, so it will almost certainly be "out of sync" by a fraction of a buffer since the two bela boards run independently from each other. what you would want to do is to sync the samplerate and potentially also the block beginning and end.. (with a master BELA and one or multiple slaves). i don't think there is a mechanism for that.

    may i ask why you need such high precision? what exactly is the application? you won't notice the starting difference in normal audio playback.

    Thank you for your reply. I think you are right about all those things. Audio is block based, Multiple BELAs triggered to start simultaneously will almost certainly be out of sync by a fraction of a buffer, AND that small loss in precision probably doesn't mater. I will run tests using two BELAs to attempt to observe the expected behavior, and then post back here with an oscilloscope photo.

    Hopefully I do not need such high precision. The application is the replication of the control signals with audio sync for the classic Laserium shows of the 1970s and 1980s. Discussion of this project is found in the CYGN-B thread on photonlexicon.com

    somedev My thought is that a digital go signal can start multiple bela units playing, but the specific frame number within an 8 frame block in which the digital go is received is not guaranteed. Thus the belas may commence playback at slightly different times.

    That may be down to your software ... Bela samples the digital inputs at the same sampling rate as the audio, so you can achieve sub-sample time-alignment if your software does it properly. In C++ this is relatively easy, but if you are using PureData, you should try and do everything in the signal domain, as when you start using messages I think these get quantised to the block.

    Generally speaking, one issue you may have when using more than one Bela unit is that the clocks will drifts between each of them (i.e.: 44100Hz is never exactly 44100Hz, but they are always slightly off between each other by some hundred part per million (or worse, depending on the crystal's accuracy). If you cannot tolerate a minimal amount of drift, which could easily cause the boards to drift off by one samples every few seconds, then you should consider synchronising the digital clock generators, using one board as the clock generator and routing its clock signals to the other boards. These are high-speed signals (1.4MHz at least), so signal quality cannot be easily guaranteed without appropriate routing. This ensures the frequency of the sampling is synchronised between different units.

    Synchronising two boards at the block level may require some changes to the PRU code, so that N-1 boards wait for a GPIO from the main board before they start clocking out samples. This ensures that the phase of the processing is synchronised between different units.

    All of this is doable, but it is not straightforward, so you should probably ask yourself: what (if any) of this do you need? If you are doing recordings that are a no longer than a few minutes and the inter-board phase accuracy is not critical, then I'd guess you probably don't need any of these.

    2 months later

    Is there anything on board bela that I could use to calculate RGB values from HSV?

    For example, java has:
    Color c = Color.getHSBColor(hue, saturation, value);
    String rgb = Integer.toHexString(c.getRGB());

    I don't know if there is something readily available but we have used this in the past:

    /* Convert HSV to RGB (the actual mechanics here0 */
    void rgbledHSVToRGB(uint8_t hue, uint8_t saturation, uint8_t value,
            uint16_t *red, uint16_t *green, uint16_t *blue) {
        if(saturation == 0) {
            /* Gray = all colors the same intensity; convert value from 8 to 12 bits */
            *red = *green = *blue = (uint16_t)value << 4;
        }
        else if(value == 0) {
            *red = *green = *blue = 0;
        }
        else {
            uint8_t sector = hue / 43; /* Divide 0-255 range into segments 0-5 */
            uint8_t factorial = hue - (sector * 43);
    
            /* Intermediate factors for HSV->RGB */
            uint32_t p = value * (255 - saturation); /* Range 0-(255*255) */
            uint32_t q = value * (255*42 - saturation * factorial); /* Range 0-(255*255*42) */
            uint32_t t = value * (255*42 - saturation * (42 - factorial)); /* Range 0-(255*255*42) */
    
            /* Normalize each intermediate value to 12-bit range (0-4095). All intermediate values
             * should stay within 32-bit range. The numbers below come from reducing the fractions
             * to keep the intermediate value as small as feasible.
             */
            p = (p * 273) / (17*255);
            q = (q * 273) / (17*255*42);
            t = (t * 273) / (17*255*42);
    
            /* Safety check */
            if(p > 4095) p = 4095;
            if(q > 4095) q = 4095;
            if(t > 4095) t = 4095;
    
            switch(sector) {
            case 0:
                *red = (uint16_t)value << 4;
                *green = t;
                *blue = p;
                break;
            case 1:
                *red = q;
                *green = (uint16_t)value << 4;
                *blue = p;
                break;
            case 2:
                *red = p;
                *green = (uint16_t)value << 4;
                *blue = t;
                break;
            case 3:
                *red = p;
                *green = q;
                *blue = (uint16_t)value << 4;
                break;
            case 4:
                *red = t;
                *green = p;
                *blue = (uint16_t)value << 4;
                break;
            case 5:
                *red = (uint16_t)value << 4;
                *green = p;
                *blue = q;
                break;
            default:
                /* Shouldn't happen */
                *red = *green = *blue = 0;
                return;
            }
        }
    }

    In this case, RGB values are 12-bit (0 to 4095) and you probably want them 8-bit, so you have to divide the red, green, blue by 16.

    That is perfect, thank you. Code you provided can be seen working in the attached photo.
    alt text

    Are signal buffers, eg. non-inverting unity gain amplifiers needed in order to simultaneously provide digital and analog signals to the inputs of multiple bela units? Or is it ok to connect them together and to a voltage source, As shown in the attached illustration,? This is a design decision regarding which I would appreciate your opinion.
    alt text

    That's surely fine on the analog inputs side: the analog inputs are high-impedance (literally some megaohms). Remember that the analog inputs are 5V-tolerant but the usable range is 0 to 4.096V.

    Regarding the digitals, each digital input has a "weak" (tens of kiloohm) pull-down resistor, so when you start connecting many in parallel, they may become "stronger" (i.e.: lower or comparable resistance) than your external 10k pull-up. Still, it probably works fine for a small number of units (2? 3?). This internal resistor can be disabled via software but it's a bit complicated. I would recommend instead, if at all possible, that you wire them up with an external 10k pull-down and then when you press the button you short the inputs to 3.3V. This way, the internal pull-downs won't cause trouble.

    Can't wait to see more of this system in action!

    giuliomoro: That is enormously helpful. Has the attached illustration got it right?

    bela_robert: Me neither! (Can't wait to see more.) There is a 20+ hours catalog of widely loved, heavily copyrighted music with brilliant choreography by the original laser show masters recently recovered from 1/4" 4 track reel to reel, preserved on hard disk and decoded courtesy of yours truly, and just waiting to be dropped into this multabela system for the first viewings in decades. This is the stuff that in 1970s through to the 1990s brought in sellout audiences to planetariums world wide. I'm incredibly fortunate to have been entrusted with this content, and I couldn't be doing much with it without bela.

    alt text

    Wow, incredibly fortunate indeed! What an incredible archive to be working with. Please do keep on posting updates as you go and we'd love to feature something about this project on the blog in the future.

    24 days later

    Here is the multabela harness, and one of two needed bela to ilda boards. I have to make a duplicate of the blue wire wrap board for the other two channels, and then the hardware component of the system will be complete.

    alt text

    9 days later

    Good luck! I'm looking forward to the result.

    12 days later

    I am trying to post a message and each time the following message is displayed:
    alt text

    I am having to post this message in parts to see where the problem is.

    This project is at the point where four belas need to be accessible as separate browser tabs. I need to assign the bela units individual ip addresses. I have reviewed the information here:

    https://learn.bela.io/using-bela/technical-explainers/ip-addresses/#using-multiple-bela-boards-at-the-same-time

    The relevant part seems to be: in order to change the IP address of the board, and still have it play well with the host, you have to make changes in at least two places: /etc/network/interfaces, to change the self-assigned address, and /etc/dhcp/dhcpd.conf to change the range of IP addresses given out by the DHCP server.

    but I am not clear on the details of the procedure including where to find /etc/network/interfaces and /etc/dhcp/dhcpd.conf. I am using a win10 system and a powered usb hub. Help would be appreciated.

    As well, the bela units, when first connected to the usb port cause an error message to be displayed. (screen captures attached) The message says scan the drive now and fix it. Is it advisable to scan the drive when the drive is a bela? The bela works fine if this message is ignored, and is found at address http://192.168.6.2/

    Using http://bela.local/ doesn't work.

    Many thanks for your help.