// by Les Hall // the patch Gain volume => dac; 0.2 => volume.gain; SqrOsc osc1; 6 => osc1.freq; CD4040 counter1; osc1 => counter1.iClock; LOGIC logic1; for(int i; i<12; i++) { counter1.oCount[i] => logic1.iInput[i]; } SUM sum1; for(int i; i<12; i++) { logic1.oOutput[i] => sum1.iInput[i]; } sum1.oOutput => Gain freq => SqrOsc osc2 => volume; 1000 => freq.gain; 1 => osc2.op; // logic network class LOGIC { 12 => int max; Gain iInput[max]; for(int i; i blackhole; } Step oOutput[max]; function void logic() { int in[max]; while(true) { for(int i; i in[i]; } in[0] ^ in[1] => oOutput[0].next; in[2] ^ in[3] => oOutput[1].next; in[4] ^ in[5] => oOutput[2].next; in[6] ^ in[7] => oOutput[3].next; in[8] ^ in[9] => oOutput[4].next; in[10] ^ in[11] => oOutput[5].next; samp => now; } } spork ~ logic(); } // aggregator class SUM { 12 => int max; max => int weight; Gain iInput[max]; for(int i; i< max; i++) { iInput[i] => blackhole; } Step oOutput; function void sum() { while(true) { 0 => float sum; for (int i; i sum; } sum / weight => oOutput.next; samp => now; } } spork ~ sum(); } // 4040 counter class CD4040 { Gain iClock => blackhole; Step oCount[12]; function void counter() { 1<<12 => int max; int count; int iClockPrev; int iClockLast; while(true) { iClockLast => iClockPrev; iClock.last() $ int => iClockLast; if ( (iClockLast > 0.5 ) && (iClockPrev < 0.5) ) { (count + 1) % max => count; for(int i; i<12; i++) { (count >> i) & 1 => oCount[i].next; } } samp => now; } } spork ~ counter(); } // time loop while(true) { second => now; }