Next  |  Prev  |  Top  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

Primer on the FAUST Language

FAUST is a functional programming language [6]. Each function specifies a block diagram having some number of input and output signals, all streaming at the same sampling rate, starting at time 0. Five block-diagram operators2.2) may be used to combine block diagrams in FAUST expressions (see below for examples). Every FAUST program (filename extension .dsp) must define a function named process, analogous to ``main'' in C or C++ programs. The process function contains FAUST expressions and/or other function expansions that specify the signal-processing block diagram associated with that FAUST program.4

A very simple FAUST program is

    process(x) = x;
which defines a simple ``wire'' block diagram that connects its single input to its single output. We can also define a pair of wires for stereo operation:
    process(x,y) = x,y;
Here we have introduced the comma block-diagram operator (,) on the righthand side which combines block diagrams in parallel. (On the lefthand side, a comma separates function arguments, which is a different usage of comma.)

Common block-diagram functions are predefined, such as ``$ +$ '':

    process(x,y) = x,y:+;
Now we have introduced the colon (:) operator for combining block diagrams in series. The block diagram consisting of two wires x and y in parallel is connected to the two inputs of the + block diagram.

Since the + operator already has two inputs, we do not need to refer to them explicitly. Thus,

    process = +;
is equivalent to ``process(x,y) = x,y:+;'', and it therefore also specifies a block diagram consisting of two input signals, one output signal, and a summer, as shown in Fig.1.

Figure 1: Main process block diagram for a two-input adder: process = +;
\includegraphics{eps/fadder}

The underbar symbol _, also called a ``wire'', denotes the trivial block diagram that feeds its single input to its single output. Thus, using the predefined block diagram ``_'' we can define the ``mono wire'' function ``process(x)=x;'' as

    process = _;
and the ``stereo bus'' as
    process = _,_;
which is equivalent to ``process(x,y)=x,y;''.

The block diagram generated by faust -svg wire.dsp (as used by the script faust2firefox), where wire.dsp contains process=_;, is shown in Fig.2.

Figure 2: process = _;
\includegraphics{eps/fwire}

Arguably even simpler is

    process = 0;
where 0 can be thought of as a predefined block diagram having no input signals, and one output signal that is a stream of zeros. The block diagram for this is shown in Fig.3.

It is convenient to refer to a block diagram as a signal when it has no input signals and one output signal.

Similarly,

    process = 1;
specifies a block diagram having no input signals and an output signal that is a stream of ones starting at time zero. Block-diagrams such as `0' and `1' may be thought of as constant signals. However, since a constant signal, as defined, is semantically a block diagram, all operations valid for block diagrams (listed below) can be applied. For example, using the one-sample-delay postfix operator ', we can specify the unit impulse signal by
    impulse = 1 - 1';
because 1 is the unit-step signal (a unit constant turning on at time 0) and 1' is the unit-step delayed by one sample.

Figure 3: process = 0;
\includegraphics{eps/f0}



Subsections
Next  |  Prev  |  Top  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

Download aspf.pdf
[Comment on this page via email]

``Audio Signal Processing in Faust'', by Julius O. Smith III
Copyright © 2023-08-16 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA