View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

L-Systems in SC



Lindenmayer-Systems

see also:


Lazy Lindenmayer
Lindenmayer Systems: Pictures


L-Systems assume a set of data, like a string, that is iteratively
rewritten using a set of rules.
A famous example is the (pre-Lindenmayer) Koch Snowflake (see there)
that one can produce by, staring from a triangle, replacing every straight
line by a shape that looks like this: __/\__
Again, each line in this shape is replaced by a scaled
copy of this shape each iteration.
It is easy to see that this process takes an exponential amount of work to be done with the raising number of iterations.

The resulting shape has the specific feature of being self-similar, each part looks similar to its components.
Depending on the rewriting rules there is a broad variety of forms that can be developed by using L-Systems and specialy some natural phaenomena can be modeled (or imitated), so they are used in biology to model things like plant growth.
further information: http://www.ldc.usb.ve/~gabro/lsys/lsys.html


The traditional L-System approach is a non-realtime approach as it uses a string that is iteratively rewritten completely before the result is returned. This has the advantage that each iteration all parts are known so that the system behaviour may depend on their state.


Within the (real-time) Pattern approach this procedure is modified so that the rewriting is done to the very end with each element in a row, in order to be less cpu intensive. That means each element is checked if it is noted in the rule dictionary, replaced by its associated value and again, as long the maximum numbers of levels is not exceeded, iteratively replaced. Only when there is no entry any more, meaning that the lookup returns nil, the element is yielded, more exactly it is embedded into the stream.



Needed for this procedure is

internally, the seeds are created from the pattern that used to create a stream
and once one rewriting process has reached the end, a new seed is obtained from the stream.

the ruleset is an IdentityDictionary mapping single elements to arrays of elements:
     
// the scale degree rewrite dictionary:
        degdict = IdentityDictionary[
                0 -> [0, 1, 2],
                1 -> [0, 1],
                2 -> [3, 2],
                3 -> [0, 3, \, 4],
                4 -> [5, 4, 2],
                5 -> [8, 7, 6, 7, 3],
                \ -> [\, 0, \]
        ];

so once the ruleset is done, the Prewrite can be used easily:
Prewrite(seedpattern, rewritedict, levels)

an example is in Sonification of the Cantor Set

using Pdef, one can do recursive phrasing in SuperColliderServer (SC3), which allows l-system
like recursion on the level of instruments and sound clusters.
There are examples in the distribution, under cmd-? with "recursive_phrasing" (JITLib)

jrh

Uploaded Image: plantz.gif

Links to this Page