//----------------------------| // on-the-fly synchronization // adapted from Perry's ChucK Drummin' + Ge's sine poops // // authors: Perry Cook (prc@cs.princeton.edu) // Ge Wang (gewang@cs.princeton.edu) // // Modified by Chris Weil // --------------------|//--------------------------------------| // this synchronizes to period // note that .125 (sixteenths) was chosen to over original .500 (quarters); still synchronizes perfectly // with other otf pieces, however it allows the drum to have more freedom. .125::second => dur T; T - (now % T) => now; // construct the patch SndBuf buf => Gain g => dac; "data/snare-hop.wav" => buf.read; .6 => g.gain; // chosen fractal constant, bounds, and iteration density #(0.2, 0.6) => complex c; #(-1, -1) => complex lower_left; #(1, 1) => complex upper_right; 20 => int num_points_x; 20 => int num_points_y; 30 => int max_iter; // create j; defined above for ease Julia j; j.setC(c); j.setLowerLeft(lower_left); j.setUpperRight(upper_right); j.setNumPointsX(num_points_x); j.setNumPointsY(num_points_y); j.setMaxIter(max_iter); j.compute() @=> int iter_values[][]; // time loop for(0 => int row; row < num_points_x; row++) { for(0 => int column; column < num_points_y; column++) { // We play cur_iter # of eighth notes. iter_values[row][column] => int cur_iter; // But we round that UP to the nearest value of 4 to determine the number of beats, // which causes gaps. This is 8 if cur_iter is 6. This introduces space into the beat. Math.round( 4 * Math.ceil(cur_iter / 4)) \$ int => int num_notes; // Walk over each iteration (8 times in the example) for(0 => int note; note < num_notes; note++) { // Only playing if this is less than the number of iterations if(note < num_notes) { //play! 0 => buf.pos; Std.rand2f(.8,.9) => buf.gain; note::T => now; } } } }