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

Generating Faust Block Diagrams

When learning the Faust language, it can be helpful to generate a block diagram using the -svg option. For example, the command

  > faust -svg cpgr.dsp
creates a subdirectory of the current working directory named cpgr.dsp-svg which contains a ``scalable vector graphics'' (.svg) file for each block-diagram expression in cpgr.dsp.K.6For this example, there is a block diagram generated for the process line, and for each of the last five lines in the with clause (not counting the comment).

Figure K.2 shows the block diagram generated for the main process block from Fig.K.1:

  process = firpart : + ~ feedback
The dot on each block indicates its standard orientation (analogous to a ``pin 1'' indicator on an integrated circuit chip). The small open square at the beginning of the feedback loop indicates a unit sample delay introduced by creating a signal loop. Needless to say, it is important to keep track of such added delays in a feedback loop.

Figure K.2: Main process block for the constant-peak-gain resonator.

Figure K.3 shows the block diagram generated for the firpart abstraction:

  firpart(x) = (x - x'') * g * ((1-RR)/2);

Figure K.3: FIR-part ((x - x'') * g * ((1-RR)/2)) in Faust.

Similarly, Fig.K.4 shows the block diagram generated for the feedback path:

  feedback(v) = 0 + 2*R*cos(A)*v - RR*v';
If not for the added sample of delay in the feedback loop (indicated by the small open square in Fig.K.2), the feedback-path processing would have been instead 0 + 2*R*cos(A)*v' - RR*v''.

Figure K.4: Feedback block (0 + 2*R*cos(A)*x - RR*x') in Faust.

Note that the block diagrams are drawn as though all details of the expression are to be evaluated every sample. However, the Faust compiler instead computes constant expressions at init time and allocates memory locations for them. More generally, the Faust compiler separately optimizes full-rate signals at the sampling rate (calculated in the inner loop), slowly varying signals (updated at the ``buffer rate'' outside of the inner loop--currently every 64 samples), and constant signals (evaluated once at initialization time).

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

[How to cite this work]  [Order a printed hardcopy]  [Comment on this page via email]

``Introduction to Digital Filters with Audio Applications'', by Julius O. Smith III, (September 2007 Edition).
Copyright © 2015-04-22 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University