Difference between revisions of "choose"

From TidalCycles userbase
Jump to: navigation, search
Line 24: Line 24:
[[Category:Randomness and chance]]
[[Category:Randomness and chance]]
[[Category:Utility Functions]]

Revision as of 22:25, 25 November 2018

Type: choose :: [a] -> Pattern a

The choose function emits a stream of randomly choosen values from the given list, as a continuous pattern.

d1 $ sound "drum ~ drum drum" # n (choose [0,2,3])

As with all continuous patterns, you have to be careful to give them structure; in this case chooose gives you an infinitely detailed stream of random choices.


Type: wchoose :: [(a, Double)] -> Pattern a

wchoose is similar to choose, but allows you to 'weight' the choices, so some are more likely to be chosen than others. The following is similar to the previous example, but the 2 is twice as likely to be chosen than the 0 or 3.

d1 $ sound "drum ~ drum drum" # n (wchoose [(0,0.25,(2,0.5),(3,0.25)])

Note: prior to version 1.0.0 of tidal, the weights had to add up to 1, but this is no longer the case.