| 1 |
// Listing 9.21 MandoScore.ck makes and plays your new MandoPlayer |
| 2 |
// let's try all this out!! Make a MandoPlayer object |
| 3 |
MandoPlayer m; // (1) Makes a smart MandoPlayer object |
| 4 |
|
| 5 |
// and declare some data for chording and strumming |
| 6 |
["G","C","G","D","D","D","D","G"] @=> string chords[]; // (2) Array of string chord names |
| 7 |
[0.4,0.4,0.4,0.1,0.1,0.1,0.1,0.01] @=> float durs[]; |
| 8 |
[79,81,83] @=> int strums[]; // (3) Array of things to strum |
| 9 |
|
| 10 |
// counter to iterate through the arrays |
| 11 |
0 => int i; |
| 12 |
|
| 13 |
// roll the basic chords, reading through the arrays |
| 14 |
while (i < chords.cap()) { // (4) ...through whole chord name array |
| 15 |
m.roll(chords[i],durs[i] :: second); // (5) Rolls each chord |
| 16 |
i++; |
| 17 |
} |
| 18 |
|
| 19 |
// now strum a few notes |
| 20 |
0 => i; |
| 21 |
while (i < strums.cap()) { // (6) Strums through the array of strums |
| 22 |
m.strum(strums[i++], 1.0 :: second); |
| 23 |
} |
| 24 |
|
| 25 |
// then end up with a big open G chord |
| 26 |
m.damp(1.0); // (7) Lets strings ring a long time |
| 27 |
m.roll("G", 0.02 :: second); // (8) Rolls a chord |
| 28 |
2.0 :: second => now; |
| 29 |
|
| 30 |
// damp it to silence, letting it ring a little |
| 31 |
m.damp(0.01); // (9) Damps strings at the end |
| 32 |
1.0 :: second => now; |