// po-tweet! //=== TODO: modify this path and name for your system ===// "/Users/thealphanerd/github/ccrma/220a/hw1/" => string dataDir; "oscar_piracy.dat" => string dataFile; // update rate in ms 10.0 => float update; // new class to manage envelopes 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); } } // patch SinOsc s => dac; // gain .4 => s.gain; DataReader drywhite; drywhite.setDataSource(dataDir + dataFile); drywhite.start(); while (!drywhite.isFinished()) { // next data point, scaled in 0.0 - 1.0 range drywhite.scaledVal() => float w; chirp( (40.0 + w*30.0), 120, 1.5::second, 100::ms ); update::ms => now; } // call chirp //chirp( 127, 20, 1::second ); // call chirp (with tinc) // chirp( 20, 120, 1.5::second, 100::ms ); // chirp function fun void chirp( float src, float target, dur duration ) { chirp( src, target, duration, 1::ms ); } // chirp function (with tinc) fun void chirp( float src, float target, dur duration, dur tinc ) { // initialize freq src => float freq; // find the number of steps duration / tinc => float steps; // find the inc ( target - src ) / steps => float inc; // counter float count; // do the actual work over time while( count < steps ) { // increment the freq freq + inc => freq; // count 1 +=> count; // set the freq Std.mtof( freq ) => s.freq; // advance time tinc => now; } }