// Michael J. Wilson // Music 220a Fall 2010 // Final Project // This is the lead voice for the main theme section of the piece. It // should be strong but smooth; it has a short part but it should be // memorable. public class MainLead { //////////////////////////////////////////////////////////////////////////////// // Declarations //////////////////////////////////////////////////////////////////////////////// TriOsc instrument; 0.5 => instrument.width; // Max gain 1.0 => float gain; // Give this instrument channel 9 instrument => Chorus cor => NRev rev => Control.chan[9]; 0.05 => rev.mix; 0.1 => cor.modFreq; 0.3 => cor.modDepth; 1.0 => cor.mix; Envelope amp; Envelope freq; 9.0 => float update; update::ms => amp.duration; update::ms => freq.duration; Step sa => amp => blackhole; Step sf => freq => blackhole; // Smoothly update amplitdude and frequency fun void run() { while (true) { amp.last() => instrument.gain; freq.last() => instrument.freq; 1::ms => now; } } // Mute instrument to start 0.0 => instrument.gain; // Play a note fun void play_note( float n, float beats ) { Std.mtof(n) => instrument.freq; Std.mtof(n) => freq.value; Std.mtof(n) => freq.target; gain => amp.target; Control.beat * beats * 0.9 => now; 0.0 => amp.target; Control.beat * beats * 0.1 => now; } fun void gliss_note( float n1, float n2, float beats) { Std.mtof(n1) => instrument.freq; Std.mtof(n1) => freq.value; Std.mtof(n2) => freq.target; Control.beat/2 => freq.duration; gain => amp.target; Control.beat * beats * 0.9 => now; 0.0 => amp.target; Control.beat * beats * 0.1 => now; update::ms => freq.duration; } fun void rest(float beats) { Control.beat * beats => now; } //////////////////////////////////////////////////////////////////////////////// // Sequences //////////////////////////////////////////////////////////////////////////////// fun void A1() { play_note(66, .75); play_note(78, .75); play_note(77, .75); play_note(78, .75); play_note(73, .5); play_note(66, .5); } fun void A2() { play_note(71, .75); play_note(78, .75); play_note(77, .75); play_note(78, .75); play_note(73, .25); play_note(75, .25); play_note(78, .5); } fun void A3() { gliss_note(72, 75, .75); play_note(78, .75); gliss_note(75, 77, .75); play_note(78, .5); rest(.25); play_note(73, .5); play_note(66, .5); } fun void A4() { play_note(75, .75); play_note(73, .75); gliss_note(69, 68, .75); play_note(66, .25); play_note(68, .50); play_note(66, 1); } fun void A5() { A1(); } fun void A6() { A2(); } fun void A7() { A3(); } fun void A8() { A4(); } fun void B1() { rest(4); } fun void B2() { rest(4); } fun void B3() { rest(4); } fun void B4() { rest(4); } fun void B5() { rest(4); } fun void B6() { rest(4); } fun void B7() { rest(4); } fun void B8() { rest(4); } fun void C1() { A1(); } fun void C2() { A2(); } fun void C3() { A3(); } fun void C4() { A4(); } fun void C5() { A1(); } fun void C6() { A2(); } fun void C7() { A3(); } fun void C8() { A4(); } fun void D1() { play_note(66, .75); play_note(78, .75); play_note(77, .75); // Note this goes into the next measure; a little custom to get // volume drop Std.mtof(78) => instrument.freq; Std.mtof(78) => freq.value; Std.mtof(78) => freq.target; gain => amp.target; Control.beat * 1.75 * 0.9 => now; 0.5 => amp.target; Control.beat * 1.75 * 0.1 => now; Control.beat * 4 * 0.9 => now; 0 => amp.target; Control.beat * 4 * 0.1 => now; } fun void D2() { // Don't need to rest because of previous sequence } fun void D3() { play_note(75, .75); play_note(78, .75); play_note(77, .75); play_note(78, .75); play_note(73, .5); play_note(66, .5); } fun void D4() { A4(); } fun void D5() { D1(); } fun void D6() { // Don't need to rest because of previous sequence } fun void D7() { A3(); } fun void D8() { A4(); } //////////////////////////////////////////////////////////////////////////////// // Play sequences //////////////////////////////////////////////////////////////////////////////// fun void play() { spork ~ run(); A1(); A2(); A3(); A4(); A5(); A6(); A7(); A8(); B1(); B2(); B3(); B4(); B5(); B6(); B7(); B8(); C1(); C2(); C3(); C4(); C5(); C6(); C7(); C8(); D1(); D2(); D3(); D4(); D5(); D6(); D7(); D8(); 0.0 => instrument.gain; } }