Sign in

username:

password:



Not a member?

Search Online Books



Search tips

Free Online Books

Sponsor

Industry's highest performing at the lowest power DSPs now as low as $5.00*
Start development today!
*volume pricing for 10ku

Chapters

See Also

Embedded SystemsFPGAElectronics
Chapter Contents:

Search Introduction to Digital Filters

  

Book Index | Global Index


Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?

  

A Simple Faust Program

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 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' expands to x : MEM and indicates a signal obtained by delaying the signal x by one sample.

Function application applies to operator symbols as well as names; thus, for example, +(x) expands to _,x : +, and *(x) expands to _,x : *, where _ denotes a simple ``wire''. There is a special unary minus in Faust (as of release 0.9.9.4), so that -x is equivalent to 0 - x. However, -(x) still expands to _,x : -, which is a blockdiagram that subtracts signal x from the input signal on _ .

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

Figure K.1: Faust program specifying a constant-peak-gain resonator. Input parameters are the resonance frequency fr (Hz), resonance bandwidth bw (Hz), and the desired peak-gain g.

 
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 $ 2,2,2,\ldots$ 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.


Previous: Digital Filtering in Faust and PD
Next: Generating Faust Block Diagrams

Order a Hardcopy of Introduction to Digital Filters


About the Author: Julius Orion Smith III
Julius Smith's background is in electrical engineering (BS Rice 1975, PhD Stanford 1983). He is presently Professor of Music and Associate Professor (by courtesy) of Electrical Engineering at Stanford's Center for Computer Research in Music and Acoustics (CCRMA), teaching courses and pursuing research related to signal processing applied to music and audio systems. See http://ccrma.stanford.edu/~jos/ for details.


Comments


No comments yet for this page


Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )