[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-users] lindenmayer
There is a new version of the rewriting system extensions:
http://swiki.hfbk-hamburg.de:8888/MusicTechnology/727
Rules can be now fully context-sensitive and rewriting can be done
on any recursion level n without iterating through the whole string
n times. This allows dynamic or stream based axioms (resulting in an
L-system-filter).
here is a sound example
(
var w, b, u, f, z, level=0;
w = SCWindow("test", Rect(40, 240, 200, 200)).front;
w.view.decorator = FlowLayout(w.bounds.copy.left_(30).top_(30));
b = { |i| { |j|
var c = ({ "abcd".choose } ! 3).join;
SCButton(w, Rect(0,0, 30,25))
.states_([[c, Color.black]])
.action_({ f.(c) })
.font_(Font(\Georgia, 11))
} ! 4; w.view.decorator.nextLine } ! 4;
w.view.decorator.nextLine;
SCButton(w, Rect(0,0, 30,25))
.states_({ |i| [i.asString, Color.black]} ! 16)
.action_({ |b| level = b.value });
r = [
"aa" -> "aba.b",
"ba" -> "....aa",
"c" -> "ddba",
"." -> "b.",
"dd" -> { #[".c", "c.", "ld"].choose }
];
(
SynthDef(\p, { |out = 0, freq=400, amp=0.4, sustain=0.04|
OffsetOut.ar(out,
SinOsc.ar(freq)
* XLine.ar(amp, amp * 0.001, sustain, doneAction: 2)
);
}).store;
);
u = { |str|
fork {
var m = str.iter.rewriteString(r, level);
var b;
Char.nl.post;
loop {
b = m.next;
if(a.notNil and: b.isNil) { "\n".post };
(b ? "").post;
if(b.isNil) { nil.yield };
Synth.grain(\p, [\freq, b.ascii - 97 * 200 + 300]);
0.04.wait;
}
}
};
f = { |c| u.(c); };
w.onClose = { u.stop };
)
--
.