Skip to content

Instantly share code, notes, and snippets.

View MAvoss's full-sized avatar
🏠
Working from home

Joshua Voss MAvoss

🏠
Working from home
  • Arizona
  • 21:13 (UTC -12:00)
View GitHub Profile
@alptugan
alptugan / CONDTIONALS
Last active June 4, 2023 12:21
Sonic Pi Cheat Sheet
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