58 lines · 1.2 KB · Text
RawDownload
//----------------------------|// 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)// --------------------|          // add one by one into VM (in pretty much any order):// // terminal-1%> chuck --loop// ---// terminal-2%> chuck + otf_01.ck// (anytime later)// terminal-2%> chuck + otf_02.ck// (etc...)//--------------------------------------| // this synchronizes to period.5::second => dur T;T - (now % T) => now; // one period offsetT => now; // construct the patchSndBuf buf => Gain g => dac;// read in from fileme.dir() + "data/snare-hop.wav" => buf.read;// set the gain.6 => g.gain; // where we actually want to start (in # of sample frames)100 => int where; // time loopwhile( true ){    // randomize the gain a bit    Math.random2f(.8,.9) => buf.gain;     // note: Math.randomf() returns value between 0 and 1    if( Math.randomf() > .25 )    {        // set play position to 'where'        where => buf.pos;        // advance time        2::T => now;    }    else    {        where => buf.pos;        .75::T => now;         .8 => buf.gain;        where => buf.pos;        1.25::T => now;    }}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t