| 1 |
// Listing 9.12 snare.ck plays on beats 2 and 4 and more, conducted by global BPM |
| 2 |
|
| 3 |
// snare.ck |
| 4 |
// on the fly drumming with global BPM conducting |
| 5 |
SndBuf snare => dac; |
| 6 |
me.dir(-1)+"/audio/snare_01.wav" => snare.read; |
| 7 |
0.5 => snare.gain; |
| 8 |
snare.samples() => snare.pos; |
| 9 |
|
| 10 |
// make a conductor for our tempo |
| 11 |
// this is set and updated elsewhere |
| 12 |
BPM tempo; |
| 13 |
while (1) { |
| 14 |
// update our basic beat each measure |
| 15 |
tempo.quarterNote => dur quarter; // (1) Updates tempo at beginning of each measure... |
| 16 |
|
| 17 |
// play measure of: rest, snare, rest, sna-snare |
| 18 |
quarter => now; // (2) ...waits a beat (quarter)... |
| 19 |
0 => snare.pos; // (3) ...plays a snare hit... |
| 20 |
2.0*quarter => now; // (4) ...waits two beats... |
| 21 |
|
| 22 |
0 => snare.pos; // (5) ...plays another hit... |
| 23 |
quarter/4.0 => now; // (6) ...waits for half a beat... |
| 24 |
|
| 25 |
0 => snare.pos; // (7) ...plays another hit... |
| 26 |
3.0*quarter/4.0 => now; //(8) ...waits for remainder of the measure. |
| 27 |
} |
| 28 |
|