| 1 |
// Listing 6.9 Even better plucked string, with enveloped noise and low-pass filter |
| 2 |
|
| 3 |
// Even Better Karplus-Strong plucked string |
| 4 |
// Noise through ADSR into interpolating delay line |
| 5 |
|
| 6 |
Noise nois => ADSR pluck => DelayA str => dac; |
| 7 |
|
| 8 |
// hook string back into itself |
| 9 |
// Feedback delay through a low-pass loop filter |
| 10 |
str => OneZero lowPass => str; |
| 11 |
|
| 12 |
// set ADSR noise envelope parameters |
| 13 |
// Sets ADSR parameters to pluck rapidly and then stick at 0.0 |
| 14 |
pluck.set(0.002 :: second, 0.002 :: second, 0.0, 0.01 :: second); |
| 15 |
|
| 16 |
// Play random notes forever |
| 17 |
while (true) |
| 18 |
{ |
| 19 |
// Can now set delay length to any arbitrary float number |
| 20 |
Math.random2f(110.0, 440.0) :: samp => str.delay; |
| 21 |
|
| 22 |
// turn on note (pluck string) and wait a bit |
| 23 |
1 => pluck.keyOn; // Plucks by sending keyOn to float number ADSR, |
| 24 |
// gates noise into string |
| 25 |
0.3 :: second => now; |
| 26 |
} |
| 27 |
|
| 28 |
|