// name: soldenit.ck // desc: Final project for Music-220a, CCRMA, Stanford University // author: Oriol Nieto // date: Fall 2009 // Instruments SndBuf metronome => dac.chan(0); Mandolin s1 => JCRev r1 => dac.chan(1); Rhodey voc=> JCRev r2 => Echo echo_a => Echo echo_b => Echo echo_c => dac.chan(1); SinOsc s => JCRev r3 => dac.chan(1); // Mapping to the interface r1 => dac.chan(0); echo_c => dac.chan(0); r3 => dac.chan(0); // We use musical tempo, and symbolic durations 130 => int tempo; // integers 1,2,4,8 mean musical figures dur duration[9]; 240000::ms / ( 1 * tempo ) => duration[1]; // whole 240000::ms / ( 2 * tempo ) => duration[2]; // half 240000::ms / ( 4 * tempo ) => duration[4]; // quarter 240000::ms / ( 8 * tempo ) => duration[8]; // eighth (duration[4] + duration[8]) => duration[5]; // dotted quarter (duration[2] + duration[4]) => duration[3]; // dotted half // Metronome 0.1 => s1.bodySize; 0.2 => s1.pluckPos; 0.9 => s1.stringDamping; 0.5 => r1.gain; 0.1 => r1.mix; // Rhodey 0.9 => voc.gain; .8 => r2.gain; .7 => r2.mix; 10::ms => echo_a.max => echo_b.max => echo_c.max; duration[8] => echo_a.delay => echo_b.delay => echo_c.delay; .80 => echo_a.mix => echo_b.mix => echo_c.mix; // SinOsc .5 => r3.gain; .075 => r3.mix; Std.mtof( 0 ) => s.freq; // load built-in sounds "special:glot_ahh" => metronome.read; 4.0 => metronome.gain; // MIDI note constants 60 => int c; 72 => int C; 61 => int cs; 73 => int Cs; 62 => int d; 74 => int D; 63 => int ds; 75 => int Ds; 64 => int e; 76 => int E; 65 => int f; 77 => int F; 66 => int fs; 78 => int Fs; 67 => int g; 79 => int G; 68 => int gs; 80 => int Gs; 69 => int a; 81 => int A; 70 => int as; 82 => int As; 71 => int b; 83 => int B; 48 => int cc; 49 => int ccs; 50 => int dd; 51 => int dds; 52 => int ee; 53 => int ff; 54 => int ffs; 55 => int gg; 56 => int ggs; 57 => int aa; 58 => int aas; 59 => int bb; 36 => int ccc; 37 => int cccs; 38 => int ddd; 39 => int ddds; 40 => int eee; 41 => int fff; 42 => int fffs; 43 => int ggg; 44 => int gggs; 45 => int aaa; 46 => int aaas; 47 => int bbb; // Tune fragments. Each note is a pair of [MIDI note,duration] // Intro guitar [[E,8],[G,8],[b,8],[D,8],[Fs,8], [b,8], [C,8], [g,8], [B,3], [C,8],[G,8],[b,8],[D,8],[Fs,8],[b,8],[E,8],[G,8],[b,3], [E,8],[G,8],[b,8],[D,8],[Fs,8], [b,8], [C,8], [g,8], [B,3], [C,8],[G,8],[b,8],[D,8],[Fs,8],[b,8],[E,8],[G,8],[b,8] ] @=> int voice_g[][]; // Pre chorus guitar [[D,8], [A,8], [D+12,3], [a,8], [G,8], [D+12,4]] @=> int pre_chorus_g[][]; // Chorus guitar [[G,5], [E,5], [Fs,1], [Fs,4], [C,5], [B,5], [E,1], [E,4], [G,5], [E,5], [Fs,1], [Fs,4], [C,5], [B,5], [E,1], [E,4], [G,5], [E,5], [Fs,1], [Fs,4], [C,5], [B,5], [E,1], [E,4], [G,5], [E,5], [Fs,1], [Fs,4], [C,5], [B,5], [E,1] ] @=> int chorus_g[][]; // intro rhodey [[ee,5], [ffs,5], [cc,1], [cc,5], [bbb,5], [eee,1]] @=> int voice_r[][]; // verse rhodey [[ee,5], [ffs,5], [cc,1], [cc,5], [gg,5], [ee,1], [ee,5], [ffs,5], [cc,1], [cc,5], [aaa,5], [ddd,1], [ee,5], [ffs,5], [cc,1], [cc,5], [bbb,5], [eee,1], [eee,5], [fffs,5], [cc,1], [cc,5], [gg,5], [ee,1], [ee,5], [ffs,5], [cc,1], [cc,5], [bbb,5], [eee,1], [eee,5], [fffs,5], [cc,1], [cc,5], [aaa,5], [ddd,1] ] @=> int verse_r[][]; // pre chorus rhodey [[ddd,1], [aaa,4]] @=> int pre_chorus_r[][]; // chorus rhodey [[ee,5], [cc,5], [aaa,1], [aaa,4], [cc,5], [dd,5], [eee,1], [eee,4], [ee,5], [cc,5], [aaa,1], [aaa,4], [cc,5], [ggg,5], [eee,1], [eee,4], [ee,5], [cc,5], [aaa,1], [aaa,4], [cc,5], [dd,5], [eee,1], [eee,4], [ee,5], [cc,5], [aaa,1], [aaa,4], [cc,5], [ggg,5], [eee,1] ] @=> int chorus_r[][]; // scale for sine_olla 48 => int octave; [e+octave, g+octave, b+octave, E+octave, G+octave, B+octave, E+(octave+12)] @=> int voice_sine_olla[]; // Second guitar part 1 fun void second_guitar( ) { for( 0 => int i; i < voice_g.cap(); i++) { if ( voice_g[i][0] > 0 ) { Std.mtof( voice_g[i][0] ) => s1.freq; 1.0 => s1.pluck; } duration[voice_g[i][1]] => now; } } // Rhodey Intro fun void intro_rhodey( ) { for( 0 => int i; i < voice_r.cap(); i++) { if ( voice_r[i][0] > 0 ) { Std.mtof( voice_r[i][0] ) => voc.freq; 1.0 => voc.noteOn; } duration[voice_r[i][1]] => now; } } // Rhodey Verse fun void verse_rhodey( ) { for( 0 => int i; i < verse_r.cap(); i++) { if ( verse_r[i][0] > 0 ) { Std.mtof( verse_r[i][0] ) => voc.freq; 1.0 => voc.noteOn; } duration[verse_r[i][1]] => now; } } // Rhodey Pre-Chorus fun void pre_chorus_rhodey( ) { for( 0 => int i; i < pre_chorus_r.cap(); i++) { if ( pre_chorus_r[i][0] > 0 ) { Std.mtof( pre_chorus_r[i][0] ) => voc.freq; 1.0 => voc.noteOn; } duration[pre_chorus_r[i][1]] => now; } } // Secong Guitar Pre-Chorus fun void pre_chorus_guitar( ) { for( 0 => int i; i < pre_chorus_g.cap(); i++) { if ( pre_chorus_g[i][0] > 0 ) { Std.mtof( pre_chorus_g[i][0] ) => s1.freq; 1.0 => s1.noteOn; } duration[pre_chorus_g[i][1]] => now; } } // Secong Guitar Chorus fun void chorus_guitar( ) { for( 0 => int i; i < chorus_g.cap(); i++) { if ( chorus_g[i][0] > 0 ) { Std.mtof( chorus_g[i][0] ) => s1.freq; 1.0 => s1.noteOn; } duration[chorus_g[i][1]] => now; } } // Rhodey Chorus fun void chorus_rhodey( ) { for( 0 => int i; i < chorus_r.cap(); i++) { if ( chorus_r[i][0] > 0 ) { Std.mtof( chorus_r[i][0] ) => voc.freq; 1.0 => voc.noteOn; } duration[chorus_r[i][1]] => now; } } // Verse Sine fun void sine_olla( ) { for( 0 => int i; i < 208; i++) { //Std.rand2f( 3000.0, 9000.0 ) => s.freq; Std.rand2( 0, 6) => int j; Std.mtof( voice_sine_olla[j] ) => s.freq; //<<< i >>>; (.5 - (j/256.0))*0.3 => s.gain; duration[8]/2 => now; } 0.0 => s.freq; } // Metronome! fun void clap( SndBuf buffy ) { // 7/4 -> 3/4 + 4/4 0 => int beat; 4 => int bar; 0 => int nbars; // infinite time loop while( 1 ) { // Start of a bar if (beat % bar == 0) { nbars + 1 => nbars; // We are at bar: <<< "Bar: ", nbars >>>; // Enter second guitar if (nbars == 13) { spork ~ second_guitar(); } // Enter rhodey if (nbars == 17) { spork ~ intro_rhodey(); } // Verse Starts if (nbars == 21) { spork ~ verse_rhodey( ); } // Olla start if (nbars == 29) { spork ~ sine_olla( ); } // Second verse if (nbars == 46) { spork ~ verse_rhodey(); } // Second Olla if (nbars == 54) { spork ~ sine_olla(); } // Pre-Chorus if (nbars == 70) { spork ~ pre_chorus_rhodey(); spork ~ pre_chorus_guitar(); } // Chorus if (nbars == 72) { spork ~ chorus_rhodey(); spork ~ chorus_guitar(); } // Second Olla for Chorus if (nbars == 80) { spork ~ sine_olla(); } // Verse (88-92 pre verse) if (nbars == 91) { spork ~ verse_rhodey(); } // Pre-Chorus II if (nbars == 115) { spork ~ pre_chorus_rhodey(); spork ~ pre_chorus_guitar(); } // Chorus II if (nbars == 117) { spork ~ chorus_rhodey(); spork ~ chorus_guitar(); } // Second Olla for Chorus II if (nbars == 125) { spork ~ sine_olla(); } // Solo base (verse) if (nbars == 133) { spork ~ verse_rhodey(); } // Pre-Chorus III if (nbars == 157) { spork ~ pre_chorus_rhodey(); } // Chorus III if (nbars == 159) { spork ~ chorus_rhodey(); spork ~ chorus_guitar(); } // Second Olla for Chorus III if (nbars == 167) { spork ~ sine_olla(); } 50.0 => buffy.freq; 0 => beat; if (bar == 3 && nbars != 46 && nbars != 91) { 4 => bar; } else if (bar == 4 && (nbars < 70 || nbars >= 88) && (nbars < 115 || nbars >= 133) && (nbars < 157 || nbars >= 175)) { 3 => bar; } } else { 30.0 => buffy.freq; } //std.mtof( 46 ) => voc.freq; //0.5 => voc.noteOn; if ( nbars < 175) { // clap! 0 => buffy.pos; beat + 1 => beat; } duration[4] => now; } } // spork one clapper, shift every shift_period measures spork ~ clap( metronome ); // infinite time loop while( true ) 1::day => now;