Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Compiling Faust code for Bela
To be able to run Faust on Bela, you need to do some setup on your computer and on the Bela board. Faust generates some very large C++ files that may take forever (many minutes) to compile on the Bela board. It is therefore highly recommended that - before using Faust on Bela - you go through setting up
distcc to get cross-builds happening, offloading the compilation task to the host computer. This is explained here. However, this step is optional and for very small Faust projects you may be fine without it.
So, here we go:
PkgConfig. Install them with your favourite package manager / googling skills. On a Mac with
brew installed, it would be something like:
brew install cmake PkgConfig
Download Faust, checkout the latest known working version, build, install
git clone https://github.com/grame-cncm/faust.git &&\ git checkout 09ad59955eccb522382d60d58fb648e9b0fb4a78 &&\ cd faust &&\ make -j4 &&\ sudo make install
If you do want to set up the
distcc cross-compiling environment, optional but recommended (see above), follow the instructions here.
There is no compulsory step to do to prepare the board. There are two optional steps, both recommended:
- you may want to setup
distccto speed up builds (yes it's optional, but it's the third time we recommend it, so please do it!), see notes above and follow the instructions here if you are interested.
- install a library on the board that will allow you to interact with the Faust GUI in the browser:
Install the libraries for the Faust GUI
- download this file, a pre-compiled version of the http library that comes with Faust
unzip libHTTPDFaust.zip scp libHTTPDFaust.so* libHTTPDFaust.a firstname.lastname@example.org:/usr/local/lib/
libmicrohttpd-dev on the board:
- connect the board to the internet and run
apt-get install libmicrohttpd-dev
Great, at this point all should be done and ready to go.
On the host, go into
faust/examples/bela and run:
faust2bela -tobela simpleFX_Analog.dsp
this should build and run the project. (If it takes forever to build, maybe it's about time you consider setting up distcc, as "suggested" above.) Plug some signal into your Bela and you will hear it processed through drive, flanger, reverb! Bela's analog inputs will be controlling some of the parameters.
Now, if you did the optional step of installing the library for the GUI, you can repeat the above but with the
faust2bela -tobela -gui simpleFX_Analog.dsp
Then find the GUI at http://192.168.7.2:5510 . Some of the parameters displayed are controlled by Bela's analog inputs, and cannot be modified through the GUI. The others can be controlled in real-time through the GUI. Here is an example of what a Faust GUI looks like:
If you are looking into using external MIDI devices, you will need to pass the
-midi -nvoices option, as per regular Faust, e.g.:
faust2bela -tobela -midi -nvoices 4 -gui /path/to/faust/file.dsp
Learn all about Faust:
Interfacing with Bela's analog and digital pins
To interface Bela's analog and digital inputs, you need to edit the labels to follow the naming scheme:
freq = hslider("Frequency[BELA:ANALOG_0]", 440 ,460, 1500, 1) :smooth(0.999); pressure = hslider("Pressure[style:knob][BELA:ANALOG_4]", 0.96, 0.2, 2.0, 0.01) :smooth(0.999):min(0.99):max(0.2); gate = hslider("ON/OFF (ASR Envelope)[BELA:DIGITAL_0]",0,0,1,1);
See also this dsp file as an example.
An alternative, probably not working, discouraged, convoluted way of doing things:
This is a bit more convoluted and requires installing and compiling
faust on your board and using a special Bela project. Follow the instructions here: https://github.com/giuliomoro/bela-faust-jit