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

Software Implementation in Faust

The Faust language for signal processing is introduced in Appendix K. Figure 3.4 shows a Faust program for implementing our example comb filter. As illustrated in Appendix K, such programs can be compiled to produce LADSPA or VST audio plugins, or a Pure Data (PD) plugin, among others.

Figure 3.4: Faust main program implementing the example digital filter. (Tested in Faust version 0.9.9.2a2.)

 
/* GUI Controls */
g1  = hslider("feedforward gain", 0.125, 0, 1, 0.01);
g2  = hslider("feedback gain", 0.59049, 0, 1, 0.01);

/* Signal Processing */
process = firpart : + ~ feedback
with {
  firpart(x) = x + g1 * x''';
  feedback(v) = 0 - g2 * v'''';
};

As discussed in Appendix K, a prime (') denotes delaying a signal by one sample, and a tilde (~) denotes feedback. A colon (:) simply indicates a connection in series. The feedback signal v is delayed only four samples instead of five because there is a free ``pipeline delay'' associated with the feedback loop itself.

Faust's -svg option causes a block-diagram to be written to disk for each Faust expression (as further discussed in Appendix K). The block diagram for our example comb filter is shown in Fig.3.5.

Figure 3.5: Block diagram generated by the Faust -svg option.
\includegraphics[width=\twidth]{eps/faustcfbd}

Compiling the Faust code in Fig.3.4 for LADSPA plugin format produces a plugin that can be loaded into ``JACK Rack'' as depicted in Fig.3.6.

Figure 3.6: JACK Rack screenshot for the example comb filter.
\includegraphics[width=4in]{eps/faustcfjr}

At the risk of belaboring this mini-tour of filter embodiments in common use, Fig.3.7 shows a screenshot of a PD test patch for the PD plugin generated from the Faust code in Fig.3.4.

Figure: Pure Data (PD) screenshot for a test patch exercising a PD plugin named cf.pd that was generated automatically from the Faust code in Fig.3.4 using the faust program and faust2pd script (see Appendix K for details).
\includegraphics[width=3.5in]{eps/faustcfpd}

By the way, to change the Faust example of Fig.3.4 to include its own driving noise, as in the STK example of Fig.3.3, we need only add the line

  import("music.lib");
at the top to define the noise signal (itself only two lines of Faust code), and change the process definition as follows:
  process = noise : firpart : + ~ feedback

In summary, the Faust language provides a compact representation for many digital filters, as well as more general digital signal processing, and it is especially useful for quickly generating real-time implementations in various alternative formats. Appendix K gives a number of examples.


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 © 2024-09-03 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA