Using one_in(N) in a live_loop creates probabilistic drum patterns with adjustable density
one_in(N) returns true with 1/N probability and false otherwise. Placing it as an if guard on sample calls creates stochastic beats: each step fires with probability 1/N. Lower N = denser; higher N = sparser. Combining use_random_seed with an n.times wrapper makes the pattern repeat deterministically every N steps while still sounding random within each pattern. Different instruments can have different probabilities for rhythmic variety.
Examples
live_loop :beat do use_random_seed 1000 8.times do sample :bd_haus if one_in(4) sample :elec_hi_snare if one_in(6) sleep 0.125 end end
Assessment
Write a probabilistic hi-hat pattern with around 50% density and a kick at 25% density. Explain how changing the seed number affects the feel.