"/Users/carlyncohen/Desktop/pigs.txt" => string dataFile; // update rate in ms 200.0 => float update; // new class to manage envelopes class Env { Step s => Envelope e => blackhole; // feed constant into env 25::ms => e.duration; // set ramp time fun void target (float val) { e.target(val); } } class Player { SinOsc s => NRev rev => dac; rev.mix(.005); 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 pig; pig.setDataSource(dataFile); pig.start(); Player p; while (!pig.isFinished()) { // next data point, scaled in 0.0 - 1.0 range pig.scaledVal() => float w; p.amp.target(0.5 * Math.pow(w, 2.0)); 50.0 + w*30 => float midi; Math.round(midi) => midi; p.freq.target(Std.mtof(midi)); update::ms => now; }