faustgen~ : LLVM powered Faust embedded compiler as an external for Max/MSP

Nov 16, 2012 at 4:45pm

faustgen~ : LLVM powered Faust embedded compiler as an external for Max/MSP

Thanks to the awesome LLVM technology (http://llvm.org/) combined with “libfaust”, the new library version of the Faust compiler, Faust DSP programs can now directly be compiled and executed on the fly at full speed. The Faust DSP source, compiled by libfaust using the LLVM backend, produces an intermediate representation (as LLVM IR : http://llvm.org/docs/LangRef.html), to be compiled and executed as native machine code directly in memory (using LLVM JIT technology). The LLVM IR can itself be optimized (using “optimization passes” in LLVM terminology), and the JIT component can be configurated to produce the best possibly native machine code.

This compilation chain has been experimented in faustgen~, an external for Max/MSP. Faustgen~ allows to easily use Faust source code inside a Max/MSP patcher, edit it, change compilation options, and even produce the processor flow chart as an SVG diagram. Preliminary tests show that the resulting native code runs at speed comparable to what the previous static compilation model was achieving.

A package containing the faustgen~external as well as faustgen~.maxhelp file, can be downloaded on the Faust site here:


Nov 16, 2012 at 8:24pm

as far as i am concerned, this is a major moment in computer dsp processing, let alone in max. as big as gen~. congratulations. i’d heard this was on the cards, and quite awesome it has appeared so quickly. i’ll be getting stuck in as soon as possible. thanks.

Nov 16, 2012 at 9:56pm

Indeed. I knew this was coming, but that fast !…

Nov 16, 2012 at 11:37pm

great stuff! but obviously OsX only :-(
can we expect a Windows version?

Nov 17, 2012 at 7:20am

Concerning Windows version, we had problems with “dynamic” inlets/outlets (the faustgen~ object has to change the number of ins/outs when the DSP source is changed). This was just crashing on Windows when we tried.

Nov 17, 2012 at 8:46am

thanks for the info sletz.
couldn’t this bug be addressed by cycling74 ?
Could be a Max6 bug related to windows only?

Nov 17, 2012 at 11:06am

very cool. I notice that when I double click a faustgen~ object the menu always seems to appear in the same place on the screen, far from my cursor. Could I suggest a usability improvement? I think that double click should just opens the “DSP code” text editor, which is how other max objects with text editors work. The other options are probably used less and could be accessed by sending messages to the object.

Nov 20, 2012 at 9:56am

hi sletz.
could be a bug solving problem for cycling74?
i think that dynamic changing of inlets and outlets seems a problem for Max ( if it works on Mac should work on Windows to i guess? )

Nov 20, 2012 at 10:16am

Cycling74 (thanks for them!) send us some code that should work on Windows also.

Nov 20, 2012 at 11:30am

thanks sletz and cycling74 !
i’ll patiently wait for a win release to test!

Nov 20, 2012 at 2:34pm

Go Stéphane, go! (Stéphane is the brains behind Jack on OS X and Windows, FYI).

Great work. The Faust stuff is really cool, and having it available directly within Max is a big win. Will check it out ASAP!

Nov 20, 2012 at 5:12pm
Nov 20, 2012 at 5:35pm

thanks sletz!
is the new version compiled for Windows to ?

Nov 20, 2012 at 6:04pm

is there such thing as a changelog ?

Nov 20, 2012 at 9:54pm

file ‘Install faustgen~.rtf’ inside the folder.


Nov 20, 2012 at 10:55pm

obviously. i was stupid. thanks

Nov 26, 2012 at 11:43am

hi stephane!
any progress on a windows version for faustgen~?
thanks and all the best

Nov 27, 2012 at 10:20pm

Windows version for faustgen~ : in progress…

Nov 27, 2012 at 11:46pm

great! thanks stephane for the info.

Dec 3, 2012 at 5:11pm

Version 0.81b available with faustgen~ for Windows. Please test and report.

Dec 3, 2012 at 6:59pm

Stéphane se développe à pas de loup, et nous en musique assistée par ordinateur sont tous profondément dans sa dette!

Merci, Stéphane.

Dec 3, 2012 at 11:47pm

great ! thanks Stephane! did a quick test. everything seems to work except opening the block diagram file. do we need to have othe faust stuff for it to be open. When i try i have a kindo of “program not found ” error. in a couple of days i’ll run more detailed tests.

Dec 4, 2012 at 7:43am

Opening SVG (dynamically generated) or PDF (documentation) or even text files (for Faust libraries), is currently done by launching a command to open the given file. It means an application has to be associated with the file. SVG files are supposed to be displayed by a browser (like Firefox, Chrome….)

Dec 4, 2012 at 10:10am

i’ll try to do the file association manually. but i suspect that the shell command given by the faustgen~ external is not correct. i’ll do a test in a couple of hours and report back right away. thanks for info stephane!

Dec 4, 2012 at 11:35am

Here is the kind of command that is done: “start /b file:///E:/faustgen-111-svg/process.svg”

Please report if you know a better/safer way to do.

Dec 4, 2012 at 1:12pm

hi stephane,
these are the error that i have trying to open the SVG and the PDF files from doubleclicking on faustgen~.
I have the same error as the PDF one while trying to view libraries. But the error is repeated several times.

[attachment=209735,4716] [attachment=209735,4717]

  1. pdferror.png
Dec 4, 2012 at 2:33pm

Well, those look suspisiously like the “Spaces in path passed to unix style commandline” error. Since the default win path to Cycling74 is in C:Program Files ( with a space), perhaps a whitespace escape should be applied to path before sending it to commandline call?

just guessin’… if that’s it, oh, those win/*nix differences…how annoying.


Dec 4, 2012 at 3:24pm

1) Have you correctly copied the “faustgen-resources” folder along with the faustgen~.mxe object? (as explained in the “Install faustgen~.rtf” file)

2) SVG files (actually inside a folder) will be dynamically generated in this “faustgen-resources” folder : can you see them?

Dec 4, 2012 at 4:14pm

“Stéphane se développe à pas de loup, et nous en musique assistée par ordinateur sont tous profondément dans sa dette!”

Hum the (automatic ??) french translation smells like “poetry” ((-; what was the original sentence?

Dec 4, 2012 at 8:59pm

“à pas de loup” = “with wolf’s steps”…a phrase my ancient parisian french teacher taught some 35+ years ago, with the implied meaning of great rapidity, of a almost scary sort….soooo….. “Stephane develops at a remarkably speedy pace, and all of us in the computer music community are deeply in his debt.”
just trying to be supportive in a grandiose , perhaps even amusing way…

*clunk*, …hmmm…k, ‘nother lose…:,-(…

good work, keep it up, Stephane…

Dec 4, 2012 at 11:31pm

Hi Stephane,
yes i do have the faustgen-resources folder in the msp-externals one.
Since i am on Windows 7 64 bit the default location of my Max 6.0.8 install is
C:Program Files (x86)Cycling ’74Max 6.0
so the faustgen-resource folder is
C:Program Files (x86)Cycling ’74Max 6.0Cycling ’74msp-externalsfaustgen-resources

when i try to view the svg files i get the error but two folders are created containing the svg files that i can actually open with Chrome.

Dec 5, 2012 at 7:38am


A pas de loup / on tiptoe.

“Stéphane développe à un rythme remarquablement rapide, et dans la communauté informatique musicale chacun d’entre nous lui en est grandement redevable.”

The google translation is pretty efficient but i like to use sometimes http://www.linguee.fr/ to confirm the meaning.

Anyway Charles, your sentence was as understandable as mine in english, and greatly poetic ;-)

Dec 5, 2012 at 12:37pm
Dec 5, 2012 at 1:11pm

thanks stephane!
now svg and pdf works perfectly.
what’s in the .lib files and with wich app is good to open those ?

Dec 5, 2012 at 1:15pm

The “.lib” are the Faust libraries: those are simply text files.

Dec 5, 2012 at 1:20pm

are those supposed to be open the same way we open the code to be edited with “Edit DSP code” ?

Dec 5, 2012 at 1:28pm

i mean….wouldn’t be nice to have another line similar to “max fileformat .dsp TEXT 0 “Faust DSP language file” dspfile;” for the .lib files to be open ?

Dec 5, 2012 at 1:31pm

nahh.. ’cause they aren’t not to be edited…sorry for the stupid things i said above :-)

Dec 5, 2012 at 1:36pm

a question about the web-compiler.
Stephane, do you think we can have SuperCollider Ugen and Csound opcode compilation on Windows ?

Dec 5, 2012 at 1:46pm

And since my curiosity is piqued: those strangely truncated paths in the error popups? Symptom of path string issue, or something else? ( I only ask since debugging other developer’s code is my major daily activity…at least recently, :) ). And RE: “on tiptoe”: this explains why my memory of the meaning of the phrase involving fear…the 15y.o. Charlie was deeply impressed with the large number of odd phrases she (my ancient teacher,the only formal contact w/ the language I ever had ) used involving the wolf as metaphor…which is why I tried to use the expression: it seemed the ‘most fun’ of the idiomatic translations I looked up, and I recalled her treasure trove of wolf idioms: they seemed so strange and interesting at the time. thanks again for your “awesome” coding efforts!

Dec 5, 2012 at 2:44pm

1) We know use coding like : start “” “file:///E:/faustgen-111-svg/process.svg” (because start command requite a “title”)

2) “do you think we can have SuperCollider Ugen and Csound opcode compilation on Windows ?” ==> possibly at on point in the future..

Dec 5, 2012 at 3:33pm

thanks Stephane.
I see in the quick start .pdf that at page 47 table 5.2 reports SC Ugens and Csound opcodes as available audio architecture on Windows.
So are they implemented in Faust ( i.e. FaustWorks ) but not in the online compiler ?
many thanks for your great coding effort and infos!

Jan 4, 2013 at 4:09pm

We are happy to announce the first distribution of Max/MSP oriented FAUST examples, by Christophe Lebreton, © GRAME http://www.grame.fr

Get them here : maxmsp_faust_examples_v1.zip file at https://sourceforge.net/projects/faudiostream/files/

Mar 11, 2013 at 11:20pm

New 0.83b version at https://sourceforge.net/projects/faudiostream/files/

- 09/03/2013 : Version 0.83b : add “write” message to save DSP in external files
- possibly fix for LLVM related bugs

Mar 15, 2013 at 10:15am

New 0.84b version at https://sourceforge.net/projects/faudiostream/files/

15/03/2013 : Version 0.84b : crashing bug correction in LLVM code generation

Mar 15, 2013 at 2:20pm

hi stephane,
on sourceforge there is still the 0.83b version. and no 0.84b.
thanks for your great work!

Mar 15, 2013 at 2:52pm

New 0.85b version at https://sourceforge.net/projects/faudiostream/files/

15/03/2013 : Version 0.85b : memory management corrections in LLVM code generation

(still 32 bits only for now… version 64/32bits to be used with latest Max/MSP 6.1 in test)

Mar 15, 2013 at 3:18pm


Apr 5, 2013 at 5:05pm

New 0.86b version at https://sourceforge.net/projects/faudiostream/files/

- 04/05/2013 : Version 0.86b : fix recursion limitation bug in Faust

(still 32 bits only for now… version 64/32bits to be used with latest Max/MSP 6.1 in test)

Apr 17, 2013 at 1:59pm

great ! this faust language is so powerful !

I have a question… is it possible to dynamically change the number of processors in the resonator example ? like with the CNMAT resonator ?
it would be very nice, or at least being able to selectively mute some processors…
thank you.

May 6, 2013 at 1:15pm

New 0.87b version at https://sourceforge.net/projects/faudiostream/files/

- 06/05/2013 : memory management correction in Faust. New “write” message to save DSP files. 64/32 bits version on OSX.

Nov 6, 2013 at 12:47pm

Does anyone know whether faustgen~ works with Max4Live? Does it need gen~? Cheers!

Nov 6, 2013 at 12:56pm

Nevermind. The answers are “yes, it does work in Max4Live” (I had to restart a couple times before it would show up), “No, it does not require gen~” :)

Nov 7, 2013 at 1:46am

Hi. I’m a bit confused about the *.lib files. There is a subfolder in the Windows installation folder which contains a few, but no mention in the installation instructions. I’m on a mac and the “imports” don’t seem to be complaining about their absence. Are they embedded in the faustgen mxo file?

I’m trying to add one from the stk-faust lib. Does it just need to go in the PATH somewhere?


Nov 7, 2013 at 3:20am

Also is there a reference anywhere for those included libs?

Nov 8, 2013 at 8:50am

On OSX, Faust libraries files are located in the mxo file, in Contents/Resources folder. You can possibly add you own files here. We’ll probably improve the libraries files location system in a future version.

Nov 8, 2013 at 10:53am

Thanks. I ended up adding the stk port in an “stk/” subfolder. Then I can just simple do import(“stk/instrument.lib”) etc…

Many thanks for this @sletz. It is awesome…I’m so excited! Working on a synthesiser version of my iOS app (soundwandapp.com) and this will help things considerably…

Nov 25, 2013 at 7:50am

I’m having some trouble with inputs into faustgen. It seems that sliders/flonums/live.dial’s messaged to input parameters aren’t translating correctly. Even the with faustgen help file, with the “gain” example, as you scroll through values, it seems to toggle gain between 0 and 1 judging by the meter. If you type entries in manually some map to 1 and others to 0. Has anyone else experienced this?

Dec 6, 2013 at 4:57pm


First off, great external, a good entryway to faust.

Second, I’m also trying to use the faust-stk, like Harikaram. I’ve put the instrument.lib in Contents/Resources, but am running into a problem. faustgen~ crashes Max everytime I try to load a function which relies on the ffunction() call, such as modalBar.dsp.

Max: “read modalbar.dsp”
program crashes
console log reads

12/6/13 4:45:14 PM Max[3100] Max: db update complete
12/6/13 4:46:33 PM [0x0-0x72072].com.cycling74.Max[3100] LLVM ERROR: Program used external function ‘readMarmstk1′ which could not be resolved!
12/6/13 4:46:33 PM [0x0-0x72072].com.cycling74.Max[3100] StartNotification name = default
12/6/13 4:46:33 PM com.apple.launchd.peruser.501[118] ([0x0-0x72072].com.cycling74.Max[3100]) Exited with exit code: 1

call from instrument.lib is:
“readMarmstk1 = ffunction(float readMarmstk1 (int), ,”");”

and “readMarmstk1″ is a cpp function in instrument.h which I’ve added to the same folder.

Any idea why this isn’t working?

Jan 20, 2014 at 5:45am

Yes, linking to code defined in external .h or .c or .cpp files is not currently supported. This would require faustgen~ to “embed” the entire C/C++ ==> LLVM IR ==> executable machine code compilation chain. Note that supporting arbitrary C/C++ code compilation could indeed become rapidly tricky. In the case of STK instruments, C headers files are currently used to access parameters tables. This may be doable directly in Faust with the new “waveform” syntax that now allows to define data tables directly in the .dsp source. We’ll have to update faustgen~ to use this new “waveform” syntax.

Apr 18, 2014 at 4:02pm

How are you supposed to get the samplerate inside faustgen? if i use the SR constant it is wrong (allways 44100)


You must be logged in to reply to this topic.