Random list selection

choose  list (array)

Choose an element at random from a list (array).

If no arguments are given, will return a lambda function which when called takes an argument which will be a list to be chosen from. This is useful for choosing random onset: vals for samples

Always returns a single element (or nil)

Introduced in v2.0

Examples

# Example 1

loop do
    play choose([60, 64, 67])
    sleep 1
    play chord(:c, :major).choose
    sleep 1
  end



 
#=> plays one of 60, 64 or 67 at random
 
#=> You can also call .choose on the list
 
 



# Example 2


live_loop :foo do
  sample :loop_amen, onset: choose  
  sleep 0.125
end



# Using choose for random sample onsets
 
# choose a random onset value each time