FAUST (programming language): Difference between revisions

Content deleted Content added
Add category
 
(36 intermediate revisions by 29 users not shown)
Line 1:
{{Short description|Audio programming language}}
{{Colloquial|date=September 2012}}
{{redirect|FAUST|other uses|Faust (disambiguation){{!}}Faust}}
{{NoMore footnotes needed|date=March 2015}}
{{Infobox software
| name = FAUST
| developer = GRAME, Centre National de Création Musicale
| author = Yann Orlarey, Dominique Fober, Stéphane Letz
| released = {{releasestart date|2002}}
| latest release version = 02.960.673<ref>[https://github.com/grame-cncm/faust/releases Releases · grame-cncm/faust · GitHub]</ref>
| latest release date = {{releasestart date|20142023|0506|1914}}
| operating system = [[Linux]], [[Mac OS X]], [[Microsoft Windows|Windows]], [[Unix]]
| genre = Functional programming language for audio signal processing
| repo = {{URL|https://github.com/grame-cncm/faust/}}
| programming language = [[C++]]
| license = [[GNU General Public License|GPL]]
| website = http://{{URL|faust.grame.fr/}}
}}
{{Portal|Free and open-source software}}
 
'''FAUST''' (Functional AUdio STream) is a [[Domain ___domain-specific language|___domain-specific]] [[purely functional programming|purely functional]] [[programming language]] for implementing [[signal processing]] [[algorithms]] in the form of [[libraryLibrary (computing)|libraries]], [[audio plug-ins]], or standalone applications. A FAUST program denotes a signal processor: a mathematical function that is applied to some input signal and then fed out.
 
==Overview==
The FAUST [[programming model]] combines a ''[[functional programming]] approach'' with a ''[[block- diagram]] syntax'':
* The functional programming approach provides a natural framework for [[signal processing]]. Digital signals are modeled as [[Sequence|discrete functions]] of time, signal processors as [[Higher-order function|second order functions]] that operate on them, and FAUST’sFAUST's block- diagram ''composition operators'', used to combine signal processors together, as third order functions, etc. .
* Block- diagrams, even if purely textual likeas in FAUST, promote a modular approach ofto signal processing that suitscomplies very well thewith sound engineers’engineers' and audio developers’developers' habits, while providing a powerful and expressive syntax.
A FAUST program doesn’tdoesn't describe a sound or a group of sounds, but a ''[[Digital signal processing|signal processor'', something that transforms input signals and produces output signals]]. The program source is organized as a set of ''definitions'' with at least the definition of the keyword <code>process</code> (the equivalent of <code>main</code> in C):
<sourcesyntaxhighlight lang=cpphaskell>
process = ...;
</syntaxhighlight>
</source>
 
The FAUST [[compiler]] translates FAUST programscode into equivalenta [[C++]] programs[[Object-oriented takingprogramming|object]], carewhich ofmay generatingthen the most efficient code. The result can generally competeinterface with, andother sometimes even outperform, [[C++]] code writtento produce bya seasonedfull programmersprogram.
 
The generated code works at the sample level. It is therefore suited to implement low-level [[Digital signal processing|DSP]] functions like [[Infinite impulse response|recursive filters]]. Moreover theThe code canmay also be easily[[Embedded software|embedded]]. It is self-contained and does not depend on any DSP library or [[runtime system]]. It has a very deterministic behaviourbehavior and a constant memory footprintsize.
 
The semanticsemantics of FAUST is driven to be simple and well -defined. This is not just of academic interest. It allows the FAUST compiler to be ''semantically driven''. Instead of compiling a program literally, it compiles the mathematical function it denotes. This feature is useful for example tomay promote componentscomponent reuse while preserving optimal performance. Moreover, having access to the exact semantics of a FAUST program can simplify preservation issues.
 
FAUST is a textual language but nevertheless block- diagram oriented. It actually combines two approaches: [[functional programming]] and algebraic [[block-diagrams. Thediagram]]s, keywhich ideaare isconstructed to view block-diagram construction asvia [[function composition]]. For that, FAUST relies on a ''block- diagram algebra'' of five composition operations.
 
==Example Codecode==
FAUST programs define a <code>process</code> function that operates on incoming data. This is analogous to the <code>main</code> function in most programming languages. The following is an example that produces silence:
<sourcesyntaxhighlight lang="haskell">
process = 0;
</syntaxhighlight>
</source>
The second example copies the input signal to the output signal. It involves the <code>_</code> primitive that denotes the [[identity function]] onfor signals:
<sourcesyntaxhighlight lang="haskell">
process = _;
</syntaxhighlight>
</source>
Another example convertssums a two-channel stereo signal into a one-channel mono signal using the <code>+</code> primitive that adds two signals together:
<sourcesyntaxhighlight lang="haskell">
process = +;
</syntaxhighlight>
</source>
[[File:Faust-simple-block-diagram.jpg|thumb|Block- diagrams generated by Faust from some simple programs]]
Most FAUST primitives are analogous to their C counterpart on numbers, but lifted to signals. For example, the FAUST primitive <code>sin</code> operates on a signal X by applying the [[C (Programmingprogramming Languagelanguage)|C]] function <code>sin</code> to each sample X[t]. All C numerical functions have their counterpart in FAUST.
Some [[signal processing]] primitives are specific to FAUST. For example, the delay operator <code>@</code> takes two input signals: X (the signal to be delayed) and D (the delay to be applied), and produces an output signal Y such that Y(t) = X(t − D(t)).
 
==Block- diagram composition==
Contrary to [[Max (software)|Max-like]] [[visual programming languages]] where the user does manual connections, FAUST primitives are assembled in [[block diagram]]s by using a set of high-level block diagram [[Function composition|composition]] operations.
 
[[File:Faust-simple-block-diagrams.jpg|thumb|upright=1.75|Simple examples of block- diagram composition]]
 
{| class="wikitable"
|+ The block- diagram ''composition operators'' used in FAUST
| f~g || Recursive composition (precedence 4)
|-
Line 70 ⟶ 72:
 
Using the sequential composition operator <code>:</code> the output of <code>+</code> can be routed to the input of <code>abs</code> to compute the [[absolute value]] of the signal:
<sourcesyntaxhighlight lang="haskell">
process = + : abs;
</syntaxhighlight>
</source>
Here is an example of parallel composition using the <code>,</code> operator that arranges its left and right expressions in parallel. This is analogous to a stereo cable.
<sourcesyntaxhighlight lang="haskell">
process = _,_;
</syntaxhighlight>
</source>
These operators can be arbitrarily combined arbitrarily. The following code multiplies an input signal with 0.5:
<sourcesyntaxhighlight lang="haskell">
process = _,0.5 : *;
</syntaxhighlight>
</source>
The above may be rewritten in [[currying|curried]] form:
<sourcesyntaxhighlight lang="haskell">
process = *(0.5);
</syntaxhighlight>
</source>
The recursive composition operator <code>~</code> can be used to create block- diagrams with cycles (that include an implicit one-sample delay). Here is an example of an integrator that takes an input signal X and computes an output signal Y such that Y(t) = X(t) + Y(t−1):
<sourcesyntaxhighlight lang=haskell>
process = + ~ _;
</syntaxhighlight>
</source>
 
==Generating full applications==
==Full applications generation==
Using specific ''architecture files'', a FAUST program can be used to produce code for a variety of platforms and plug-in formats. These architecture files act as wrappers and describe the interactions with the host audio and GUI system. Currently{{As of|2021}}, more than 1030 architectures are supported and new ones may be implemented by anyone.
 
[[File:Faust-mixer-jackqt.jpg|thumb|Screenshot of mixer.dsp (available in the FAUST distribution) using the jack-qt architecture]]
Line 97 ⟶ 99:
{| class="wikitable"
|+ Some architecture files available for FAUST
! File
| alsa-gtk.cpp || ALSA application + GTK
! Architecture
|-
| alsa-qtgtk.cpp || ALSA application + QT4[[GTK]]
|-
| alsa-gtkqt.cpp || ALSA application + GTK[[Qt (software)|Qt]] 4
|-
| android.cpp || Android applications
Line 105 ⟶ 110:
| au.cpp || Audio Unit plug-in
|-
| ca-qt.cpp || CoreAudio application + QT4Qt 4
|-
| ios-coreaudio.cpp || iPhone and iPad applications
Line 111 ⟶ 116:
| jack-gtk.cpp || JACK application + GTK
|-
| jack-qt.cpp || JACK application + QT4Qt 4
|-
| ladspa.cpp || LADSPA plug-in
Line 117 ⟶ 122:
| max-msp.cpp || Max MSP plug-in
|-
| pd.cpp || PuredataPure Data plug-in
|-
| q.cpp || Q language plug-in
|-
| supercollider.cpp || SupercolliderSuperCollider plug-in
|-
| vst.cpp || VST plug-in
Line 130 ⟶ 135:
|}
 
==Generating block diagrams==
==Block-diagram generation==
A useful option makes it possible to generatesgenerate the block diagram representation of the program as one or more SVG graphic files.
It is interesting to note the difference between the block diagram and the generated C++ code.
As already said, the key idea here is not to compile the block diagram literally, but the mathematical function it denotes. Modern C/C++ compilers too don’t compile programs literally. But because of the complex semantic of C/C++ (due to side effects, pointer aliasing, etc.) they can’t go very far in that direction. This is a distinctive advantage of a purely functional language: it allows compilers to do very advanced optimisations.
 
AsIt alreadyis useful to note the difference between the block diagram and the generated C++ code. As saidstated, the key idea here is not to compile the block diagram literally, but the mathematical function it denotes. Modern C/C++ compilers tooalso don’tdon't compile programs literally. But because of the complex semanticsemantics of C/C++ (due to side effects, pointer aliasing, etc.) they can’tcan't go very far in that direction. This is a distinctivedistinct advantage of a purely functional language: it allows compilers to do very advanced optimisations.
==Connection to Arrows==
 
The Faust semantics is almost the same as that of [[Haskell (programming language)|Haskell]]'s [[Arrow (computer science)|Arrows]] type class.
==Arrows-like semantics==
The Faust semantics is almost the same as that of [[Haskell (programming language)|Haskell]]'s]] [[Arrow (computer science)|Arrows]] type class.
However, the Arrow type class is not bound to signal processors.
 
{| class="wikitable"
|+ Equivalences between FAUST and Arrow combinators
| <code>f~g</code> || <{{code>|2=haskell|1=loop ((\(a,b) -> (b,a)) ^>> f >>> id &&& (delay>>>g))</code>}} where <code>delay</code> is not a method of the <code>Arrow</code> type class, but is specific to signal processing arrows
|-
| <code>f,g</code> || <code>f***g</code>
Line 152 ⟶ 157:
|}
 
The Arrow combinators are more restrictive than their FAUST counterparts, e.g., the nesting of parallel composition is preserved, and inputs of the operands of <code>&&&</code> must match exactly.
e.g. the nesting of parallel composition is preserved
and inputs of the operands of <code>&&&</code> must match exactly.
 
==References==
Line 194 ⟶ 197:
| year = 2011
}}
* {{cite journal
|first1 =Pierre Pierre
|last1 =Jouvelot Jouvelot
|first2 =Yann Yann
|last2 =Orlarey Orlarey
|title = Dependent Vector Types for Data Structuring in Multirate Faust
|journal = Computer Languages, Systems and& Structures&nbsp;– Elsevier
|url = http://faust.grame.fr/images/faust-doc/papers/faust-elsevier2011.pdf
|year =2011 2011
|volume=37
}}
|issue=3
|pages=113–131
|doi=10.1016/j.cl.2011.03.001
}}{{dead link|date=December 2016 |bot=InternetArchiveBot |fix-attempted=yes }}
* {{Cite web
| first = Julius O.
Line 211 ⟶ 218:
| year = 2011
}}
* {{cite journal
| first3 =Dominique Dominique
| last3 =Fober Fober
| first1 =Yann Yann
| last1 =Orlarey Orlarey
| first2 =Stéphane Stéphane
| last2 =Letz Letz
| title = Automatic Parallelization of Audio Applications with Faust
| journal = Proceedings of the Congrès Français d'Acoustique
| url = http://faust.grame.fr/images/faust-doc/papers/faust-CFA-2010.pdf
| year =2010 2010
}}{{dead link|date=December 2016 |bot=InternetArchiveBot |fix-attempted=yes }}
}}
* {{cite journal
| first3 = Dominique
Line 244 ⟶ 251:
| year = 2010
}}
* {{cite journal
| first1 =Jérôme Jérôme
| last1 =Barthélemy Barthélemy
| first2 =Alain Alain
| last2 =Bonardi Bonardi
| first3 =Yann Yann
| last3 =Orlarey Orlarey
| first4 =Serge Serge
| last4 =Lemouton Lemouton
| first5 =Raffaele Raffaele
| last5 =Ciavarella Ciavarella
| first6 =Karim Karim
| last6 =Barkati Barkati
| title = First Steps Towards an Organology of Virtual Instruments in Computer Music
| journal = Proceedings of the 2010 International Computer Music Conference (ICMA-2010)
| url = http://faust.grame.fr/images/faust-doc/papers/astree-icmc2010.pdf
| pages =369–372 369–372
| year =2010 2010
}}{{dead link|date=December 2016 |bot=InternetArchiveBot |fix-attempted=yes }}
}}
* {{cite journal
| first1 = Pierre
Line 269 ⟶ 276:
| last2 = Orlarey
| title = Depandant Vector Types for Multirate Faust
| journal = Proceedings of the 7th Sound anand Music Computing Conference (SMC-2010)
| url = http://smcnetwork.org/files/proceedings/2010/51.pdf
| pages = 345–352
| year = 2010
| access-date = 2011-10-11
| archive-url = https://web.archive.org/web/20120407043121/http://smcnetwork.org/files/proceedings/2010/51.pdf
| archive-date = 2012-04-07
| url-status = dead
}}
* {{cite journal
| first3 =Dominique Dominique
| last3 =Fober Fober
| first1 =Yann Yann
| last1 =Orlarey Orlarey
| first2 =Stéphane Stéphane
| last2 =Letz Letz
| title = Adding Automatic Parallelization to Faust
| journal = Proceedings of the Linux Audio Conference (LAC-2009)
| url = http://faust.grame.fr/test/images/faust-doc/papers/faustLAC09.pdf
| year =2009 2009
}}{{dead link|date=December 2016 |bot=InternetArchiveBot |fix-attempted=yes }}
}}
* {{cite book
| first1 = Pierre
Line 295 ⟶ 306:
| url = http://faust.grame.fr/images/faust-doc/papers/multirate-faust.pdf
| year = 2009
}}{{Dead link|date=December 2019 |bot=InternetArchiveBot |fix-attempted=yes }}
}}
* {{cite journal
| first2 = Dominique
Line 306 ⟶ 317:
| url = http://smc2009.smcnetwork.org/programme/pdfs/232.pdf
| year = 2009
| archive-date = 2012-04-25
| access-date = 2011-10-11
| archive-url = https://web.archive.org/web/20120425061241/http://smc2009.smcnetwork.org/programme/pdfs/232.pdf
| url-status = dead
}}
* {{cite book
Line 320 ⟶ 335:
| isbn = 978-2-7521-0054-2
| year = 2009
}}{{Dead link|date=December 2019 |bot=InternetArchiveBot |fix-attempted=yes }}
}}
* {{cite journal
| first3 =Dominique Dominique
| last3 =Fober Fober
| first1 =Yann Yann
| last1 =Orlarey Orlarey
| first2 =Stéphane Stéphane
| last2 =Letz Letz
| title = Multicore Technologies in Jack and Faust
| journal = Proceedings of the 2010 International Computer Music Conference (ICMC-2008)
| url = http://faust.grame.fr/images/faust-doc/papers/jack-faust-multicore.pdf
| year =2008 2008
}}{{dead link|date=December 2016 |bot=InternetArchiveBot |fix-attempted=yes }}
}}
* {{cite journal
| first = Albert
Line 346 ⟶ 361:
| last = Smith III
| title = Introduction to Digital Filters: With Audio Applications
| chapter = Appendix K. Digital Filtering in Faust and PD
| publisher = W3K Publishing
| year = 2007
| isbn = 978-0-9745607-1-7
| chapter-url = httphttps://books.google.com/books?id=pC1iCQUAsHEC&pg=PA417
| pages = 417-417–?
}}
* {{cite journal
Line 389 ⟶ 404:
| publisher = Computer Music Association
| url = http://quod.lib.umich.edu/cgi/t/text/text-idx?c=icmc;idno=bbp2372.2005.*
| chapterurlchapter-url = http://quod.lib.umich.edu/i/icmc/bbp2372.2005.054?view=image
| year = 2005
| page = 286
Line 404 ⟶ 419:
| url = http://faust.grame.fr/images/faust-doc/papers/faust-soft-computing.pdf
| year = 2004
}}{{Dead link|date=December 2019 |bot=InternetArchiveBot |fix-attempted=yes }}
}}
* {{cite journal
| first1 =Nicolas Nicolas
| last1 =Scaringella Scaringella
| first3 =Dominique Dominique
| last3 =Fober Fober
| first2 =Yann Yann
| last2 =Orlarey Orlarey
| title = Automatic Vectorization in Faust
| journal = Journée de l'Informatique Musicale (JIM-2003)
| url = http://faust.grame.fr/images/faust-doc/papers/JIM2003vect.pdf
| year =2003 2003
}}{{dead link|date=December 2016 |bot=InternetArchiveBot |fix-attempted=yes }}
}}
* {{cite journal
| first3 =Stéphane Stéphane
| last3 =Letz Letz
| first2 =Dominique Dominique
| last2 =Fober Fober
| first1 =Yann Yann
| last1 =Orlarey Orlarey
| title = An Algebraic Approach to Block Diagram Constructions
| journal = Journée de l'Informatique Musicale (JIM-2002)
| url = http://faust.grame.fr/images/faust-doc/papers/faust-jim2002.pdf
| year =2002 2002
}}{{dead link|date=December 2016 |bot=InternetArchiveBot |fix-attempted=yes }}
}}
* {{cite journal
| first3 =Stéphane Stéphane
| last3 =Letz Letz
| first2 =Dominique Dominique
| last2 =Fober Fober
| first1 =Yann Yann
| last1 =Orlarey Orlarey
| title = An Algebra for Block Diagram Languages
| journal = Proceedings of International Computer Music Conference (ICMA-2002)
| url = http://faust.grame.fr/images/faust-doc/papers/faust-icmc2002.pdf
| year =2002 2002
}}{{dead link|date=December 2016 |bot=InternetArchiveBot |fix-attempted=yes }}
}}
{{Refend}}
 
==External links==
{{commonsCommons category|FAUST (programming language)}}
* [http://{{Official website|faust.grame.fr/ FAUST home page]:}}, Onlineonline compiler, support, documentation, news, etc.
* {{GitHub|grame-cncm/faust}}
* [http://faudiostream.sourceforge.net/ FAUST on SourceForge]: Faust repository and mailing lists
 
[[Category:Audio programming languages]]
[[Category:Programming languages created in 2002]]