From CSWiki
// baseloop.ck
// constructing a percussion set
// Rasmus Kaj program implemented by Gary Williams
60::second / 125.0 => dur t4;
t4 / 2.0 => dur t8;
t4 / 4.0 => dur t16;
t4 / 8.0 => dur t32;
t4 * 2.0 => dur t2;
t4 * 4.0 => dur t1;
fun void taktpos(dur module, dur offset) {
module - ((now - offset) % module) => now;
}
0 => int fundamental;
fun void bassloop() {
Rhodey instr => dac;
0.7 => instr.gain;
while(true) {
taktpos(t1, 0::samp);
std.mtof((float)(2*12 + fundamental + 0)) => instr.freq;
0.8 => instr.noteOn;
t4 + t8 => now;
std.mtof((float)(2*12 + fundamental + 4)) => instr.freq;
0.6 => instr.noteOn;
t8 => now;
std.mtof((float)(2*12 + fundamental + 7)) => instr.freq;
0.7 => instr.noteOn;
t4 => now;
std.mtof((float)(2*12 + fundamental + 4)) => instr.freq;
0.6 => instr.noteOn;
}
}
// drive the base loop
taktpos(t1, t1 - 2::samp);
spork ~ bassloop();
// step through blues notes (...!)
while(true) {
7 + 0 => fundamental;
t1 * 4.0 => now;
7 + 5 => fundamental;
t1 * 2.0 => now;
7 + 0 => fundamental;
t1 * 2.0 => now;
7 + 7 => fundamental;
t1 => now;
7 + 5 => fundamental;
t1 => now;
7 + 0 => fundamental;
t1 * 2.0 => now;
}