Debian Codegraph @

examples/otf_03.ck

raw
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 // extra half T offset
23 .5::T => now;
24
25 // construct the patch
26 SndBuf buf => Gain g => dac;
27 // read in from file
28 me.dir() + "data/hihat-open.wav" => buf.read;
29 // set the gain
30 .5 => g.gain;
31
32 // time loop
33 while( true )
34 {
35 // set play position to beginning
36 0 => buf.pos;
37 // randomize gain a bit
38 Math.random2f(.8,.9) => buf.gain;
39
40 // advance time
41 1::T => now;
42 }