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:
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.
Indeed. I knew this was coming, but that fast !…
great stuff! but obviously OsX only :-(
can we expect a Windows version?
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.
thanks for the info sletz.
couldn’t this bug be addressed by cycling74 ?
Could be a Max6 bug related to windows only?
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.
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? )
Cycling74 (thanks for them!) send us some code that should work on Windows also.
thanks sletz and cycling74 !
i’ll patiently wait for a win release to test!
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!
New 0.80b version here : https://sourceforge.net/projects/faudiostream/files/
is the new version compiled for Windows to ?
is there such thing as a changelog ?
file ‘Install faustgen~.rtf’ inside the folder.
obviously. i was stupid. thanks
any progress on a windows version for faustgen~?
thanks and all the best
Windows version for faustgen~ : in progress…
great! thanks stephane for the info.
Version 0.81b available with faustgen~ for Windows. Please test and report.
Stéphane se développe à pas de loup, et nous en musique assistée par ordinateur sont tous profondément dans sa dette!
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.
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….)
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!
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.
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.
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.
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?
"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?
"à 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…
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.
Version 0.82b to test at https://sourceforge.net/projects/faudiostream/files/
now svg and pdf works perfectly.
what’s in the .lib files and with wich app is good to open those ?
The ".lib" are the Faust libraries: those are simply text files.
are those supposed to be open the same way we open the code to be edited with "Edit DSP code" ?
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 ?
nahh.. ’cause they aren’t not to be edited…sorry for the stupid things i said above :-)
a question about the web-compiler.
Stephane, do you think we can have SuperCollider Ugen and Csound opcode compilation on Windows ?
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!
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..
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!
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/
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
New 0.84b version at https://sourceforge.net/projects/faudiostream/files/
15/03/2013 : Version 0.84b : crashing bug correction in LLVM code generation
on sourceforge there is still the 0.83b version. and no 0.84b.
thanks for your great work!
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)
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)
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…
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.
Does anyone know whether faustgen~ works with Max4Live? Does it need gen~? Cheers!
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~" :)
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?
Also is there a reference anywhere for those included libs?
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.
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…
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?
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"
console log reads
12/6/13 4:45:14 PM Max Max: db update complete
12/6/13 4:46:33 PM [0x0-0x72072].com.cycling74.Max LLVM ERROR: Program used external function ‘readMarmstk1′ which could not be resolved!
12/6/13 4:46:33 PM [0x0-0x72072].com.cycling74.Max StartNotification name = default
12/6/13 4:46:33 PM com.apple.launchd.peruser.501 ([0x0-0x72072].com.cycling74.Max) 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?
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.
How are you supposed to get the samplerate inside faustgen? if i use the SR constant it is wrong (allways 44100)
Thanks for all of your help on this wonderful project. I can tell that you put in a lot of hard work, and it works like a charm in OS X!
One of my students would like to use faustgen~ with Windows, so I’m trying to figure out what the situation is. It seems that the faustgen v0.87 archive only contains a 32-bit version, so I went back and installed the 32-bit version of Max 6.1.8 for Windows. Then I was able to instantiate the faustgen~ object. However, when I don’t think that it’s finding the lib files. I get the error "Unable to open file math.lib" when I try to compile a simple DSP file using it.
I tried having the lib files in the same directory as the currently open patch, adding the directory of lib files to the Max path, and directly putting them inside the msp-externals directory. Still it doesn’t find the lib files.
PS. Also there is the error "Cannot read "version" key, so ignore bitcode, force recompilation and use default compileoptions.
@Edgar I’m on a mac but I had to place them inside of the faustgen~.mxo "package" (an app on a mac is usually a folder which looks like a file until you choose "Show package contents"). I’m not sure how it’s structured on the PC but basically I’d guess you need them in the same path as the faustgen~ executable.
Forums > MaxMSP