Main Content

Karplus-Strong Algorithm by Using Moore Charts

This example shows a simple implementation of the Karplus-Strong algorithm for string synthesis by using Stateflow® charts with Moore semantics. For more information, see Design Considerations for Moore Charts.


The initial burst of white noise is produced by a Uniform Random Number block. It is fed back into a delay line of the same length. The moving average smooth the signal at each cycle, while the gain less than 1 maintains the stability of the feedback loop. They both model the string losses over each cycle.

Nondirect Feedthrough

This example illustrates the benefits of Moore Charts in loops. Moore semantics guarantees that outputs only depend on the current state, but neither on inputs nor the next state. Hence a Moore Chart has nondirect feedthrough and can safely be used in feedback loops. For more information, see Algebraic Loop Concepts (Simulink).

On the contrary, Classic or Mealy Charts provide direct feedthrough. These charts do not prevent algebraic loops, unless an external Delay block breaks cyclic dependencies. Simulation would issue an error if both charts were Classic or Mealy charts.

Related Topics