16 Faust
Phil Schatzmann edited this page 2024-05-17 22:03:20 +02:00

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:

Using the Online WEB IDE

  • 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

Using Faust Command Line

You can generate the C++ code with the help of the command line.

faust filename.dsp -o filename.h

ESP32 and PSRAM

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!

Examples

see here