faust icon indicating copy to clipboard operation
faust copied to clipboard

Compiling with int's

Open matias-levy opened this issue 4 years ago • 3 comments

Hi! I'm trying to make some test of faust on microcontrollers that don't have a FPU, i was wondering if there was anyway to compile the faust code using int's, or to modify the code afterwards. Would something like defining FAUSTFLOAT uint16_t work? I imagine it would be more complex and maybe converting a lot of things manually, but I have no idea. This paper shows how they did some experiments on the Teensy 3.2 which doesn't have a FPU unit and manage to, quote, "by hand" re-write the compiled code to use fixed point without changing the original FAUST DSP file. However, they don't go into details on the changes they performed. Does anybody know?

matias-levy avatar Jul 10 '21 15:07 matias-levy

You can possibly use the -fx (fixed-point) option that will use the fixpoint_t type for samples. Then add a proper definition forfixpoint_t and associated arithmetic, like showed in a limited way in https://github.com/grame-cncm/faust/blob/master-dev/architecture/minimal-fixed-point.cpp architecture file. Then use faust -a minimal-fixed-point.cpp -fx foo.dsp to generate a C++ file.

sletz avatar Jul 11 '21 11:07 sletz

You can possibly use the -fx (fixed-point) option that will use the fixpoint_t type for samples. Then add a proper definition forfixpoint_t and associated arithmetic, like showed in a limited way in https://github.com/grame-cncm/faust/blob/master-dev/architecture/minimal-fixed-point.cpp architecture file. Then use faust -a minimal-fixed-point.cpp -fx foo.dsp to generate a C++ file.

In that case should I create the file "ap_fixed.h"? Also, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs in compute: being floats wouldn't pose a problem?

matias-levy avatar Jul 12 '21 14:07 matias-levy

  • minimal-fixed-point.cpp file is given as an example, you'll have make a new version for you use case and adapt it
  • you'll have to define FAUSTFLOAT in your adapted architecture file. Read https://faustdoc.grame.fr/manual/architectures/ for a general info

sletz avatar Jul 12 '21 14:07 sletz