FAUST (programming language): Difference between revisions

Content deleted Content added
AvicBot (talk | contribs)
Line 1:
{{Colloquial|date=September 2012}}
{{No footnotes|date=March 2015}}
{{Infobox software
Line 8 ⟶ 7:
| latest release version = 0.9.67
| latest release date = {{release date|2014|05|19}}
| operating system = [[Linux]], [[Mac OS X]], [[Microsoft Windows|Windows]], [[Unix]]
| genre = Functional programming language for audio signal processing
| programming language = [[C++]]
| license = [[GNU General Public License|GPL]]
| website = http://{{URL|faust.grame.fr/}}
}}
 
'''FAUST''' (Functional AUdio STream) is a [[Domain specific language|___domain-specific]] [[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|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’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 complies with sound engineers' and audio developers' habits.
A FAUST program doesn’t describe a sound or a group of sounds, but a [[Digital signal processing|signal processor]]. 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):
<source lang=haskell>
Line 26 ⟶ 25:
</source>
 
The FAUST [[compiler]] translates FAUST code into a [[C++]] [[Object -oriented programming|object]], which may then interface with other C++ code to produce a completefull program.
 
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]]. The code may also be [[Embedded software|embedded]]. It is self-contained and does not depend on any DSP library or [[runtime system]]. It has a very deterministic behavior and a constant memory footprintsize.
 
The semanticsemantics of FAUST is driven to be simple and well-defined. It allows the FAUST compiler to be ''semantically driven''. Instead of compiling a program literally, it compiles the mathematical function it denotes. This may promote component reuse. Moreover, having access to the exact semantics of a FAUST program can simplify preservation issues.
 
FAUST is a textual language but block- diagram oriented. It combines two approaches: [[functional programming]] and algebraic [[Blockblock diagram|block-diagrams]]s, which are constructed via [[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:
<source lang=haskell>
Line 47 ⟶ 46:
process = +;
</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 85 ⟶ 84:
process = *(0.5);
</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):
<source lang=haskell>
process = + ~ _;
</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|2015}}, more than 10 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 130 ⟶ 129:
|}
 
==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.
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’t compile programs literally. But because of the complex semanticsemantics of C/C++ (due to side effects, pointer aliasing, etc.) they can’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.
However, the Arrow type class is not bound to signal processors.
 
Line 152 ⟶ 151:
|}
 
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 445 ⟶ 442:
==External links==
{{Commons category|FAUST (programming language)}}
* [http://{{Official website|faust.grame.fr/ FAUST home page]:}}, Onlineonline compiler, support, documentation, news, etc.
* [http://faudiostream.sourceforge.net/ FAUST on SourceForge]: Faust repository and mailing lists