# What is a Pattern?

This post is a wiki. Anyone with karma >1 is welcome to improve it.

How does the Pattern type work in Tidal?

edit retag close merge delete

Sort by » oldest newest most voted

Tidal works with Patterns a lot, and you've seen lots of them. Often you start with something in double-quotes

d1 \$ sound "[gabba bd*2 cp {cp sn:2}%1]"


which gives the impression that a Pattern is something like a list of stuff. But that's not quite right.

A Pattern is a function. Specifically, it's a function that takes a time interval as an argument, and returns a list of Events that take place during that interval.

Though you normally don't need to explicitly call the function to make music, the way to call a Pattern as a function is like this: let's first define a pattern

let pat = "a b"::Pattern String


here the ::Pattern String part is because Haskell needs a little help figuring out whether that double-quote expression is supposed to be just a normal String or a Pattern. Then,

arc pat (0,1)


will give you the list of Events that take place between 0 and 1.

What is an Event?

It's basically just a "thing" along with it's "interval" and "domain of influence". Usually those two are the same but they're tracked separately because things like density might want to change them. So the first event of the pattern above looks like:

((0 % 1,1 % 2),(0 % 1,1 % 2),"a")


which just means the thing "a" has an interval between 0 and 1/2 (the % is a way for Haskell to keep track of fractions without reducing them to decimals). So finally, the list of Events between 0 and 1 in the Pattern is

[((0 % 1,1 % 2),(0 % 1,1 % 2),"a"),((1 % 2,1 % 1),(1 % 2,1 % 1),"b")]


A bit wordy, but it can be useful to look at this stuff when trying to debug a complicated Pattern.

more