Trigger and struct and every

I was playing around with trigger, struct, and every today.

d1 $ trigger 1 $ struct "t f t f" $ n ("0 1 2 3") # s "bitwig" # midichan 0
When triggered it outputs 0 ~ 2 ~
~ representing false or no output.

d1 $ trigger 1 $ struct (every 3 rev "t f t f") $ n ("0 1 2 3") # s "bitwig" # midichan 0
when triggered outputs 1 ~ 3 ~ 0 ~ 2 ~ 0 ~ 2 ~

I thought the trigger would start on the first iteration of the pattern, like this:
0 ~ 2 ~ 0 ~ 2 ~1 ~ 3 ~ but it seems to start on the third (reversed).

Is this expected behaviour for trigger, or am I failing to understand something? (I'm probably failing to understand something).

Hi, I think the confusion is that every 3 applies the function every third cycle, but starting with the first one.

For more control you could use while, e.g. while "<f f t>" rev

3 Likes

Thanks Alex! Confusion still abounds, but I'm getting closer.

So in this case, I don't need every at all. I simply need to use while and set the rev in the while "pattern". The pattern determines when the rev is applied.

d1 $ trigger 1 $ while "<f f f t f f t>" rev $ n ("0 1 0 1") # s "bitwig" # midichan 0

I could use every like so:

d1 $ trigger 1 $ every 1 (while "<f f f t>" rev) $ n ("0 1 0 1") # s "bitwig" # midichan 0

But what's the point of that!

Thank you!

Yes that's right, while is an alternative to every. There's another whenmod which is similar to while https://tidalcycles.org/index.php/whenmod.

while is a bit newer and I think more flexible. Instead of every 10 you could do while "<f!9 t>". A bit more fiddly but more flexible, as you can just as easily do while "<t f!9>" or while "<f!3 t f!4 t t>" .. Or even while (iter 4 "<f!3 t>")

2 Likes

I'm trying to write a big structure song using lots of "do" as I wrote below. When I change from first do to second do it seems doesn't synchronize. Why?

--beginning
do
      let slices1 = "~ 15 12 5 6 [5 3] 5 14 ~ 3*2 5 ~ [0*4] 3 ~ 1"
      let slices2 = "~ [0 15] [~ 12] 5*2 ~ [5 3] 5 14 ~ 3*2 5 ~ [0*2] 3 ~ 1"
      let slices3 = "~ 2 ~ 3 ~ 0 ~ 1"
      d2
        $ trigger 1
        $ slice 16 slices1
        $ s "future"
        # n (irand 2)
        # cut 1
        # orbit 1

--first change

do
      let slices1 = "~ 15 12 5 6 [5 3] 5 14 ~ 3*2 5 ~ [0*4] 3 ~ 1"
      let slices2 = "~ [0 15] [~ 12] 5*2 ~ [5 3] 5 14 ~ 3*2 5 ~ [0*2] 3 ~ 1"
      let slices3 = "~ 2 ~ 3 ~ 0 ~ 1"
      d1
        $ trigger 1
        $ slice 4 slices3
        $ s "[bskick bssnare]"
        # n (irand 3)
        # pan (rand)
        # cut 2
        # orbit 0       
      d2
        $ trigger 1
        $ sometimesBy 0.15 (within (0, 0.25) (#squiz 4) . (hurry 4))
        $ slice 16 slices1
        $ s "future"
        # n (irand 2)
        # cut 1
        # orbit 1
      d7 $ trigger 1 $ fast 2 $ speed "2 1 1 1" #s "bshihat" #orbit 7

trigger resets the clock. Try qtrigger instead for a 'quantised' version.

1 Like

Thaks!!