// relooper in chuck // dna(at)basilar(dot)net // shuffles from max/msp's relooper (0s were converted to next block value) [[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16], [1,5,12,11,3,9,7,8,6,3,5,12,14,15,9,16], [1,2,3,11,5,6,7,5,5,8,8,9,6,5,5,16], [1,2,5,7,9,14,13,14,14,15,16,15,14,11,9,16], [3,4,5,6,13,14,15,16,14,15,16,17,9,8,9,10], [1,5,9,2,12,4,5,11,4,7,13,12,9,8,9,16], [5,13,12,11,12,13,14,15,9,5,6,15,7,8,12,13], [1,2,5,8,9,8,7,11,5,15,5,15,14,15,9,16], [16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1], [1,5,11,8,9,5,6,5,8,13,5,13,5,2,11,15], [3,1,1,8,9,5,6,5,8,13,5,13,5,2,11,15], [4,1,1,10,9,3,6,5,8,11,5,13,5,2,11,15], [3,4,5,6,13,14,15,16,14,13,1,2,9,10,11,12], [3,4,5,6,13,14,15,1,14,13,1,2,9,10,11,12], [3,4,5,6,13,14,1,2,14,1,2,3,9,10,11,14], [3,4,5,6,13,14,1,2,14,1,11,12,9,10,11,14], [5,6,7,8,13,14,1,2,14,1,11,12,9,10,11,14], [5,6,8,9,13,14,1,13,14,1,11,12,9,10,11,14], [16,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], [16,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], [16,1,2,3,4,5,6,7,8,9,10,11,10,11,12,13], [16,1,2,3,4,5,6,7,8,9,10,11,10,11,12,1], [16,1,2,3,4,5,6,7,8,9,10,11,10,11,12,1], [16,1,2,3,1,5,6,7,8,9,10,11,12,13,14,1], [16,1,2,3,1,5,6,5,13,7,8,9,10,11,12,1], [16,1,2,3,1,5,6,5,13,8,9,10,10,11,12,1], [16,1,2,3,1,5,6,5,13,9,10,11,10,11,12,1], [16,1,2,3,1,5,6,5,13,10,11,12,10,11,12,1], [16,1,2,3,1,5,6,5,13,8,9,10,5,5,14,11], [1,1,9,10,11,5,6,5,13,8,9,10,5,13,14,11], [1,1,9,12,9,5,12,5,13,9,9,5,5,13,14,11], [1,1,9,12,9,5,12,5,13,9,9,5,9,13,14,11], [1,1,9,12,9,5,12,5,13,9,9,5,10,13,14,11], [1,1,9,12,9,5,12,5,13,9,10,5,10,13,14,11], [9,1,9,12,9,5,12,5,13,5,10,5,10,13,14,11]] @=> int shuffle_bank[][]; // ... SndBuf buf => dac; "jongly.aif" => buf.read; buf.samples() => int len; len/16 => int blocklen; int remap[len]; int bs; while(true) { // choose shuffle from 35 available at random Std.rand2(0, 34) => int idx; <<< "playing shuffle", idx >>>; shuffle_bank[idx] @=> int seq[]; // calculate remapping // NOTE: in fact, this should be precalculated outside the event // loop, but ChucK can cope with it here (realtime) too... -1 => int current_block; // "for" can overrun if last block is not complete => check if above 16 for(0 => int c; c < len && (c/blocklen => int cb) <16; c++) { // execute only once, on first sample of each block if(cb != current_block) { cb => current_block; // start offset of first sample of block from shuffle (seq[current_block]-1)*blocklen => bs; } // offset of actual sample within selected block c%blocklen => int asb; bs + asb => remap[c]; } // play buffer using remap[] for(0 => int i; i buf.pos; 1::samp => now; } }