-
-
Notifications
You must be signed in to change notification settings - Fork 244
Faust
Faust (Functional Audio Stream) is a functional programming language for sound synthesis and audio processing. The core component of Faust is its compiler. It allows to "translate" any Faust digital signal processing (DSP) specification to a wide range of non-domain specific languages such as C++, C, LLVM bit code, WebAssembly, Rust, etc.
We use Faust to generate a C++ file that we can include in our Arduino sketch.
The following scenarios are supported:
- Faust generates output sound (see the noise example)
- Faust uses input sound to generate the output result (see the guitarix example)
- Open the web IDE and write or load your Faust Program.
- Click on the Export button (the one with the Truck!)
- In Platform select source
- In Architecture select cplusplus
- Click on Compile
- Clock on Download
- Rename the generated cpp file to .h and move it to the Arduino Sketch Directory
You can generate the C++ code with the help of the command line.
- Install the Faust Compiler (https://faust.grame.fr/downloads/
- Now you can compile a dsp file into a h file with
faust filename.dsp -o filename.h
The RAM of the microcontrollers is limited and Faust sometimes generates code which does not fit into the available RAM. The ESP32 AudioKit and ESP32 WROVER modules have PSRAM that can be used instead. In order to use PSRAM we need to use the Faust memory manager. An example how to do this can be found in streams-faust_flute_i2s!
In this case we need to use the -mem option when we compile the sketch to cpp code:
faust -mem fluteMIDI.dsp -o fluteMIDI.h
Don't forget to activate the PSRAM in the Arduino Tools menu and you need to start the sketch with a
#define USE_MEMORY_MANAGER
Before the #include statements!