// Final Project for 220A // The accompaniment // Composed and chucked by Cecilia Wu // Part One Maping ============================================================= // Create OSC objects and set them up OscSend xmit; xmit.setHost( "127.0.0.1", 8889 ); fun void sendMessage( int n, int t ) { // start packing OSC outgoing message with type tags xmit.startMsg( "/220a", "ii" ); // index number of image n => xmit.addInt; // transparency t => xmit.addInt; // then send! } //==================================================================== // Intro // Cecilia's Tibetan Horn Modulation VoicForm s => JCRev r => Echo a => Echo b => Echo c => dac; VoicForm s2 => r; VoicForm s3 => r; 1 => s.gain; 0.5 => s2.gain; 0.75=> s3.gain; 0.25 => r.mix; 8000::ms => a.max => b.max => c.max; 5000::ms => a.delay => b.delay => c.delay; 0.25 => a.mix => b.mix => c.mix; 0.5 => s.loudness; 0.01 => s.vibratoGain; 700::ms => dur noteDuration; // For chords spork ~ playMelody1( 60, 60, 65, 67 ); spork ~ playMelody2( 64, 64, 64, 67 ); spork ~ playMelody3( 67, 67, 67, 67 ); 21::second => now; //-------------------------------------------------------------------- //Set up Seven Instruments and their channels // Instrument One set up Wurley mand => JCRev q => Echo d => Echo e => Echo f => dac; Wurley mand2 => q; Wurley mand3 => q; // Gain 0.14 => mand.gain; 0.04 => mand2.gain; 0.004=> mand3.gain; // Effect 0.3 => q.mix; 1.5::second => d.max => e.max => f.max; 1::second=> d.delay => e.delay => f.delay; 0.25 => d.mix => e.mix => f.mix; 600::ms => dur noteDuration1; // Instrument Two & Channel set up Saxofony mog => JCRev P => dac.chan(2); 0.03=> mog.gain; 0.7=> P.mix; 300::ms => dur noteDuration2; // Instrument Three and Channel set up Mandolin di => JCRev W => dac.chan(3); 0.16=> di.gain; 0.15=> W.mix; 300::ms=> dur noteDuration5; // Instrument Four - Percussion set up Shakers shake => JCRev k => dac; 0.38=> shake.gain; 0.05=> k.mix; 300::ms => dur noteDuration3; // Instrument Five set up // Panning SinOsc V => blackhole; SinOsc V2 => blackhole; 1=>V.freq; 1=>V2.freq; 0.25 => V2.phase; ModalBar mao =>JCRev g => Pan2 pan; pan.left => dac.chan(2); pan.right => dac.chan(0); g => Pan2 panfr; panfr.left => dac.chan(1); panfr.right => dac.chan(3); 0.036=> mao.gain; 0.8 => g.mix; 75::ms=> dur noteDuration4; fun void oscil() { while ( true ) { //<<< V.last() >>>; V.last() => pan.pan; V2.last() => panfr.pan; 600::ms => now; } } spork ~ oscil(); // Instrument Six and Channel set up BandedWG mog1 => JCRev p => dac.chan(1); 1=> mog1.gain; 0.8=> p.mix; 300::ms => dur noteDuration6; // Instrument Seven set up later at the Coda //-------------------------------------------------------------------- // For Playing sequentially // Theme One // Wurley for Theme One spork ~ instrument1(); 33.6::second => now; repeat(6) playMelody5( 72, 67, 65, 60 ); repeat(6) playMelody5( 70, 67, 65, 58 ); repeat(6) playMelody5( 70, 65, 63, 56 ); repeat(2) playMelody5( 65, 60, 63, 53 ); // Theme Two // Multi-instruments spork ~ instrument3(); spork ~ instrument2(); spork ~ instrument4(); spork ~ instrument10(); 19::second => now; // Rings For Theme Two and Three spork ~ instrument6(); 19.4::second => now; // Theme Three spork ~ instrument5(); //spork ~ instrument6(); spork ~ instrument7(); 9.6::second => now; spork ~ instrument6(); spork ~ instrument8(); spork ~ instrument9(); 13.8::second => now; // Coda //End with a free style spork ~ instrument1(); 7::second => now; //Instrument Seven Set Up ModalBar modey => JCRev H => Echo M => Echo N => Echo O => dac; // set the gain .38 => H.gain; // set the reverb mix .25 => H.mix; // set max delay for echo 1.5::second => M.max => N.max => O.max; // set delay for echo 1::second => M.delay => N.delay => O.delay; // set the initial effect mix 0.25 => M.mix => N.mix => O.mix; // scale [ 0, 5, 7 ] @=> int scale[]; // Timing set up now + 56::second => time later; while( now < later ) { //presets if ( Std.randf() > 0.9 ) Std.rand2 (0,8) => modey.preset; // position Std.rand2f( 0.2, 0.8 ) => modey.strikePosition; // frequency... scale[Std.rand2(0,scale.cap()-1)] => int freq; Std.mtof( 60 + Std.rand2(0,4)*5 + freq ) => modey.freq; // pluck it! Std.rand2f( 0.2, 0.4 ) => modey.strike; sendMessage( Std.rand2(1, 35), 255 ); if( Std.randf() > 0.3 ) { 500::ms => now; sendMessage( 8, 255 ); } else if( Std.randf() > .4 ) { 250::ms => now; sendMessage( 3, 255 ); } else if( Std.randf() > -0.9 ) { .125::second => now; sendMessage( 19, 255 ); } else { 1 => int i => int pick_dir; // how many times 4 * Std.rand2( 1, 5 ) => int pick; 0.0 => float pluck; 0.65 / pick => float inc; // time loop for( ; i < pick; i++ ) { 150::ms => now; Std.rand2f(.2,.3) + i*inc => pluck; pluck => modey.stickHardness; pluck + -.2 * pick_dir => modey.strike; // simulate pluck direction !pick_dir => pick_dir; sendMessage( Std.rand2(1, 35), Std.rand2(127, 255) ); } // let time pass for final pluck 750::ms => now; } } sendMessage(23, 255); //-------------------------------------------------------------------- //Set up Notation to play the above instruments fun void instrument1() { repeat(7) playMelody4( 60, 67, 65, 72 ); repeat(3) playMelody4( 58, 67, 65, 70 ); repeat(3) playMelody4( 56, 65, 63, 70 ); repeat(1) playMelody4( 53, 63, 60, 65 ); repeat(3) playMelody4( 60, 67, 65, 72 ); repeat(3) playMelody4( 58, 67, 65, 70 ); repeat(3) playMelody4( 56, 65, 63, 70 ); repeat(1) playMelody4( 53, 60, 63, 65 ); } fun void instrument3() { repeat(2) playMelody4( 60, 67, 63, 67 ); repeat(2) playMelody4( 58, 67, 62, 67 ); repeat(2) playMelody4( 57, 65, 63, 65 ); repeat(1) playMelody4( 57, 65, 63, 65 ); repeat(1) playMelody4( 58, 62, 60, 67 ); repeat(2) playMelody4( 60, 67, 63, 67 ); repeat(2) playMelody4( 58, 67, 62, 67 ); repeat(2) playMelody4( 57, 65, 63, 65 ); repeat(1) playMelody4( 57, 65, 63, 65 ); repeat(1) playMelody4( 58, 62, 60, 67 ); } fun void instrument2() { repeat(4) playMelody5( 67, 63, 67, 60 ); repeat(4) playMelody5( 67, 62, 67, 58 ); repeat(4) playMelody5( 65, 63, 65, 57 ); repeat(2) playMelody5( 65, 63, 65, 57 ); repeat(2) playMelody5( 67, 60, 62, 58 ); repeat(4) playMelody5( 60 ,67, 63, 67 ); repeat(4) playMelody5( 67, 62, 67, 58 ); repeat(4) playMelody5( 65, 63, 65, 57 ); repeat(2) playMelody5( 65, 63, 65, 57 ); repeat(2) playMelody5( 67, 60, 62, 58 ); } fun void instrument4() { repeat(4) playMelody6( 67, 63, 67, 60 ); repeat(4) playMelody6( 67, 62, 67, 58 ); repeat(4) playMelody6( 65, 63, 65, 57 ); repeat(2) playMelody6( 65, 63, 65, 57 ); repeat(2) playMelody6( 58, 62, 60, 67 ); repeat(4) playMelody6( 67, 63, 67, 60 ); repeat(4) playMelody6( 67, 62, 67, 58 ); repeat(4) playMelody6( 65, 63, 65, 57 ); repeat(2) playMelody6( 65, 63, 65, 57 ); repeat(2) playMelody6( 58, 62, 60, 67 ); } fun void instrument5() { repeat(1) playMelody4( 60, 67, 72, 75 ); repeat(1) playMelody4( 79, 84, 79, 75 ); repeat(1) playMelody4( 58, 67, 70, 74 ); repeat(1) playMelody4( 79, 82, 79, 74 ); } fun void instrument6() { repeat(10) playMelody7(72, 79, 81, 82); repeat(20) playMelody7(71, 79, 81, 82); } fun void instrument7() { repeat(2) playMelody11( 60, 67, 72, 75 ); repeat(2) playMelody11( 60, 67, 72, 75 ); repeat(2) playMelody11( 58, 67, 70, 74 ); repeat(2) playMelody11( 58, 67, 70, 74 ); } fun void instrument8() { repeat(1) playMelody4( 60, 67, 72, 75 ); repeat(1) playMelody4( 79, 84, 79, 75 ); repeat(1) playMelody4( 57, 65, 67, 72 ); repeat(1) playMelody4( 74, 77, 75, 74 ); } fun void instrument9() { repeat(2) playMelody11( 60, 67, 72, 75 ); repeat(2) playMelody11( 60, 67, 72, 75 ); repeat(2) playMelody11( 57, 65, 67, 72 ); repeat(2) playMelody11( 74, 77, 75, 74 ); } fun void instrument10() { repeat(4) playMelody10( 60, 67, 60, 67 ); repeat(4) playMelody10( 58, 67, 62, 67 ); repeat(4) playMelody10( 63, 65, 57, 65 ); repeat(2) playMelody10( 57, 65, 63, 65 ); repeat(2) playMelody10( 58, 67, 60, 62 ); repeat(4) playMelody10( 63, 60, 67, 63 ); repeat(4) playMelody10( 62, 67, 58, 67 ); repeat(4) playMelody10( 57, 65, 63, 65 ); repeat(2) playMelody10( 57, 65, 63, 65 ); repeat(2) playMelody10( 58, 62, 60, 67 ); } //-------------------------------------------------------------------- // Functions to make some sound for the instuments; // Also send maping parameters to the processing fun void playMelody1( int p1, int p2, int p3, int p4 ) { 2 * Std.rand2( 3,3 ) => s.phonemeNum; Std.mtof( p1 ) => s.freq; s.noteOn( 0.9 ); sendMessage( 0, 255 ); noteDuration => now; s.noteOff( 0.0 ); Std.mtof( p2 ) => s.freq; s.noteOn( 0.9 ); sendMessage( 0, 255 ); noteDuration => now; s.noteOff( 0.0 ); Std.mtof( p3 ) => s.freq; s.noteOn( 0.9 ); sendMessage( 0, 255 ); noteDuration => now; s.noteOff( 0.0 ); Std.mtof( p4 ) => s.freq; s.noteOn( 0.9 ); sendMessage( 0, 255); noteDuration => now; s.noteOff( 0.0 ); } fun void playMelody2( int p1, int p2, int p3, int p4 ) { 2 * Std.rand2( 3,3 ) => s2.phonemeNum; Std.mtof( p1 ) => s.freq; s2.noteOn( 0.9 ); noteDuration => now; s2.noteOff( 0.0 ); Std.mtof( p2 ) => s.freq; s2.noteOn( 0.9 ); noteDuration => now; s2.noteOff( 0.0 ); Std.mtof( p3 ) => s.freq; s2.noteOn( 0.9 ); noteDuration => now; s2.noteOff( 0.0 ); Std.mtof( p4 ) => s.freq; s2.noteOn( 0.9 ); noteDuration => now; s2.noteOff( 0.0 ); } fun void playMelody3( int p1, int p2, int p3, int p4 ) { 2 * Std.rand2( 3,3 ) => s3.phonemeNum; Std.mtof( p1 ) => s.freq; s3.noteOn( 0.9 ); noteDuration => now; s3.noteOff( 0.0 ); Std.mtof( p2 ) => s.freq; s3.noteOn( 0.9 ); noteDuration => now; s3.noteOff( 0.0 ); Std.mtof( p3 ) => s.freq; s3.noteOn( 0.9 ); noteDuration => now; s3.noteOff( 0.0 ); } fun void playMelody4( int p1, int p2, int p3, int p4 ) { Std.mtof( p1 ) => mand.freq; mand.noteOn( 0.9 ); sendMessage( Std.rand2(1, 35), 255); noteDuration1 => now; //mand.noteOff( 0.0 ); Std.mtof( p2 ) => mand.freq; mand.noteOn( 0.9 ); sendMessage(Std.rand2(1, 35), Std.rand2(127, 255)); noteDuration1 => now; // mand.noteOff( 0.0 ); Std.mtof( p3 ) => mand.freq; mand.noteOn( 0.9 ); sendMessage( Std.rand2(1, 35), 255 ); noteDuration1 => now; // mand.noteOff( 0.0 ); Std.mtof( p4 ) => mand.freq; mand.noteOn( 0.9 ); sendMessage(Std.rand2(1, 35), Std.rand2(60, 255)); noteDuration1 => now; // mand.noteOff( 0.0 ); } fun void playMelody5( int p1, int p2, int p3, int p4 ) { Std.mtof( p1 ) => mog.freq; mog.noteOn( 0.9 ); sendMessage( Std.rand2(1,4), 255 ); noteDuration2 => now; mog.noteOff( 0.0 ); Std.mtof( p2 ) => mog.freq; mog.noteOn( 0.9 ); sendMessage(Std.rand2(5,8), 255 ); noteDuration2 => now; mog.noteOff( 0.0 ); Std.mtof( p3 ) => mog.freq; mog.noteOn( 0.9 ); sendMessage( Std.rand2(11,14), 255 ); noteDuration2 => now; mog.noteOff( 0.0 ); Std.mtof( p4 ) => mog.freq; mog.noteOn( 0.9 ); sendMessage(Std.rand2(16, 19), 255 ); noteDuration2 => now; mog.noteOff( 0.0 ); } fun void playMelody6( int p1, int p2, int p3, int p4 ) { Std.mtof( p1 ) => shake.freq; shake.noteOn( 0.9 ); sendMessage( Std.rand2(1, 35), 255); noteDuration3 => now; shake.noteOff( 0.0 ); Std.mtof( p2 ) => shake.freq; shake.noteOn( 0.9 ); sendMessage( Std.rand2(1, 35), Std.rand2(1, 255) ); noteDuration3 => now; shake.noteOff( 0.0 ); Std.mtof( p3 ) => shake.freq; shake.noteOn( 0.9 ); sendMessage( Std.rand2(1, 35), 255 ); noteDuration3 => now; shake.noteOff( 0.0 ); Std.mtof( p4 ) => shake.freq; shake.noteOn( 0.9 ); sendMessage(Std.rand2(1, 35), Std.rand2(60, 255)); noteDuration3 => now; shake.noteOff( 0.0 ); } fun void playMelody7( int p1, int p2, int p3, int p4 ) { Std.mtof( p1 ) => mao.freq; mao.noteOn( 0.9 ); sendMessage(Std.rand2(7,13), 225); noteDuration4 => now; //mand.noteOff( 0.0 ); Std.mtof( p2 ) => mao.freq; mao.noteOn( 0.9 ); sendMessage(16, 225); noteDuration4 => now; // mand.noteOff( 0.0 ); Std.mtof( p3 ) => mao.freq; mao.noteOn( 0.9 ); sendMessage(Std.rand2(18,24), 255); noteDuration4 => now; // mand.noteOff( 0.0 ); Std.mtof( p4 ) => mao.freq; mao.noteOn( 0.9 ); sendMessage(4, 225); noteDuration4 => now; // mand.noteOff( 0.0 ); } fun void playMelody8( int p1, int p2, int p3, int p4 ) { Std.mtof( p1 ) => mand2.freq; mand2.noteOn( 0.9 ); noteDuration1 => now; //mand.noteOff( 0.0 ); Std.mtof( p2 ) => mand2.freq; mand2.noteOn( 0.9 ); noteDuration1 => now; // mand.noteOff( 0.0 ); Std.mtof( p3 ) => mand2.freq; mand2.noteOn( 0.9 ); noteDuration1 => now; // mand.noteOff( 0.0 ); Std.mtof( p4 ) => mand2.freq; mand2.noteOn( 0.9 ); noteDuration1 => now; // mand.noteOff( 0.0 ); } fun void playMelody9( int p1, int p2, int p3, int p4 ) { Std.mtof( p1 ) => mand3.freq; mand3.noteOn( 0.9 ); noteDuration1 => now; //mand.noteOff( 0.0 ); Std.mtof( p2 ) => mand3.freq; mand3.noteOn( 0.9 ); noteDuration1 => now; // mand.noteOff( 0.0 ); Std.mtof( p3 ) => mand3.freq; mand3.noteOn( 0.9 ); noteDuration1 => now; // mand.noteOff( 0.0 ); Std.mtof( p4 ) => mand3.freq; mand3.noteOn( 0.9 ); noteDuration1 => now; // mand.noteOff( 0.0 ); } fun void playMelody10( int p1, int p2, int p3, int p4 ) { Std.mtof( p1 ) => di.freq; di.noteOn( 0.9 ); noteDuration5 => now; di.noteOff( 0.0 ); Std.mtof( p2 ) => di.freq; di.noteOn( 0.9 ); noteDuration5 => now; di.noteOff( 0.0 ); Std.mtof( p3 ) => di.freq; di.noteOn( 0.9 ); noteDuration5 => now; di.noteOff( 0.0 ); Std.mtof( p4 ) => di.freq; di.noteOn( 0.9 ); noteDuration5 => now; di.noteOff( 0.0 ); } fun void playMelody11( int p1, int p2, int p3, int p4 ) { Std.mtof( p1 ) => mog1.freq; mog1.noteOn( 0.9 ); noteDuration6 => now; mog1.noteOff( 0.0 ); Std.mtof( p2 ) => mog1.freq; mog1.noteOn( 0.9 ); noteDuration6 => now; mog1.noteOff( 0.0 ); Std.mtof( p3 ) => mog1.freq; mog1.noteOn( 0.9 ); noteDuration6 => now; mog1.noteOff( 0.0 ); Std.mtof( p4 ) => mog1.freq; mog1.noteOn( 0.9 ); noteDuration6 => now; mog1.noteOff( 0.0 ); }