//This code is based off of a CCRMA example by Ge Wang //Write to file dac => WvOut2 writer => blackhole; writer.wavFilename("/Users/catrian/Desktop/fan_filtered.wav"); SndBuf buffy; "/Users/catrian/Desktop/" => string dataDir; "fan.wav" => string dataFile; // delay DelayL delay => dac; delay => Gain g => delay; // max 1::second => delay.max; // load dataDir + dataFile => buffy.read; // silence it 0 => buffy.gain; while( true ) { // play it! play( buffy, delay, .5, 64, .9, 2::second ); play( buffy, delay, .5, 62, .9, 2::second ); play( buffy, delay, .5, 60, .9, 4::second ); // advance time .05::second => now; play( buffy, delay, .5, 60, .9, 2::second ); play( buffy, delay, .5, 59, .9, 2::second ); play( buffy, delay, .5, 60, .9, 2::second ); play( buffy, delay, .5, 55, .9, 2::second ); } fun void play( SndBuf buf, DelayL delay, float gain, float pitch, float attenuation, dur T ) { // connect buf => delay; // attenuation attenuation => g.gain; // freq pitch => Std.mtof => float freq; // sample rate second / samp => float SRATE; // delay in samples (SRATE / freq)::samp => delay.delay; // set the playhead 0 => buf.pos; // set the gain gain => buf.gain; // advance T => now; // disconnect buf =< delay; }