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

Scope Rules

As illustrated in §3 below, a with{...}; block may be used to define local symbols (block diagrams). Otherwise, everything is globally defined.

A library ``foo.lib'' may be loaded into its own namespace by writing

  f = library("foo.lib");
and then symbols from that library may be accessed using the given prefix:
  fPI = f.PI;           // use definition of PI given in foo.lib
  fTanZero = f.tan(0);  // use definition of tan() given in foo.lib

An environment works similarly:

  e = environment {
    Phi = 0.5*(1.0+sqrt(5));
  golden_ratio = e.Phi;

For convenience, ``component("prog.dsp")'' is defined to mean the same thing as

Definitions within an environment can be replaced (or appended) using the following bracket syntax:

  f = library("filters.lib")[pole(p) = _;];
  process = f.dcblocker; // now it is one-zero, no pole

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

Download aspf.pdf
[Comment on this page via email]

``Audio Signal Processing in Faust'', by Julius O. Smith III
Copyright © 2023-08-16 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University