Lindenmayer function

ok great! now we're getting somewhere! i will play around with the scale idea tonight. thanks again for taking the time to explain :slight_smile:

2 Likes

Meanwhile, I'm still battling to get my n and note usage correct :stuck_out_tongue:

Informative reading - thanks for digging @kit-christopher and thanks for the detailed explanations @mattia.paterna !

I might even get to a point where I try and use this one day :stuck_out_tongue:

3 Likes

@cleary note is probably my favorite/most used function so do reach out if you get into a bind!

Instead of take 512 and slow 16, is there a way to just get the next 32 and not use slow?
I would like to play all the elements of lindenmayer 9 "0:001,1:011" "0"

i honestly don't know. if i remove take n it blows my whole shit up.

By my estimation, that lindenmayer 9 "0:001,1:011" "0" will generate a string of over 19,000 steps. Without explicitly "taking 32", your pattern will try to fit 19,000 steps into a single cycle (assuming you don't use slow). @kit-christopher this might also help explain why things blow up without using take. Longer L-system strings and more iterations means your patterns will explode in size.

If you only want 32 steps, you really don't need to go 9 iterations deep. lindenmayer 4 should go deep enough, and then make sure to explicitly do take 32, regardless of the number of iterations.

@kit-christopher did you ever figure out how to use lindenmayer with note or n? I'm trying to do the same but can't figure out the key function to convert a character pattern to a pattern of doubles.

EDIT: I figured it out:

d1 
    $ slow 16 
    $ n (listToPat $ (take 256 $ lindenmayerI 5 "0:012010,1:20102,2:1011" "0"))
    # s "feel"

I used lindenmayerI and listToPat to make it work. However, my solution will not work if you want to use rests with "~".

1 Like

@kindohm the way i got it to work was to do something like this:

d1 $ (# note (arp "[converge up] [diverge down]" "<bf'min7'6 f'min7'7 fs'6by9'8 df'sus2'9>")) $
  stack [
    slow "<32 24 12>" $
    s $
    step' ["supertron", "supersaw", "superzow"] (take 512 $ lindenmayer 12 "0:1~~~,1:0~~~2~~~~~0~~~2~,2:2~1~,~:~~1~" "0")] #
    octave "4 3 3 4 3"
1 Like

So there in no way to walk a sequence like yield, pop, next, cdr, butfirst? On each cycle take the next 16 elements? These longer lindenmayer expansions can create similar changing none repetitive rhythms. I explored these L-systems rhythms years ago with LOGO programming and would like to work on them again.

Yeah we should get to the bottom of these questions because this stuff is super powerful. I posted my question about mapping a lindenmayer pattern of digits to a pattern of doubles at chat.toplap.org.

I'm not good enough at Haskell to know the right functions to convert the patterns correctly. Ideally I'd like to be able to map a Lindenmayer string to anything . I also would like to do what you're suggesting about navigating the generated sequence.

I'll update the doc page for lindenmayer once we uncover more info.

4 Likes

@kit-christopher I learned in a chat on chat.toplap.org about a way to make a Lindenmayer pattern more cleanly with numbers and rests. The trick is to use fmap read, but I don't understand Haskell well enough to fully grasp what is going on with fmap and read.

Here's a pattern with two Lindenmayers, one for the samples and one for the sample index:

d1 
  $ n (slow 16 $ fmap read $ step' ["0", "1", "2"] (take 256 $ lindenmayer 5 "0:111~,1:2~120,2:1~,~:02" "0"))  
  # s (slow 32 $ step' ["feel", "drum", "ifdrums"] (take 512 $ lindenmayer 5 "0:0110~~,1:~2~~221,2:101~2,~:~~201" "0"))

Further, if you want to map the steps of a pattern to something else, you can do so with a custom mapping utility function:

let strToNum "0" = 1
    strToNum "1" = (-1)
    strToNum "2" = 0.5

d1 
  $ speed (slow 16 
      $ fmap strToNum 
      $ step' ["0", "1", "2"] (take 256 $ lindenmayer 5 "0:111~,1:2~120,2:1~,~:02" "0")
  )  
  # s "feel"

Credit to "clarissaAdjoint" on the chat for helping with this.

4 Likes

@kindohm This is great. I know that in creating these patterns I do have complete control of the outcome, however, the complexity is so great I'm not sure I could even start to predict what it might sound like. :slight_smile:

2 Likes