Prewrite / L-system pattern help

Hello everyone

I have never really dabbled with the Prewrite class for making L-system patterns but now that I am trying it I find it a bit confusing.

In the example below, I try to construct a Lindenmayer melody using three very basic melodic components. One going up, one going down and one random. But the Prewrite class seems to be stuck in the first sentence of it’s dictionary. Can anyone tell me what I am doing wrong here? Thanks

(
	// Up
	Pdef(\a, Pbind(\dur, 0.25, \degree, Pseq((0..3))));

	// Down
	Pdef(\b, Pbind(\dur, 0.25, \degree, Pseq((3..0))));

	// Scramble
	Pdef(\c, Pbind(\dur, 0.125, \degree, Pwhite(0,10, 8)));

	// Lindenmayer melody
	Psym(
		Prewrite(0, // start with 0
			(    
				0: #[\a, \b],
				1: #[\c, \a, \b],
				2: #[\a, \b, \c]
			), 2).trace
		).play
)

Aha, I actually misunderstood the role of the dict keys here. Here is a version that works as expected:

(
	// Up
	Pdef(\a, Pbind(\dur, 0.25, \degree, Pseq((0..3))));

	// Down
	Pdef(\b, Pbind(\dur, 0.25, \degree, Pseq((3..0))));

	// Scramble
	Pdef(\c, Pbind(\dur, 0.125, \degree, Pwhite(0,10, 8)));

	// Lindenmayer melody
	Psym(
		Prewrite(\a, // start with 0
			(    
				\a: #[\a, \b],
				\b: #[\c, \a],
				\c: #[\a, \b]
			), 4).trace
		).play
)
2 Likes

Cool idea embedding patterns in the L-System with Psym.