| 1 |
//----------------------------| |
| 2 |
// on-the-fly synchronization |
| 3 |
// adapted from Perry's ChucK Drummin' + Ge's sine poops |
| 4 |
// |
| 5 |
// authors: Perry Cook ([email protected]) |
| 6 |
// Ge Wang ([email protected]) |
| 7 |
// --------------------| |
| 8 |
// add one by one into VM (in pretty much any order): |
| 9 |
// |
| 10 |
// terminal-1%> chuck --loop |
| 11 |
// --- |
| 12 |
// terminal-2%> chuck + otf_01.ck |
| 13 |
// (anytime later) |
| 14 |
// terminal-2%> chuck + otf_02.ck |
| 15 |
// (etc...) |
| 16 |
//--------------------------------------| |
| 17 |
|
| 18 |
// this synchronizes to period |
| 19 |
.5::second => dur T; |
| 20 |
T - (now % T) => now; |
| 21 |
|
| 22 |
// construct the patch |
| 23 |
SndBuf buf => Gain g => dac; |
| 24 |
// read in the file |
| 25 |
me.dir() + "data/kick.wav" => buf.read; |
| 26 |
// set the gain |
| 27 |
.5 => g.gain; |
| 28 |
|
| 29 |
// time loop |
| 30 |
while( true ) |
| 31 |
{ |
| 32 |
// set the play position to beginning |
| 33 |
0 => buf.pos; |
| 34 |
// randomize gain a bit |
| 35 |
Math.random2f(.8,.9) => buf.gain; |
| 36 |
|
| 37 |
// advance time |
| 38 |
1::T => now; |
| 39 |
} |