This gist was very helpful to me and I wanted to write my own version with a dual-boot setup.
All actions are at your own risk!
This gist was very helpful to me and I wanted to write my own version with a dual-boot setup.
All actions are at your own risk!
So, let’s flip a coin: if it’s heads, play a drum, if it’s tails, play a cymbal. Easy. We can emulate a coin flip with our one_in function (introduced in the section on randomness) specifying a probability of 1 in 2: one_in(2). We can then use the result of this to decide between two pieces of code, the code to play the drum and the code to play the cymbal: | |
loop do | |
if one_in(2) | |
sample :drum_heavy_kick | |
else | |
sample :drum_cymbal_closed | |
end | |