The examples below show two ways to implement this, with a different result.
(by jrh, 3/2006)
Here is an example of the 11th iteration, with a minimal trigger signal time difference of 0.042 ms.
Listen to the sound directly (mp3): // sound example 1 | // sound example 2
// interpreting set as amplitudes directly ( var modict, pat, level, ftrig; level = 8; ftrig = 3 ** level / 8; modict = IdentityDictionary[ 0 -> [0, 0, 0], 1 -> [1, 0, 1] ]; pat = Pseq([Prewrite( Pseq([1]), modict, level)], 1); d = { arg t_trig, freq=5000; var trig = Duty.ar(1 / ftrig, 0, Dseq(pat.asStream.all)); Ringz.ar(trig, freq, 0.01, 0.1) }.play; )
// sound example 1 // calculating time differences first, using them as trigger delta times. ( var modict, pat, level, times; level = 11; modict = IdentityDictionary[ 0 -> [0, 0, 0], 1 -> [1, 0, 1] ]; pat = Pseq([Prewrite( Pseq([1]), modict, level)], 1); times = pat.asStream.all.separate { |a,b| b == 1 and: { a == 0 } }.collect(_.size); d = { arg t_trig, freq=8000; var trig = TDuty.ar(Dseq(times) *SampleDur.ir, 0, 1.0, doneAction:2); Ringz.ar(trig, freq, 0.01, 0.1) }.play; )
note:
to use this example, Lazy Lindenmayer is required.// different levels as different trigger filter frequencies. ( var rules, pat, level, string, data, times; level = 9; rules = [ "0" -> "000", "1" -> "101" ]; string = "1"; string = string.rewriteString(rules, level); data = string.collectAs({|char| char.asString.asInteger }, Array); times = data.separate { |a,b| b == 1 and: { a == 0 } }.collect(_.size); d = { arg t_trig, freq=800; var u; u = (7..0).collect {|i| var trig, seq; seq = Dseq(times.clump(2 ** i).collect(_.sum).postcs); trig = TDuty.ar(seq * SampleDur.ir * 13, 0, 1.0, doneAction:2); Ringz.ar(trig, freq * i + 300, 0.03, 0.1) }; Splay.ar(u) }.play; )
// sound example 2 // use n sine waves in parallel, showing each level of rewriting separately ( var rules, pat, level, string, data, times, duration; level = 9; duration = 6; rules = [ "0" -> "000", "1" -> "101" ]; string = "1"; level.do { string = string.rewriteString(rules, 1); data = data.add( string.collectAs({|char| char.asString.asInteger }, Array) ) }; d = { arg t_trig, freq=300; var u; u = data.collect {|x, i| var amp, n; n = 3 ** i; amp = Duty.ar(Dseq([n.reciprocal * duration], n), 0, Dseq(x), doneAction:2); SinOsc.ar(freq * (i + 1), 0, 0.1 * amp) }; Splay.ar(u) }.play; )