/* Krishan Kumar First file for composition for hw 4 based off the lab command line: chuck clip_flu.ck */ fun void playNoteClip(dur length, int pitch, float vibFreq, float vibGain, float breathPressure, float noiseGain, int cresc ) { //our flute Flute c => dac; //if cresc, long attack time if(cresc == 1) spork ~ clarGain(c, length); // set physical model parameters noiseGain => c.noiseGain; vibFreq => c.vibratoFreq; vibGain => c.vibratoGain; breathPressure => c.pressure; Std.mtof( pitch ) => c.freq; //making a small tail for the note so it doesn't clip length / 10 => dur noteTail; //start note <<<"\tnote start at",now/second,"seconds">>>; Math.random2f( .6, .9 ) => c.noteOn; //note the method of starting and stopping the physical model //play note length - noteTail => now; //end note 1 => c.noteOff; noteTail => now; <<<"\tnote end at",now/second,"seconds">>>; } //this function controls the gain of the Clarinet over the course of a note, and is bounded by that note length //it is designed to be called within playNoteClip() fun void clarGain(Flute c, dur length) { now + length => time later; while ( now < later ) { //values go from 0 to 1 - as now approaches later, the second half (in the //parentheses) goes to 0. 1 - ((later - now) / length) => c.gain; 10::samp => now; } } //percussion Shakers shaker => dac; fun void percuss() { Math.random2(1,4) => shaker.preset; Math.random2f(50.0,110) => shaker.objects; Math.random2f(.8,1.0) => shaker.decay; shaker.noteOn(Math.random2f(0.0, 4.0)); } 1::second => dur silDur; now + 1::minute => time later; dac => WvOut2 out => blackhole; me.sourceDir() + "Kumar_hw4.wav" => string _capture; _capture => out.wavFilename; while (now now; spork ~ playNoteClip(1::second, 74, 3.0, 0.3, 1.0, 0.5, 1); now + silDur => now; spork ~ playNoteClip(1::second, 76, 3.0, 0.3, 1.0, 0.5, 1); now + silDur => now; spork ~ playNoteClip(1::second, 78, 3.0, 0.3, 1.0, 0.5, 1); now + silDur => now; spork ~ playNoteClip(1::second, 80, 3.0, 0.3, 1.0, 0.5, 1); now + silDur => now; spork ~ playNoteClip(1::second, 82, 3.0, 0.3, 1.0, 0.5, 1); now + silDur => now; spork ~ playNoteClip(1::second, 84, 3.0, 0.3, 1.0, 0.5, 1); now + silDur => now; spork ~ playNoteClip(1::second, 86, 3.0, 0.3, 1.0, 0.5, 1); now + silDur => now; percuss(); spork ~ playNoteClip(1::second, 88, 3.0, 0.3, 1.0, 0.5, 1); now + silDur => now; spork ~ playNoteClip(1::second, 90, 3.0, 0.3, 1.0, 0.5, 1); now + silDur => now; spork ~ playNoteClip(1::second, 92, 3.0, 0.3, 1.0, 0.5, 1); now + silDur => now; spork ~ playNoteClip(1::second, 94, 3.0, 0.3, 1.0, 0.5, 1); now + silDur => now; spork ~ playNoteClip(1::second, 96, 3.0, 0.3, 1.0, 0.5, 1); now + silDur => now; percuss(); } // last item in this program is this print statement <<<"program end at",now/second,"seconds">>>; // and with nothing left to do this program exits out.closeFile();