FAUST (programming language): Difference between revisions

Content deleted Content added
no blank lines in list for accessibility; fix heading style, ndash; rm trailing space; rm ref=harv, no lines, thus +no footnote; +commons categorys
Line 35:
FAUST is a textual language but nevertheless block-diagram oriented. It actually combines two approaches: functional programming and algebraic block-diagrams. The key idea is to view block-diagram construction as function composition. For that, FAUST relies on a ''block-diagram algebra'' of five composition operations.
 
==SimpleExample examplesCode==
Let’sFAUST startprograms withdefine somea really<code>process</code> simplefunction one-linethat examplesoperates ofon FAUSTincoming programdata. HereThe isfollowing ais firstan example that produces silence:
<source lang=cpphaskell>
process = 0;
</source>
The second example is a little bit more sophisticated and copies the input signal to the output signal. It involves the <code>_ (underscore)</code> primitive that denotes the [[identity function]] on signals (that is a simple audio cable for a sound engineer):
<source lang=cpphaskell>
process = _;
</source>
Another very simple example is the conversion ofconverts a two-channel stereo signal into a one-channel mono signal using the <code>+</code> primitive that adds two signals together:
<source lang=cpphaskell>
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 (Programming Language)|C]] function <code>sin</code> to each sample X([t) of X. In other words sin transforms an input signal X into an output signal Y such that Y (t) = sin(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==