# ur

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Type: `ur :: Time -> Pattern String -> [(String, Pattern a)] -> [(String, Pattern a -> Pattern a)] -> Pattern a`

The ur function is designed for longer form composition, by allowing you to create 'patterns of patterns' in a repeating loop. It takes three parameters -- how long the loop will take, a pattern giving the structure of the composition, a lookup table for named patterns to feed into that structure, and a second lookup table for named transformations/fx.

Lets say you had three patterns (called 'a', 'b' and 'c'), and that you wanted to play them four cycles each, over twelve cycles in total. Here is one way to do it:

```let pats =
[
("a", stack [n "c4 c5 g4 f4 f5 g4 e5 g4" # s "superpiano" # gain "0.7",
n "[c3,g4,c4]" # s "superpiano"# gain "0.7"
]
),
("b", stack [n "d4 c5 g4 f4 f5 g4 e5 g4" # s "superpiano" # gain "0.7",
n "[d3,a4,d4]" # s "superpiano"# gain "0.7"
]
),
("c", stack [n "f4 c5 g4 f4 f5 g4 e5 g4" # s "superpiano" # gain "0.7",
n "[f4,c5,f4]" # s "superpiano"# gain "0.7"
]
)
]
in
d1 \$ ur 12 "a b c" pats []```

In `ur 12 "a b c" pats []`, the `12` is the duration of the loop (in cycles), the `"a b c"` is the structure of named patterns, and `pats` is the lookup table, defined above. So the "a b c" pattern happens over the 12 cycles, with the `a`, `b` and `c` standing in for each of the three patterns given in the lookup table. Because there are three events in this pattern, and it happens over 12 cycles. then each event is four cycles long.