Is it possible to define the a rhythmic pattern and a note pattern separately?

Hi, I'm new to Tidal and getting very inspired by it, thank you!

I'm wondering if there is a way in Tidal to separate the rhythmic pattern from the note pattern. In the following snippet I play the [g3, d4] interval in a particular rhythm and then play the [f3, c4] interval in the same rhythm:

d1 $ note "<[[g3, d4]*2 [g3, d4]] [[f3, c4]*2 [f3, c4]]>"
  # s "supersquare"

I'm wondering if I could write this in some way where I only have to write the rhythmic pattern once and the intervals once. For example, if there was a rhythm function that took a rhythm template (I'm just making this up, of course):

d1 $ rhythm "x*2 x"
  # note "<[g3, d4] [f3, c4]>"
  # s "supersquare"

Welcome! I think this would do it:

d1 $ struct "t*2 t"
  $ note "<[g3, d4] [f3, c4]>"
  # s "supersquare"

Yes struct is exactly what I was looking for, thanks so much!

1 Like

This is a favourite of mine, makes pattern reuse very easy in your own code, but also when collaborating :slight_smile:
I talk about it a little here: