Homework 2 is about synthesizing an auditory streaming illusion using FM tones.
What if your preloaded class just needs a small tweak? For example, adding some chorusing and reverb to the IsoRhythm class (after it gets preloaded). Use "extend" to create a subclass that inherits everything in the superclass and adds some tweaks.
The live code below respects the stereo panned output, keeping left and right signals separate all the way through the dac. It only adds effects to the first instrument and that in itself is enough to enhance the auditory streaming effect. For more craziness, the suggestion below applies chorus and reverb to all instruments -- but watch out for gains!
////////////////////////////////////////////////////class IsoRev extends IsoRhythm { 2 => int nChans; Chorus crs[nChans]; NRev rev[nChans]; for (0 => int i; i < nInsts; i++) for (0 => int ch; ch < nChans; ch++) { stereo[i].chan(ch) => crs[ch] => rev[ch] => dac.chan(ch); } for (0 => int i; i < nInsts; i++) fm[i].gain(0.05); } IsoRev iso[3]; spork ~iso[0].play(30::second, 0.97, 160::ms); 1::second => now; spork ~iso[1].play(29::second, 0.96, 150::ms); 1::second => now; spork ~iso[2].play(48::second, 0.95, 140::ms); 30::second => now; IsoRev iso2[3]; spork ~iso2[0].play(30::second, 0.97, 160::ms); 1::second => now; spork ~iso2[1].play(29::second, 0.96, 150::ms); 1::second => now; spork ~iso2[2].play(28::second, 0.95, 140::ms); 30::second => now;
class IsoRev extends IsoRhythm { 2 => int nChans; Chorus crs[nChans]; NRev rev[nChans]; for (0 => int ch; ch < nChans; ch++) { stereo[0].chan(ch) => crs[ch] => rev[ch] => dac.chan(ch); } for (0 => int i; i < nInsts; i++) fm[i].gain(0.1); } IsoRev iso; // instantiate an IsoRev object spork ~ iso.play(15::second, 0.9, 40::ms); 20::second => now; 1::week => now;