(Yet another micro-language by Paul Batchelor)

LSYS is a tiny little language designed to produce l-systems. A grammar for a classic L-System could look like this:


The code is split up into three slices, delimited by the '|':

  1. The first slice dictates the initial axiom, 'a'.
  2. The second slice dictates the definition for 'a' to be 'ab'.
  3. The third slice dictates the definition for 'b' to be 'a'.

Once the code has been parsed, it can be used to generate a list, whose length is determined by the order N:

N | output

1 | a

2 | ab

3 | aba

4 | abaab

5 | abaababa

6 | abaababaabaab

7 | abaababaabaababaababa

And so on and so forth...

LSYS in Sporth

Lsys is implemented as a Sporth UGen. The ugen takes in 3 arguments. From left to right, they are:

  1. trigger signal, which iterates through the L-System
  2. The order N of the L-System (init-time only)
  3. The code itself.

The signal output by the LSYS ugen a number in the range of 0-35, which correspond to the base-36 numbering system:


In the example from the previous section, the signal would be alternating between 10 and 11.

Below is an example of lsys in action. The output of lsys is converted into a trigger signal, which feeds into an envelope generator, then modulates a sinusoidal signal. Layering l-systems with the same rules but different orders creates an interesting rhythmic phase effect:

 # L-Systems Test
 # Paul Batchleor
 # August 2016
 _tick var
 0.1 dmetro _tick set
 _tick get dup
 8 "a|a:ab|b:a" lsys 10 eq *
 0.01 0.01 0.01 tenvx 1000 0.4 sine *
 _tick get dup
 4 "a|a:ab|b:a" lsys 10 eq *
 0.01 0.01 0.01 tenvx 500 0.4 sine *
 _tick get dup
 3 "a|a:ab|b:a" lsys 10 eq *
 0.01 0.01 0.01 tenvx 1500 0.4 sine *

From a compositional standpoint, there is still much more exploration to be had.

LSYS as a standalone

LSYS can also be compiled as a standalone application in Sporth by running:

 make lsys

In the top-level Sporth directory. This will create the binary uti/lsys.

Alternatively, it can be compiled like this:

 gcc lsys.c -DLSYS_STANDALONE -o lsys

Where lsys.c is located in the ugens directory.

The standalone can be fed in code and the order as command line arguments:

 ./lsys 5 "01|0:121|1:01|2:1"

Which will produce the following string: