// by Les Hall 16 => int n; // number of bits in counter 4 => int m; // width of logic block 4 => int k; // depth of logic block 0 => int count; // the counter Math.pow(2, n) $ int => int countMax; // 2^n, the maximum counter value 440.0 => float ckFreq; // clock frequency second / ckFreq => dur ckPeriod; // clock period Step CD4040s[n]; NAND nand[m][k]; Gain sum => dac; for(int i; i nand[i][0].input[0]; CD4040s[Math.rand2(0,n-1)] => nand[i][0].input[1]; for(int j; j<(k-1); j++) { nand[Math.rand2(0,m-1)][j].output => nand[i][j+1].input[0]; nand[Math.rand2(0,m-1)][j].output => nand[i][j+1].input[1]; } nand[i][k-1].output => sum; } 1.0 / m => sum.gain; SinOsc beep => dac; 440.0 => beep.freq; 50::ms => now; 0.0 => beep.gain; class NAND { Gain input[2]; Gain output; input[0] => LPF f0 => Gain logic => FullRect fwr; input[1] => LPF f1 => logic; fwr => Gain sum; Step s1 => sum; logic => Gain div => output; sum => div; 1000 => f0.freq => f1.freq; 1 => logic.op; -1 => logic.gain; 1.0 => s1.next; 4 => div.op; 1.0 => input[0].gain; 1.0 => input[1].gain; 1.0 => output.gain; } while (count < countMax) { for (int i; i> i) & 1) * 2 - 1 => CD4040s[i].next; } count++; ckPeriod => now; }