Matlab Code Examples

Here are various simple code fragments, making use of the finite difference methods described in the text. All can be viewed as prototypes for physical modeling sound synthesis. The coding style reflects something of a compromise between efficiency on the one hand, and brevity and intelligibility on the other. The choice of Matlab as a programming environment definitely reflects the latter sensibility, though the use of Matlab as an actual synthesis engine is not recommended. Some of these examples make use constructs and features which need not appear in a code fragment intended for synthesis, including various calls to plotting functions, as well as the demonstration of energy conservation in some cases. It should be clear, in all cases, which elements of these examples may be neglected in an actual implementation. For the sake of brevity, these examples are too crude for actual synthesis purposes, but many features, discussed at various points in the text and exercises, may be added.