| 1 |
/////////////////////////////////////////////////////////////////////////////// |
| 2 |
// Mesh2D: Two-dimensional rectilinear waveguide mesh class. // |
| 3 |
// // |
| 4 |
// Part of the Synthesis Toolkit in C++ // |
| 5 |
// https://ccrma.stanford.edu/software/stk/ // |
| 6 |
// // |
| 7 |
// This class implements a rectilinear, two-dimensional digital waveguide // |
| 8 |
// mesh structure. For details, see Van Duyne and Smith, "Physical Modeling // |
| 9 |
// with the 2-D Digital Waveguide Mesh", Proceedings of the 1993 // |
| 10 |
// International Computer Music Conference. // |
| 11 |
// // |
| 12 |
// This is a digital waveguide model, making its use possibly subject to // |
| 13 |
// patents held by Stanford University, Yamaha, and others. // |
| 14 |
/////////////////////////////////////////////////////////////////////////////// |
| 15 |
|
| 16 |
// Options: |
| 17 |
// |
| 18 |
// x: X dimension size in samples. int [2-12], default 5 |
| 19 |
// y: Y dimension size in samples. int [2-12], default 4 |
| 20 |
// xpos: x strike position. float [0-1], default 0.5 |
| 21 |
// ypos: y strike position. float [0-1], default 0.5 |
| 22 |
// decay: decay factor. float [0-1], default 0.999 |
| 23 |
|
| 24 |
Mesh2D mesh1 => dac.left; |
| 25 |
Mesh2D mesh2 => dac.right; |
| 26 |
0.5 => mesh1.gain => mesh2.gain; |
| 27 |
|
| 28 |
while (true) |
| 29 |
{ |
| 30 |
Math.random2(2,12) => mesh1.x; |
| 31 |
Math.random2(2,12) => mesh1.y; |
| 32 |
Math.randomf() => mesh1.xpos; |
| 33 |
Math.randomf() => mesh1.ypos; |
| 34 |
1 => mesh1.noteOn; |
| 35 |
250::ms => now; |
| 36 |
Math.random2(2,12) => mesh2.x; |
| 37 |
Math.random2(2,12) => mesh2.y; |
| 38 |
Math.randomf() => mesh2.xpos; |
| 39 |
Math.randomf() => mesh2.ypos; |
| 40 |
1 => mesh2.noteOn; |
| 41 |
250::ms => now; |
| 42 |
|
| 43 |
} |