200.0 => float update; 4 => int nInsts;//set number of instruments StkInstrument inst[nInsts]; Moog moog @=> inst[0] => dac.chan(0); Wurley wurl @=> inst[1] => dac.chan(1); Mandolin mand @=> inst[2] => dac.chan(2); BlowBotl bot @=> inst[3] => dac.chan(3); moog => NRev rev => dac; wurl => rev=> dac; mand => Echo ech => dac; bot => Chorus chr => dac; rev.mix(0.05); rev.gain(1.0); "/user/c/cbeachy/Library/Web/220a/" => string dataDir; //might have to start it at Library class Env { Step s => Envelope e => blackhole; // feed constant into env update::ms => e.duration; // set ramp time fun void target (float val) { e.target(val); } } class Amp extends Env // for gain { fun void run() // sample loop to smoothly update gain { while (true) { moog.gain(e.last()); 1::samp => now; } } spork ~ run(); // run run }; class Freq extends Env // for freq { fun void run() { while (true) { moog.freq(e.last()); 1::samp => now; } } spork ~ run(); // run run }; Amp amp; // instantiate both Freq freq; ////////////////////////////////////////// //New Class contained above /////////////////////////////////////// DataReader treerings; treerings.setDataSource(dataDir + "treerings.dat"); treerings.start(); DataReader grain; grain.setDataSource(dataDir + "grain.dat"); grain.start(); DataReader pursesnatch; pursesnatch.setDataSource(dataDir + "pursesnatch.dat"); pursesnatch.start(); fun void treeBeeps(DataReader read, int update) { while (!read.isFinished()) { // next data points, scaled in 0.0 - 1.0 range read.scaledVal() => float val; amp.target(0.5 * Math.pow(val, 2.0)); freq.target(Std.mtof(80.0 + val*20.0)); update::ms => now; } } fun void moreBeeps(DataReader read, int instr, int update) { while (! read.isFinished()) { read.scaledVal() => float val; 2.0 * Math.pow(val, 2.0)=>inst[instr].noteOn; Std.mtof(20.0 + val*50.0)=>inst[instr].freq; update::ms => now; } } spork ~ treeBeeps(treerings, 900); spork ~ moreBeeps(pursesnatch, 3, 900); spork ~ moreBeeps(grain, 2, 900); 10::second => now; spork ~ moreBeeps(treerings, 1, 20); 5:: second => now; spork ~ moreBeeps(treerings, 3, 100); 20::second => now;