OK, I installed openssl, LLVM and faust on my Bela board. I also cloned the bela-faust-jit repository. And now , what? I can't see any Faust options in the IDE, so I'm lost here. Help (possibly step-by-step explanation) is appreciated.
My experience with Faust, and some more general observations
- Edited
The README says
at runtime, pass the name of the .dsp file as a command-line argument: --faust faust.dsp
this can be done from the IDE adding --faust faust.dsp
to the "custom command line options".
The included faust.dsp
script exemplifies how to access Bela's analog and digitals.
- Edited
OK. I copied render.cpp to the IDE and set the cmd line parameters. Result:
Building render.cpp...
Makefile:411: recipe for target '/root/Bela/projects/faust/build/render.o' failed
Build finished
variable type 'BelaUI' is an abstract class column: 8, line: 310
which is
...
dsp* fDSP;
BelaUI fUI;
bela_midi fMIDI;
MidiUI* fMidiUI;
...
/usr/local/include/faust/gui/UI.h:71:22: note: unimplemented pure virtual method 'addSoundfile' in 'BelaUI'
virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) = 0;
seems the code was too old to be compiled. Got the latest bela.cpp from git and now, this results:
/**************************BEGIN USER SECTION **************************/
<<includeIntrinsic>>
<<includeclass>>
/***************************END USER SECTION ***************************/
/*******************BEGIN ARCHITECTURE SECTION (part 2/2)***************/
std::list<GUI*> GUI::fGuiList;
ztimedmap GUI::gTimedZoneMap;
/**************************************************************************************
Bela render.cpp that calls FAUST generated code
***************************************************************************************/
unsigned int gNumBuffers = 0; // the number of de-interleaved buffers for audio and analog i/o
FAUSTFLOAT *gInputBuffers = NULL, *gOutputBuffers = NULL; //de-interleaved input/output buffers for the audio and analog inputs
FAUSTFLOAT* gFaustIns[10]; // array of pointers to gInputBuffer data
FAUSTFLOAT* gFaustOuts[10]; // array of pointers to gOutputBuffers data
mydsp fDSP;
Any idea, what's missing (sorry, I have no idea about faust infrastructure, because I can't get it to work neither offline or online).
- Edited
So I decided to compile faust.dsp
with faust and inserted the created cpp code into bela.cpp
(i.e. render.cpp
). Result now:
Building project...
Building render.cpp...
...done
Linking...
...done
Build finished
Running project...
/root/Bela/projects/faust/faust: unrecognized option '--faust'
Usage:
Am I missing something important here?
DragonSF Am I missing something important here?
if you compiled the FAUST-generated C++ code, then you would not be loading a .dsp file at runtime, therefore the --faust filename.dsp
option is not supported, but that options is probably still in your IDE settings and you should remove it.
DragonSF seems the code was too old to be compiled.
Perhaps just adding virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) {}
inside class BelaUI : public UI
would have fixed this (I got that by comparing with the bela.cpp file mentioned below)?
DragonSF Got the latest bela.cpp from git and now, this results:
I assume you mean this. This is a regular FAUST architecture file, that will not provide just-in-time compilation features, but should be suitable if you generate some C++ code with FAUST.
DragonSF Any idea, what's missing (sorry, I have no idea about faust infrastructure, because I can't get it to work neither offline or online).
What error do you get? The text you pasted seems to only be part of the source file?
- Edited
I have no problems with pre-compiled dsp code and to include that. But somehow the generated program doesn't run:
After some editing , copying session, I came to this point:
Building project...
Build finished
Running project...
Trying to parse FAUST file: (null)
Error: no audio callback defined. Make sure you set settings->render to point to your audio callback
Error: unable to initialise audio
Makefile:502: recipe for target 'runide' failed
make: *** [runide] Error 255
Bela stopped
I can't see any settings->render. Please advise.
Add
settings.setup = setup;
settings.render = render;
settings.cleanup = cleanup;
to your main()
function, similarly to what is done here https://github.com/BelaPlatform/Bela/blob/master/core/default_main.cpp#L45-L47
- Edited
After adding these lines:
settings.setup = setup;
settings.render = render;
settings.cleanup = cleanup;
to main.cpp, I got no error left, but also no sound. And no GUI. Do I need anything else?
I can hear, that the audio is switched on and off, but that's it.
Does this message mean anything: Trying to parse FAUST file: (null)
When I stop Bela:
Error in `/root/Bela/projects/nfaust/nfaust': corrupted size vs. prev_size: 0x00803840
Aborted
Makefile:502: recipe for target 'runide' failed
make: *** [runide] Error 134
Bela stopped
There is no GUI to be expected at the moment.
I have lost track of what your project folder looks like just now, so I can only guess as to why there is no sound. If you have a render()
function somewhere that looks like this, then it means that the problem is most likely in the FAUST code in use.
Maybe it requires some user input in order to generate sound?
looks like --faust is not an option for main.cpp (I'll look at that later).
DragonSF looks like --faust is not an option for main.cpp (I'll look at that later).
correct:
giuliomoro if you compiled the FAUST-generated C++ code, then you would not be loading a .dsp file at runtime, therefore the --faust filename.dsp option is not supported, but that options is probably still in your IDE settings and you should remove it.
- Edited
giuliomoro : yes, the flute example needs a GUI action. My folder (nfaust) is actually the same as your github folder. I replaced the main.cpp with the mentioned code and render.cpp with the bela.cpp code. In render.cpp I added $include "faust.,h", which contains the compiled faust.dsp code. That's it. If you want, I can upload the whole project. But without GUI, Faust is meaningless.
Any idea, what's the problem with the GUI is?
giuliomoro no, I have removed the setting.
FAUST on Bela is meant to run without GUI, using Bela's inputs as controllers.
These lines in the faust.dsp
file
freq = hslider("[1]Frequency[BELA:ANALOG_0]", 440,460,1500,1):smooth(0.999);
pressure = hslider("[2]Pressure[style:knob][BELA:ANALOG_4]", 0.96, 0.2, 2.0, 0.01):smooth(0.999):min(0.99):max(0.2);
mean (as far as I understand, as I know nothing about FAUST) that you can use either an hslider
or the Bela analog inputs in order to control freq
and pressure
. In fact here I am playing titanic on it using a breath sensors and a slider:
In the future there may be a GUI (e.g.: as an additional tab in the IDE), which would make tweaking parameters easier during prototyping, but ultimately, I think that the final objective of running some program on Bela is to run it embedded, controlled by the sensors.
Thanks for the advice. I neither do know anything about Faust programming, but I'm trying to learn. I could connect my BSP (which luckily has analog outputs) and get some sound. And also I solved the mystery with the Faust file as command options. Works now as expected.
And yes, a GUI would be awesome. If you need help with that, I'm willing to do whatever is necessary.
DragonSF And yes, a GUI would be awesome. If you need help with that, I'm willing to do whatever is necessary.
I think the steps needed here are to generate a web-based GUI and then serve it from a tab in the browser.
The faust playground can generate GUIs from FAUST code. I have no idea how that is done, but going through its source code you may find a way of generating the GUI and serve it as a page (either with a python server, as they do, or plugging into our node
server). Once that is done, the sliders on the GUI can be hooked up to send OSC messages to the running audio backend (perhaps similarly to what we did here with NexusUI).
I don't think this is easy or straightforward, but if you really have time to dig into this, then I think the above sums it up well. @sletz - who is one of the developers of FAUST - will have a better idea than I have on the subject.
Yes, I'll try to dig into that. Have enough time at the moment.
@sletz suggests:
We already have a « server a web-based GUI to the user » model. On server side we use libmicrohttpd (https://www.gnu.org/software/libmicrohttpd/) to have the Web server running, wrapping/controlling the running DSP, delivering a HTML + SVG + CSS page to the browser. Then messages are sent/received using HTTP requests (which is a bit heavy but works…) This could be a starting point, possibly using OSC an an alternate protocol later on.
You can see this HTML + SVG + CSS code used in another context here : http://faust.grame.fr/modules/. In this case we just generated static pages, but you can see the kind of UI we get.
- Edited
To activate HTTP UI control you will have to follow what is done in other architecture files, like : https://github.com/grame-cncm/faust/blob/master-dev/architecture/jack-qt.cpp
So adding in the bela.cpp template file:
#include "faust/gui/httpdUI.h"
httpdUI httpdinterface(name, fDSP.getNumInputs(), fDSP.getNumOutputs(), argc, argv);
fDSP.buildUserInterface(&httpdinterface);
...
httpdinterface.run();
Then you'll have to compile the code in faust source tree: /architecture/httpdlib and link also with libmicrohttpd (https://www.gnu.org/software/libmicrohttpd/)
Then starting the program will start a libmicrohttpd based server at http://127.0.0.1:5510, that should display the UI to control the DSP running on the Bela card.
A bit of work but not impossible...
- Edited
Do you mean render.cpp (instead of bela.cpp)?
I found a gem: if (p == '.' | p == ',') (really?) ;-)
So, I got the /root/faust/architecture/httpdlib/cmake/libHTTPDFaust.so, how do I have to link this to the bela project?
(I guess, I have to change the Makefile, but what will be the code for including the shared lib)?