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

Appendix A: State-Space Models to FAUST

A digital state-space model is normally written mathematically as

\begin{eqnarray*}
\underline{y}(n) & = & \mathbf{C}\, \underline{x}(n) + \mathbf{D}\,\underline{u}(n)\\ [10pt]
\underline{x}(n+1) & = & \mathbf{A}\, \underline{x}(n) + \mathbf{B}\, \underline{u}(n)
\end{eqnarray*}

where

The matrices $ \mathbf{B}$ , $ \mathbf{C}$ and $ \mathbf{D}$ make up the feedforward part, while $ \mathbf{A}$ is the feedback part.

Note that all four matrices may change each sample instant $ n$ to implement a general time-varying linear system.

A FAUST example for the general linear state-space model is shown in Fig.19. The FAUST-generated block diagram is shown in Fig.20.

Since a state-space model can implement any $ N$ th-order linear system with $ p$ inputs and $ q$ outputs, all we have to do is come up with the $ (\mathbf{A}, \mathbf{B}, \mathbf{C}, \mathbf{D})$ matrix entries and use the general state-space formulation in FAUST given in Fig.19.

Here are the steps for finding the state-space matrices:

  1. Label each delay element as a state variable $ x_i$ . Delay lines can be treated as one ``generalized delay'' (Feedback Delay Networks are often written this way). In terms of the mathematical description above, the $ i$ th delay input is $ \underline{x}_i(n+1)$ , and the output is $ \underline{x}_i(n)$ .

  2. By tracing connections in the block diagram, write $ \underline{x}_i(n+1)$ as a linear combination of either inputs $ \underline{u}(n)$ or states $ \underline{x}(n)$ for each $ i=1,2,\ldots,N$ . Place these coefficients where they go in the $ i$ th row of $ \mathbf{B}$ (for inputs) and $ \mathbf{A}$ (for states), and enter zeros for inputs and states not needed to create $ \underline{x}_i(n+1)$ .

  3. Now do the same for each output $ \underline{y}_i(n)$ , $ i=1,\ldots,q$ , which is similarly a linear combination of inputs and/or states. Use these coefficients to populate the $ i$ th row of $ \mathbf{D}$ (for inputs) and $ \mathbf{C}$ (for states).

  4. Now you've filled your $ (\mathbf{A}, \mathbf{B}, \mathbf{C}, \mathbf{D})$ matrices, so they can be plugged into FAUST code based on Fig.19.

A simple example for trying out and checking this process can be found by starting at step 3 of ``Converting to State-Space Form by Hand'' [11].21 The details appear below in §A.1. Also be aware of the matlab function tf2ss for converting a transfer function to state-space form.

Figure 19: FAUST example illustrating a general state-space model having 2 inputs, 3 outputs, and 5 state variables.

 
// General Linear State-Space Model Example

import("stdfaust.lib");

p = 2; // number of inputs
q = 3; // number of outputs
N = 5; // number of states

A = matrix(N,N); // state transition matrix
B = matrix(N,p); // input-to-states matrix
C = matrix(q,N); // states-to-output matrix
D = matrix(q,p); // direct-term matrix, bypassing state

matrix(M,N) = tgroup("Matrix: %M x %N", par(in, N, _)
              <: par(out, M, mixer(N, out))) with {
  fader(in) = ba.db2linear(vslider("Input %in", -10, -96, 4, 0.1));
  mixer(N,out) = hgroup("Output %out", par(in, N, *(fader(in)) ) :> _ );
};

Bd = par(i,p,mem) : B; // input delay needed for conventional definition
vsum(N) = si.bus(2*N) :> si.bus(N); // vector sum of two N-vectors
impulse = 1-1'; // For zero initial state, set impulse = 0 or simplify code
x0 = par(i,N,i*impulse); // initial state = (0,1,2,3,...,N-1)

system = si.bus(p) <: D, (Bd : vsum(N)~(A), x0 : vsum(N) : C) :> si.bus(q);

process = system;

Figure 20: State-space model in FAUST having 2 inputs, 3 outputs, and 5 state variables.
\includegraphics[width=6in]{eps/ssbd}



Subsections
Next  |  Prev  |  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 © 2021-02-08 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA