Hello Bela Devs!
I want to run my Faust code on Bela. I compiled it with the Faust online compiler, it gives me a binary to download called "BeagleRT". What to do with it? I tried to copy it to BELABOOT, but nothing happens, bela is still running the Bela code from the Bela IDE.
I tried to find information on the Internet but I could'n find anything, also not here in the forum and also not there: https://github.com/BelaPlatform/Bela/wiki/Compiling-Faust-code-for-Bela

I would be happy if somebody could explain me a quick and easy a way to run the "BeagleRT" binary from the Faust compiler on the Bela board. Thank you in advance!
The best, of course, would be to load it from the Bela IDE 🙂

All the best,

Vince

Hi,
I am afraid the Faust support has seen better days. What Bela image are you running? To know it, type cat /etc/motd in the console at the bottom of the Bela IDE.
If it is v 0.3 or above, the downloaded binary will not work. You should then go to the faust online compiler, download the full C++ source and compile it on Bela. Hopefully I put the necessary info at github.com/BelaPlatform/Bela/wiki : I am away from a computer for a few days and I would not be able to assist further just now. We have a work in progress faust to llvm to binary that should make the faust process more streamlined but that is not ready for release yet.

    Hey Guiliomoro,
    Thank you for your reply! As I can see my Bela image is 0.3.1, so it will not work. I'll wait for instructions on github.com/BelaPlatform/Bela/wiki. I know the Faust People personally, can I do something to accelereate the process on the Faust side?
    I'd like to help if I can! 🙂
    All the best,
    Vince

    7 days later

    We'll have a student working on Faust and Bela starting in may. Hopefully the Faust on Bela situation will improve then.

      sletz Oh that are great news!! Hopefully Faust will be back to bela in may/june 🙂 (I actually bought bela because of its faust capability). Thank you for all the efforts and good luck!
      all the best,
      Vincent

      2 months later

      giuliomoro

      Hi,
      I'm sorry, but I need more details. This README seems like it was written from one core Bela developer to another, but for a newcomer like me ... I tried to puzzle this out as best I could, but I hit a wall. When I load bela-faust-jit as a Bela project in the IDE, I get this error:

      "In file render.cpp: 'faust/dsp/llvm-dsp.h' file not found column: 10, line: 62".

      OTOH, running 'make' from a shell, as suggested in the README, does not work at all, because there is no Makefile in the project.

      I would update the instructions to be clear about these steps:

      • How should bela-faust-jit be installed on the Bela? IDE or shell? Where should the project live? (I logged in as root and used 'git clone' under /Bela/projects.)

      • How should libssl-dev, LLVM libraries & Faust be installed? I ran "apt-get install libssl-dev llvm faust", which seems reasonable. But it looks like the apt package for Faust is missing llvm-dsp.h, which I guess is why you suggest building the latest master from scratch. However, that build fails while building libcode.cpp ... with an internal g++ compiler error! Is there some other compiler, or makefile, or command that's supposed to be used here? Are there specific versions of Faust & Bela where this has been tested & is known to build successfully?

      • How should the bela-faust-jit project itself be built? IDE or shell? If we need to run make, then where's the Makefile?

      I'm trying to puzzle this out myself, but it's taking me all day & still not working ... please advise.

        mykle I'm sorry, but I need more details. This README seems like it was written from one core Bela developer to another,

        Even worse, it was written by me for myself! Below are your answers, I will update the README accordingly.
        Also, you probably need a fix to run with the latest FAUST. I think that just adding virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) {} inside class BelaUI : public UI would fix it.

        mykle How should bela-faust-jit be installed on the Bela? IDE or shell? Where should the project live? (I logged in as root and used 'git clone' under /Bela/projects.)

        It is a Bela project, so it should live in ~/Bela/projects/bela-faust-jit.

        mykle How should libssl-dev, LLVM libraries & Faust be installed? I ran "apt-get install libssl-dev llvm faust"

        libssl-dev and llvm-3.9-dev you can install with apt-get.

        The README says:

        compile and install the master branch of https://github.com/grame-cncm/faust

        that is how you are supposed to get faust: you need the latest version, which is more recent than the one you would get from apt-get.

        mykle OTOH, running 'make' from a shell, as suggested in the README, does not work at all, because there is no Makefile in the project.
        How should the bela-faust-jit project itself be built? IDE or shell? If we need to run make, then where's the Makefile?

        The README says:

        pass the following flags to make ...

        There is a box Make parameters in the Bela IDE's project settings to pass flags to make. If you were to compile from the terminal, you would do run make -C ~/Bela PROJECT=projectname and then add the CFLAGS="..." specified in the README.

        mykle I'm trying to puzzle this out myself, but it's taking me all day & still not working ... please advise.

        I am sorry about that, that project really is a work in progress with notes for myself. In fact:

        giuliomoro that is not ready for release yet.

        However, things became more interesting since someone managed to get the FAUST GUI to work, although they have basically discarded this render.cpp file and replaced it with a file from the FAUST source tree and this requires an additional step of compiling FAUST->C++: https://forum.bela.io/d/88-my-experience-with-faust-and-some-more-general-observations/54

        last, the README says:

        The above options are already set in the settings.json and will therefore be used automatically if you build and run this project from within the Bela IDE.

        Which in practice means that as long as you have the dependencies in place, if you put all these files in a Bela project, then you should be able to hit run from the IDE and it should work.

        5 days later

        Thanks, I do appreciate yr help.
        Faust compiled on the Bela the second time I tried, so hopefully the first failure was just some random memory failure or something. The standalone Faust compiler seems to work just fine, hooray.

        Now that I've built & installed Faust, and modified the bela architectural file, and installed those other RPMs, I'm stuck again. Here's me trying to build bela-faust-jit in a shell (tell me if I got the command right):

        cd Bela/projects/bela-faust-jit; make LDLIBS=-lfaust `llvm-config --ldflags --libs all --system-libs` -ltinfo -lssl -lcrypto
        make: invalid option -- '/'
        make: invalid option -- 'u'
        make: invalid option -- '/'
        Usage: make [options] [target] ...

        In the Bela UI, I get a console error when I try to build bela-faust-jit (I wonder if I modified bela.cpp correctly):

        variable type 'BelaUI' is an abstract class column: 8, line: 310

        And when I try to use 'faust2bela' in a shell on Bela, I get these errors (maybe just some missing build argument?):

        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/default_main.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/DigitalChannelManager.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/GPIOcontrol.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/I2c_Codec.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/I2c_TouchKey.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/Midi.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/OSCClient.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/OSCServer.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/PRU.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/PulseIn.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/RTAudioCommandLine.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/RTAudio.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/Scope.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/UdpClient.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/UdpServer.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/core/WriteFile.cpp: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/libprussdrv.a: No such file or directory
        arm-linux-gnueabihf-g++: error: /usr/local/beaglert/libNE10.a: No such file or directory

          OTOH, it looks like if I run 'faust -a bela.cpp myFaust.dsp' to generate myFaust.cpp, then the IDE can compile and run it! So I finally succeeded in running Faust on Bela.

          mykle And when I try to use 'faust2bela' in a shell on Bela, I get these errors (maybe just some missing build argument?):

          no idea if there is a build argument to set the path of the Bela source code: maybe that's just the hardcoded path they had on their build server. I guess you could ln -s /root/Bela/ /usr/local/beaglert/ however that still would not work because the Bela file structure has changed since, so there are more .cpp and .c files to build and the libraries are in Bela/lib/. Truth is that things have changed so much that you would not need to compile all those files at all really, because you could just #include <Bela.h>, passing -I/root/Bela/include to the compiler and then passing -lbela -L/root/Bela/libto the linker.

            giuliomoro
            Yeah, it looks like faust2bela is for Bela v0.2 only -- at least I assume that's what it's for. But build_project.sh works from my host computer to my v0.3 Bela, and it's accomplishing effectively the same thing. So I can probably take it apart & use it to build some v0.3 workflow into faust2bela .

            That makes me wonder: what's the preferred way to test/know the firmware image version of a Bela? It'd be great if faust2bela could detect what OS it's building for.

            bela-faust-jit is still not building tho. Do you have any advice for that BelaUI error?

              mykle cd Bela/projects/bela-faust-jit; make LDLIBS=-lfaust llvm-config --ldflags --libs all --system-libs -ltinfo -lssl -lcrypto
              make: invalid option -- '/'
              make: invalid option -- 'u'
              make: invalid option -- '/'
              Usage: make [options] [target] ...

              this is due to missing quotes " " around the LDLIBS arguments. it should be

              LDLIBS="-lfaust `llvm-config --ldflags --libs all --system-libs` -ltinfo -lssl -lcrypto"

              if you are using it from the command-line.

              mykle Bela v0.2 only -- at least I assume that's what it's for

              It's actually for an old version of the Bela core code. This same build would work even on an old v0.2 image with update core code.

              mykle That makes me wonder: what's the preferred way to test/know the firmware image version of a Bela? It'd be great if faust2bela could detect what OS it's building for.

              To test what image you are running on you can check out some of the checks in Bela/Makefile : https://github.com/BelaPlatform/Bela/blob/master/Makefile#L166-L176 , but again - as mentioned - this is mostly not relevant, as it only tells you half of the story. I have no idea what is in faust2bela (that was made by the FAUST people at the early stages of Bela).

              To test what version of Bela you have, you can check for these lines in Bela.h. They have been introduced only recently but they are the way forward to check for the version of the Bela core code currently installed.

              mykle bela-faust-jit is still not building tho. Do you have any advice for that BelaUI error?

              Let me see if I can give this a try.

              2 months later

              Hi,
              I'm the student that work on FAUST. As I understand, the current Faust2Bela don't works because the command line is obsolete.
              Instead of trying to rewrite it, does it make sense to call the Makefile ? (as the build_project.sh for example)

              Is faust2bela meant to generate the executable binary via an intermediate cpp file? If it is, then I suggest you use the Makefile, add another kind of project type (faust), detect the project type by searching for a _main.dsp file in the project folder. If the project type is faust, add a rule to generate projects/$(PROJECT)/faust-generated-render.cpp, which will have as a prerequisite the .dsp file. If this doesn't get generated early enoug in the Makefile (i.e.: before CPP_OBJS), then you will have to manually add the projects/$(PROJECT)/build/faust-generated-render.o to CXX_OBJS.

              However, one thing we want to try is to benchmark the faust->cpp->clang->binary workflow versus faust->llvmIR->binary, as the latter should be able to compile faster than the former.

              Maybe the above is just confusing: could you tell us more in details what you are planning to do?

              Hi,

              For this moment, I can create a render.cpp directly from a modified Faust2Bela script. I copy the content of this file into the BELA IDE, and run it.
              But it should be better (I think...) that the Faust2Bela script do all the job.

              (The use of BELA IDE, and not very complexe C++ code is ok for me, but I'm new in all bash scripts, console, Linux..etc. So I can do some misunderstanding...)

              I am not sure I understand what you need. Faust2Bela could generate a cpp file, put it in /root/Bela/projects/projectname and call

              make -C /root/Bela PROJECT=projectname

              this will compile the files in /root/Bela/projects/projectname, and generate an executable /root/Bela/projects/projectname/projectname