Next  |  Prev  |  Top  |  REALSIMPLE Top


Generating a Pure Data (Pd) Plugin

This section illustrates making a pd plugin using the Faust architecture file puredata.cpp, and Albert Gräf's faust2pd script (version 0.9.8.6--also included in the Planet CCRMA distribution). Familiarity with Pure Data (the pd program by Miller Puckette [3,4]) is assumed in this section. Also, the original faust2pd paper [1] contains the most complete description of faust2pd at the time of this writing.

Even if one prefers writing real-time signal-processing programs in C++, C, or assembly language,9the ability to generate user interfaces and plugins with Faust is compellingly useful.

To illustrate automatic generation of user-interface controls, we will add two ``numeric entry'' fields and one ``horizontal slider'' to our example of Fig.1. These controls will allow the plugin user to vary the center-frequency, bandwidth, and peak gain of the constant-peak-gain resonator in real time. A complete listing of cpgrui.dsp (``Constant-Peak-Gain Resonator with User Interface'') appears in Fig.7.

Figure 7: Listing of cpgrui.dsp--a Faust program specifying a constant-peak-gain resonator with three user controls. Also shown are typical header declarations.

 
  declare name "Constant-Peak-Gain Resonator";
  declare author "Julius Smith";
  declare version "1.0";
  declare license "GPL";

  /* Controls */
  fr = nentry("frequency (Hz)", 1000, 20, 20000, 1);
  bw = nentry("bandwidth (Hz)", 100, 20, 20000, 10);
  g  = hslider("peak gain", 1, 0, 10, 0.01);

  /* Constants (Faust provides these in math.lib) */
  SR = fconstant(int fSamplingFreq, <math.h>);
  PI = 3.1415926535897932385;

  /* The resonator */
  process = firpart : + ~ feedback
  with {
    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 coeffs ASSUMING ONE PIPELINE DELAY:
    feedback(v) = 0 + 2*R*cos(A)*v - RR*v';
  };



Subsections
Next  |  Prev  |  Top  |  REALSIMPLE Top

Download faust.pdf

``Signal Processing in Faust and PD'', by Julius O. Smith III,
REALSIMPLE Project — work supported by the Wallenberg Global Learning Network .
Released 2010-07-29 under the Creative Commons License (Attribution 2.5), by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA