// Michael J. Wilson // Music 220a Fall 2010 // Final Project // Backup / counter part for main lead public class MainBackup { //////////////////////////////////////////////////////////////////////////////// // Declarations //////////////////////////////////////////////////////////////////////////////// // Declare instrument TriOsc instrument; 0.75 => instrument.width; // Max gain 1.0 => float gain; // Give this instrument channel 11 instrument => Chorus cor => NRev rev => Control.chan[11]; 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() { rest(4); } fun void A2() { rest(4); } fun void A3() { rest(2.5); 0.5 => gain; play_note(54, .50); 1.0 => gain; rest(1); } fun void A4() { rest(4); } fun void A5() { rest(4); } fun void A6() { rest(4); } fun void A7() { A3(); } fun void A8() { 0.5 => gain; play_note(87, .75); play_note(85, .75); gliss_note(81, 80, .75); play_note(78, .25); play_note(80, .50); play_note(78, 1); 1.0 => gain; } fun void B1() { play_note(78, 0.75); play_note(66,0.25); rest(0.25); play_note(68,0.25); rest(0.25); play_note(70,1.25); play_note(73,.5); play_note(78,.5); } fun void B2() { play_note(82, 0.5); play_note(83, 0.25); play_note(82, 0.5); play_note(80, 0.25); play_note(78, 0.5); play_note(75, 0.25); rest(0.25); play_note(73, 0.25); rest(0.25); play_note(80, 0.5); play_note(78, 0.5); } fun void B3() { play_note(75, 1.0); play_note(78, 0.5); play_note(73, 1.5); play_note(78, 0.5); play_note(72, 1.5); } fun void B4() { // Note first beat is in previous measure play_note(78, 0.5); play_note(71, 2.0); rest(0.5); } fun void B5() { B1(); } fun void B6() { play_note(82, 0.5); play_note(83, 0.25); play_note(82, 0.5); play_note(80, 0.25); play_note(78, 0.5); play_note(87, 0.5); play_note(85, 0.5); gliss_note(82, 80, 0.5); play_note(78, 0.5); } fun void B7() { play_note(75, 1.0); play_note(78, 0.5); play_note(73, 1.5); play_note(78, 0.5); play_note(80, 0.5); } fun void B8() { play_note(83, 0.5); play_note(82, 0.5); play_note(78, 0.5); play_note(75, 0.5); play_note(73, 0.5); play_note(70, 0.5); play_note(69, 0.25); play_note(68, 0.25); play_note(66, 0.5); } fun void C1() { rest(4); } fun void C2() { rest(4); } fun void C3() { A3(); } fun void C4() { rest(4); } fun void C5() { rest(4); } fun void C6() { rest(4); } fun void C7() { A3(); } fun void C8() { rest(4); } fun void D1() { rest(3.5); 0.95 => instrument.width; play_note(61, .25); play_note(62, .25); 0.75 => instrument.width; } fun void D2() { 0.95 => instrument.width; play_note(63, .5); 0.75 => instrument.width; play_note(78, .25); 0.80 => instrument.width; play_note(78, .25); rest(.25); play_note(78, 0.25); rest(.25); 0.85 => instrument.width; play_note(78, 0.25); rest(.25); play_note(78, 0.25); rest(.25); play_note(75, 0.25); 0.80 => instrument.width; play_note(80, .5); play_note(78, .5); 0.75 => instrument.width; } fun void D3() { rest(4); } fun void D4() { rest(4); } fun void D5() { D1(); } fun void D6() { 0.95 => instrument.width; play_note(63, .5); 0.75 => instrument.width; play_note(78, .25); play_note(78, .25); rest(.25); 0.85 => instrument.width; play_note(75, 0.25); rest(.25); 0.75 => instrument.width; play_note(83, 0.25); rest(.25); 0.80 => instrument.width; play_note(82, 0.25); rest(.25); play_note(82, 0.25); 0.75 => instrument.width; play_note(80, .5); play_note(78, .5); 0.75 => instrument.width; } fun void D7() { A3(); } fun void D8() { rest(4); } //////////////////////////////////////////////////////////////////////////////// // 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; } }