//Demonstrates very simple additive synthesis //Generate a set of harmonics, each of equal strength //Comment out the sections you don't want SinOsc s[8]; 220 => float fundamental; //Set each frequency and connect to dac, but make silent for (0 => int i; i < s.size(); i++) { fundamental * (i+1) => s[i].freq; 0 => s[i].gain; s[i] => dac; } //Play each sine tone individually for (0 => int i; i < s.size(); i++) { .2 => s[i].gain; .5::second => now; 0 => s[i].gain; } //Rest 1::second => now; //Now bring in sines one at a time, keeping the lower frequencies on for (0 => int i; i < s.size(); i++) { .2 => s[i].gain; .5::second => now; } //Play all together 1::second => now; //Now play with a single onset: //First turn all off for (0 => int i; i < s.size(); i++) { 0 => s[i].gain; } //They're off: rest 1::second => now; //Turn them all on for (0 => int i; i < s.size(); i++) { .2 => s[i].gain; } //And advance time once everyone is on to create 1 onset 4::second => now; //Now add some vibrato spork ~ addvib(); 4::second => now; fun void addvib() { SinOsc m => blackhole; 5=> m.freq; .03 => m.gain; while (true) { for (0 => int i; i < s.size(); i++) { (m.last() + 1)*(fundamental * (i+1)) => s[i].freq; } 1::samp => now; } }