«wiard noise ring, language implementation (task-based)» by LFSaw
on 20 Mar'13 19:49 in"In latter model synthesizers, digital noise sources began to appear in place of analog ones. Traditionally, a psuedo-random shift register set up for optimal length. By optimal length, it is meant that every state of all available bits will appear at some time, but the order is unknown. Essentially a counter that counts in an unknown order. This represents the maximum state of information "entropy" available for that number of bits. But music has close self-similarity over short periods of time. That is, it repeats itself with changes appearing slowly. This shift register generator is designed to give control of the rate of appearance of new information. It has a tight set of controls over how random it actually is and how fast change occurs. (text from http://mamonu.weebly.com/wiard-noisering.html)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
q = (); q.registerSize = 7; // max 64 q.rbuf = ((2**q.registerSize).asInteger).rand; // parameters, can be changed while playing // The higher change, the greater the chance for a new value q.change = 0.1; // The higher chance, the greater the chance the new value is HIGH q.chance = 0.5; q.waitTime = 0.01; // in seconds ( q.ror = {|q, x, shift, numBits| // shift right by m bits, input x is a number with numBits bits: var lsbs = x & ((1 << shift) - 1); (x >> shift) | (lsbs << (numBits-shift)); }; // do one step q.step = {|q, rbuf, change, chance| // rotate rbuf = q.ror(rbuf, 1, q.registerSize); // rbuf.asBinaryDigits(7).postln; (change.coin).if{ // swap bit //rbuf = rbuf.bitXor(1); rbuf = rbuf.setBit(0, chance.coin.postln); "+++++++ change!>>".postln; }; rbuf; // return (altered) item }; ( Tdef(\steppr, { loop{ q.rbuf = q.step(q.rbuf, q.change, q.chance); // debug output // q.rbuf.asArray.postln; // play the current note, can be basically everything ( midinote: q.rbuf, sustain: 0.01, dur: 0.2, amp: 0.2 ).play; q.waitTime.wait; } }) ); ) // start Tdef(\steppr).play // stop Tdef(\steppr).stop