Search Introduction to Digital Filters
Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?
Figure K.1 lists a minimal Faust program specifying the constant-peak-gain resonator discussed in §B.6.4. This appendix does not cover the Faust language itself, so the the Faust Tutorial, or equivalent, should be considered prerequisite reading. We will summarize briefly, however, the Faust operators relevant to this example: signal processing blocks are connected in series via a colon (:), and feedback is indicated by a tilde (~). The colon and tilde operators act on ``block diagrams'' to create a larger block diagram. There are also signal operators. For example, a unit-sample delay is indicated by appending a prime (') after a signal variable; thus, x' indicates a signal obtained by delaying the signal x by one sample. The with block provides local definitions in the context of the process definition.K.3 Other aspects of the language used in this example should be fairly readable to those having a typical programming background.K.4
process = firpart : + ~ feedback
with {
bw = 100; fr = 1000; g = 1; // parameters - see caption
SR = fconstant(int fSamplingFreq, <math.h>); // Faust fn
pi = 4*atan(1.0); // circumference over diameter
R = exp(0-pi*bw/SR); // pole radius [0 required]
A = 2*pi*fr/SR; // pole angle (radians)
RR = R*R;
firpart(x) = (x - x'') * g * ((1-RR)/2);
// time-domain coefficients ASSUMING ONE PIPELINE DELAY:
feedback(v) = 0 + 2*R*cos(A)*v - RR*v';
};
|
Constants such as RR in Fig.K.1 are better thought of as
constant signals. As a result, operators such as *
(multiplication) conceptually act only on signals. Thus, the
expression
2*x denotes the constant-signal
muliplied
pointwise by the signal x. The Faust compiler does a good job
of optimizing expressions so that operations are not repeated
unnecessarily at run time. In summary, a Faust expression expands
into a block diagram which processes causal signals,K.5 some of which may be constant signals.
