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

Signal Types

The two signal types in FAUST are int and float. When compiling, a float can be elevated to double or quad precision by means of the -double or -quad options to the FAUST compiler. An int is always 32-bit precision, for reasons mentioned in §2.25 below.

In the FAUST language, the type of a signal can be forced (with conversion, if necessary), as follows:

$\displaystyle \begin{tabular}{rcl}
\texttt{int(x)} & $\to$\ & integer part of the signal \texttt{x}\\
\texttt{float(x)} & $\to$\ & treat the signal \texttt{x} as a float in expressions

The int(x) conversion implements what is normally called magnitude truncation, or ``rounding toward zero''. Thus, int(0.99) = int(-0.99) = 0. Magnitude truncation is often preferred in digital signal processing applications because it normally best preserves the stability of all feedback loops. (When signals have a physical-amplitude interpretation, such as pressure or voltage, then magnitude truncation, unlike rounding, is always passive, i.e., not energy-creating.)

Note that integer expressions are automatically converted to float when necessary to avoid a loss of precision. Thus, for example,

  process = 1/2; // = 0.5, 0.5, 0.5,...
outputs 0.5, while
  process = int(1/2); // = 0, 0, 0, ...
puts out the constant zero signal.

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