// @title m220a-Player.ck // @desc a sample sound player goes with DataReader class // @author Chris Chafe (cc@ccrma) //=== TODO: modify this path and name for your system ===// "/user/c/cpang/Downloads/" => string dataDir; "erie.dat" => string dataFile; // update rate in ms 75.0 => float update; // new class to manage envelopes class Env { Step s => Envelope e => blackhole; // feed constant into env 5::ms => e.duration; // set ramp time fun void target (float val) { e.target(val); } } class Player { TriOsc s => Chorus cho => Echo ech => NRev rev => dac; cho.mix(0.50); cho.modDepth(.5); cho.modFreq(.5); ech.mix(.4); rev.mix(0.15); Env amp, freq; fun void run() // sample loop to smoothly update gain { while (true) { s.gain(amp.e.last()); s.freq(freq.e.last()); 1::samp => now; } } spork ~ run(); // run run } DataReader drywhite; drywhite.setDataSource(dataDir + dataFile); drywhite.start(); Player p; while (!drywhite.isFinished()) { // next data point, scaled in 0.0 - 1.0 range drywhite.scaledVal() => float w; p.amp.target(0.5 * Math.pow(w, 2.0)); p.freq.target(Std.mtof(30.0 + w*70.0)); update::ms => now; }