| 1 |
// name: unclap.ck |
| 2 |
// desc: configurable "clapping music" (Steve Reich) |
| 3 |
// author: Jesus Gollonet (original) |
| 4 |
// Ge Wang (shreds and glottal pops) |
| 5 |
// date: Summer 2006 |
| 6 |
|
| 7 |
// our patch |
| 8 |
SndBuf clapper1 => dac.left; |
| 9 |
SndBuf clapper2 => dac.right; |
| 10 |
|
| 11 |
// load built-in sounds |
| 12 |
"special:glot_ahh" => clapper1.read; 3.0 => clapper1.gain; |
| 13 |
"special:glot_ahh" => clapper2.read; 3.0 => clapper2.gain; |
| 14 |
|
| 15 |
// the full "clapping music" figure |
| 16 |
[.5, .5, 1, .5, 1, 1, .5, 1 ] @=> float seq[]; |
| 17 |
|
| 18 |
// length of quarter note |
| 19 |
.4::second => dur quarter; |
| 20 |
// how many measures per shift |
| 21 |
3 => int shift_period; |
| 22 |
// how much to shift by (in quarter notes) |
| 23 |
.5 => float shift_factor; |
| 24 |
|
| 25 |
// one clapper |
| 26 |
fun void clap( SndBuf buffy, int max, float factor ) |
| 27 |
{ |
| 28 |
1 => int shifts; |
| 29 |
|
| 30 |
// infinite time loop |
| 31 |
for( ; true; shifts++ ) |
| 32 |
{ |
| 33 |
// one measure |
| 34 |
for( 0 => int count; count < seq.size(); count++ ) |
| 35 |
{ |
| 36 |
// set gain |
| 37 |
seq[count] * 2 => buffy.gain; |
| 38 |
// clap! |
| 39 |
0 => buffy.pos; |
| 40 |
// let time go by |
| 41 |
if( !max || shifts < max || count != (seq.size() - 1) ) |
| 42 |
seq[count]::quarter => now; |
| 43 |
else |
| 44 |
{ |
| 45 |
<<< "shift!!!", "" >>>; |
| 46 |
seq[count]*factor*quarter => now; |
| 47 |
0 => shifts; |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
// spork one clapper, shift every shift_period measures |
| 54 |
spork ~ clap( clapper1, shift_period, shift_factor ); |
| 55 |
// spork, no shift |
| 56 |
spork ~ clap( clapper2, 0, 0 ); |
| 57 |
|
| 58 |
// infinite time loop |
| 59 |
while( true ) 1::day => now; |