Patterning offset ( `(0.25 ~>)` ) used in conjunction with `loopFirst`

Sorry if this question already exists, I wasn't able to quite find what I was looking for...

How would I go about patterning the offset function (not sure what it's actually called) combined with loopFirst?

What I actually want to do is "lock" various cycles of random patterns. Basically I want to be able to cycle through / pattern through different iterations of a random pattern.

Like in this example that generates random notes... I want to be able to play the 13th cycle and then the 91st cycle, and keep switching between them. In other words, I want to create a repeating 2 cycle pattern where I choose which cycles loop.

  loopFirst $ ("<12 90>" ~>) $ degradeBy 0.1 $ st "[t*16]" $ n (irand 16)

That code doesn't work, it just loops cycle 13 (12) over and over again. This works, but only plays half of each:

  loopFirst $ ("[12 90]" ~>) $ degradeBy 0.1 $ st "[t*16]" $ n (irand 16)

And for some reason, this doesn't work - it just plays cycle 13 (12) repeatedly:

  loopFirst $ ("[12 90]/2" ~>) $ degradeBy 0.1 $ st "[t*16]" $ n (irand 16)

OK in writing this question I think I found a way to do this:

  fast 0.5 $ loopFirst $ ("[29 90]" ~>) $ degradeBy 0.1 $ st "[t*32]" $ n (irand 16)

That code plays 1 cycle of the 30th iteration (29) and then 1 cycle of the 91st iteration (90), which is what I'm looking for.

But I'm wondering... is there a better/easier way to do this?

I don't have the st function, but the problem is that you want a pattern that repeats every two cycles, and loopFirst only repeats the first one.

Taking this example

d1 $ loopFirst $ ("<12 90>" ~>) $ degradeBy 0.1 $ s "[bd*16]" # n (irand 16)

You can speed it up on the way into loopFirst, then slow it down again, so it works over two cycles.

d1 $ slow 2 $ loopFirst $ fast 2 $ ("<12 90>" ~>) $ degradeBy 0.1 $ s "[bd*16]" # n (irand 16)

The outside function does this for you:

d1 $ outside 2 loopFirst $ ("<12 90>" ~>) $ degradeBy 0.1 $ s "[bd*16]" # n (irand 16)

Or instead you can just use timeLoop which takes as input the number of cycles to loop:

d1 $ timeLoop 2 $ ("<12 90>" ~>) $ degradeBy 0.1 $ s "[bd*16]" # n (irand 16)
1 Like

awesome @yaxu thank you, I'll try that!

st is my shortened alias for struct, sometimes I forget which things I use are in my custom functions and which are built-in